6393 - start running .mu apps in CI

This commit is contained in:
Kartik Agaram 2020-05-24 20:36:31 -07:00
parent 27b1e19ebe
commit 4d14c3fefd
5 changed files with 73 additions and 12 deletions

View File

@ -4,7 +4,7 @@
== code
kernel-string-to-string: # ad: (addr allocation-descriptor), in: (addr kernel-string) -> result/eax: (addr array byte)
kernel-string-to-string: # ad: (addr allocation-descriptor), in: (addr kernel-string), out: (addr handle array byte)
# . prologue
55/push-ebp
89/<- %ebp 4/r32/esp
@ -18,22 +18,24 @@ kernel-string-to-string: # ad: (addr allocation-descriptor), in: (addr kernel-s
(kernel-string-length *(ebp+0xc))
89/<- %ecx 0/r32/eax
# result = allocate-array(ad, len)
(allocate-array *(ebp+8) %ecx) # => eax
(allocate-array *(ebp+8) %ecx *(ebp+0x10))
# var c/edx: byte = 0
ba/copy-to-edx 0/imm32
# var src/esi: (addr byte) = in
8b/-> *(ebp+0xc) 6/r32/esi
# var dest/edi: (addr byte) = result->data
8b/-> *(ebp+0x10) 7/r32/edi
(lookup *edi *(edi+4)) # => eax
8d/copy-address *(eax+4) 7/r32/edi
{
$kernel-string-to-string:loop:
# c = *src
8a/byte-> *esi 2/r32/edx
8a/byte-> *esi 2/r32/dl
# if (c == 0) break
81 7/subop/compare %edx 0/imm32
74/jump-if-= break/disp8
# *dest = c
88/byte<- *edi 2/r32/edx
88/byte<- *edi 2/r32/dl
# ++src
46/increment-esi
# ++dest

View File

@ -31,8 +31,8 @@ fn test-factorial {
check-ints-equal result 0x78 "F - test-factorial"
}
fn main args: (addr array string) -> exit-status/ebx: int {
var a/eax: (addr array string) <- copy args
fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
var a/eax: (addr array (addr array byte)) <- copy args
var tmp/ecx: int <- length a
$main-body: {
# if (len(args) <= 1) factorial(5)
@ -44,7 +44,7 @@ fn main args: (addr array string) -> exit-status/ebx: int {
break $main-body
}
# if (args[1] == "test") run-tests()
var tmp2/ecx: (addr string) <- index a, 1
var tmp2/ecx: (addr addr array byte) <- index a, 1
var tmp3/eax: boolean <- string-equal? *tmp2, "test"
compare tmp3, 0
{

BIN
apps/mu

Binary file not shown.

View File

@ -27,13 +27,14 @@ $Entry:initialize-args:
8b/-> *esi 2/r32/edx
# argc is in words; convert it to bytes
c1/shift 4/subop/left %edx 2/imm8
# var tmp/eax: handle
# var tmp/ebx: handle
68/push 0/imm32
68/push 0/imm32
89/<- %eax 4/r32/esp
89/<- %ebx 4/r32/esp
# var args/edi: (addr array (addr array byte))
(allocate-array Heap %edx %eax)
8b/-> *(eax+4) 7/r32/edi
(allocate-array Heap %edx %ebx)
(lookup *ebx *(ebx+4)) # => eax
89/<- %edi 0/r32/eax
# var curr/ecx: (addr kernel-string) = argv
8d/copy-address *(esi+4) 1/r32/ecx
# var max/edx: (addr kernel-string) = argv+4+argc
@ -45,7 +46,8 @@ $Entry:initialize-args:
39/compare %ecx 2/r32/edx
73/jump-if-addr>= break/disp8
# *dest = kernel-string-to-string(*curr)
(kernel-string-to-string Heap *ecx) # => eax
(kernel-string-to-string Heap *ecx %ebx)
(lookup *ebx *(ebx+4)) # => eax
89/<- *esi 0/r32/eax
# curr += 4
81 0/subop/add %ecx 4/imm32

View File

@ -338,4 +338,61 @@ echo mu
./translate_subx init.$OS [0-9]*.subx apps/mu.subx
diff apps/mu a.elf
# Mu programs
echo ex1.mu
./translate_mu apps/ex1.mu
test $EMULATED && {
./bootstrap run a.elf || ret=$?
test $ret -eq 42 # life, the universe and everything
}
test $NATIVE && {
./a.elf || ret=$?
test $ret -eq 42 # life, the universe and everything
}
echo ex2.mu
./translate_mu apps/ex2.mu
test $EMULATED && {
./bootstrap run a.elf || ret=$?
test $ret -eq 7
}
test $NATIVE && {
./a.elf || ret=$?
test $ret -eq 7
}
echo ex2.2.mu
./translate_mu apps/ex2.2.mu
test $EMULATED && {
./bootstrap run a.elf || ret=$?
test $ret -eq 4
}
test $NATIVE && {
./a.elf || ret=$?
test $ret -eq 4
}
echo ex3.mu
./translate_mu apps/ex3.mu
test $EMULATED && {
./bootstrap run a.elf || ret=$?
test $ret -eq 55
}
test $NATIVE && {
./a.elf || ret=$?
test $ret -eq 55
}
echo ex3.2.mu
./translate_mu apps/ex3.2.mu
test $EMULATED && {
./bootstrap run a.elf || ret=$?
test $ret -eq 55
}
test $NATIVE && {
./a.elf || ret=$?
test $ret -eq 55
}
exit 0