about summary refs log blame commit diff stats
path: root/subx/examples/ex1.subx
blob: 89d331ab39dd7d3a18c695b558ecf7fc7711ca00 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                                                       
                 
 


                                                        


                  
 
       
 
                   
                                     
                            
                     
 
                            
# First program: same as https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
# Just return 42.
#
# To run (from the subx directory):
#   $ subx translate examples/ex1.2.subx -o examples/ex1
#   $ subx run examples/ex1
# Expected result:
#   $ echo $?
#   42

== code

# syscall(exit, 42)
bb/copy-to-EBX  2a/imm32  # 42 in hex
b8/copy-to-EAX  1/imm32/exit
cd/syscall  0x80/imm8

# . . vim:nowrap:textwidth=0