2020-01-02 00:35:02 +00:00
|
|
|
# Just a test stub for mu-init.subx
|
|
|
|
#
|
|
|
|
# Try it out like this:
|
2020-03-16 04:03:12 +00:00
|
|
|
# $ ./translate_subx init.linux [0-9]*.subx mu-init.subx mu-init-test.subx
|
2020-01-02 00:35:02 +00:00
|
|
|
# $ ./a.elf # should run all tests
|
|
|
|
|
2020-03-16 04:03:12 +00:00
|
|
|
main: # args: (addr array (addr array byte)) -> result/ebx: int
|
2020-01-02 00:35:02 +00:00
|
|
|
# . prologue
|
|
|
|
55/push-ebp
|
|
|
|
89/<- %ebp 4/r32/esp
|
|
|
|
# . save registers
|
|
|
|
50/push-eax
|
|
|
|
56/push-esi
|
|
|
|
# esi = args
|
|
|
|
8b/-> *(ebp+8) 6/r32/esi
|
|
|
|
{
|
|
|
|
# if (argc <= 1) break
|
2020-03-16 04:03:12 +00:00
|
|
|
81 7/subop/compare *esi 4/imm32
|
2020-01-17 02:31:12 +00:00
|
|
|
7e/jump-if-<= break/disp8
|
2020-01-02 00:35:02 +00:00
|
|
|
# if (argv[1] != "test") break
|
2020-03-16 04:03:12 +00:00
|
|
|
(string-equal? *(esi+8) "test") # => eax
|
2020-01-02 00:35:02 +00:00
|
|
|
3d/compare-eax-and 0/imm32
|
2020-01-17 02:31:12 +00:00
|
|
|
74/jump-if-= break/disp8
|
2020-01-02 00:35:02 +00:00
|
|
|
#
|
|
|
|
(run-tests)
|
|
|
|
# return *Num-test-failures
|
|
|
|
8b/-> *Num-test-failures 3/r32/ebx
|
|
|
|
eb/jump $main:end/disp8
|
|
|
|
}
|
|
|
|
$main:end:
|
|
|
|
# . restore registers
|
|
|
|
5e/pop-to-esi
|
|
|
|
58/pop-to-eax
|
|
|
|
# . epilogue
|
|
|
|
89/<- %esp 5/r32/ebp
|
|
|
|
5d/pop-to-ebp
|
|
|
|
c3/return
|