about summary refs log tree commit diff stats
path: root/022arithmetic.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-20 20:01:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-20 20:01:34 -0700
commit8e7b4429787bc2b7fe289f264d09a4b1f5f6b081 (patch)
treeda78a0432f4cc01f9083bda4b04a9cb0e5c46142 /022arithmetic.cc
parentc31209c6a14cebad97976b4089fe6a69f074f748 (diff)
downloadmu-8e7b4429787bc2b7fe289f264d09a4b1f5f6b081.tar.gz
3235
Diffstat (limited to '022arithmetic.cc')
0 files changed, 0 insertions, 0 deletions
rtik.com> 2020-01-16 18:31:12 -0800 committer Kartik Agaram <vc@akkartik.com> 2020-01-16 18:31:12 -0800 5897 - rename comparison instructions' href='/akkartik/mu/commit/mu-init-test.subx?h=hlt&id=6070c23e5e1c60d3bb169e43bddfa59b1d322427'>6070c23e ^
7ca19e4e ^
c48ce3c8 ^
7ca19e4e ^
6070c23e ^
7ca19e4e ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


                                   
                                                                            

                                     
                                                                









                            
                                     
                               
                                    
                                               
                                
                              













                                        
# Just a test stub for mu-init.subx
#
# Try it out like this:
#   $ ./translate_subx init.linux [0-9]*.subx mu-init.subx mu-init-test.subx
#   $ ./a.elf  # should run all tests

main:  # args: (addr array (addr array byte)) -> result/ebx: int
    # . 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
      81 7/subop/compare *esi 4/imm32
      7e/jump-if-<= break/disp8
      # if (argv[1] != "test") break
      (string-equal? *(esi+8) "test")  # => eax
      3d/compare-eax-and 0/imm32
      74/jump-if-= break/disp8
      #
      (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