From 78357b8852626b510527f3b8d770a7dd8956fcc7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 16 Jul 2021 08:38:43 -0700 Subject: . --- html/linux/apps/ex6.subx.html | 96 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 html/linux/apps/ex6.subx.html (limited to 'html/linux/apps/ex6.subx.html') diff --git a/html/linux/apps/ex6.subx.html b/html/linux/apps/ex6.subx.html new file mode 100644 index 00000000..5aa4fd53 --- /dev/null +++ b/html/linux/apps/ex6.subx.html @@ -0,0 +1,96 @@ + + + + +Mu - linux/apps/ex6.subx + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/linux/apps/ex6.subx +
+ 1 # Print out a (global variable) string to stdout.
+ 2 #
+ 3 # To run:
+ 4 #   $ bootstrap/bootstrap translate apps/ex6.subx -o ex6
+ 5 #   $ bootstrap/bootstrap run ex6
+ 6 #   Hello, world!
+ 7 
+ 8 == code
+ 9 
+10 # . op          subop               mod             rm32          base        index         scale       r32
+11 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
+12 
+13 Entry:
+14     # write(stdout, X, Size)
+15     # . fd = 1 (stdout)
+16     bb/copy-to-ebx  1/imm32
+17     # . initialize X (location to write result to)
+18     b9/copy-to-ecx  X/imm32
+19     # . initialize Size
+20     8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           2/r32/edx   Size/disp32     .                 # copy *Size to edx
+21     # . syscall
+22     e8/call  syscall_write/disp32
+23 
+24     # exit(ebx)
+25     e8/call  syscall_exit/disp32
+26 
+27 == data
+28 
+29 Size:  # size of string
+30     0x0d/imm32  # 13
+31 X:  # string to print
+32     48 65 6c 6c 6f 20 77 6f 72 6c 64 21 0a       00
+33 #   H  e  l  l  o  ␣  w  o  r  l  d  !  newline  null
+34 
+35 # . . vim:nowrap:textwidth=0
+
+ + + -- cgit 1.4.1-2-gfad0