From bb2b6ba7fd72bbebc3a4490d090f080e7b8628cc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 4 Aug 2018 17:00:27 -0700 Subject: 4478 --- html/subx/ex6.subx.html | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 html/subx/ex6.subx.html (limited to 'html/subx/ex6.subx.html') diff --git a/html/subx/ex6.subx.html b/html/subx/ex6.subx.html new file mode 100644 index 00000000..f79324f6 --- /dev/null +++ b/html/subx/ex6.subx.html @@ -0,0 +1,95 @@ + + + + +Mu - subx/ex6.subx + + + + + + + + + + +
+ 1 ## print out a (global variable) string to stdout
+ 2 #
+ 3 # To run:
+ 4 #   $ subx translate ex6.subx ex6
+ 5 #   $ subx run ex6
+ 6 #   Hello, world!
+ 7 
+ 8 == 0x08048074  # code segment, after leaving room for ELF header and segment headers
+ 9 # instruction                     effective address                                                   operand     displacement    immediate
+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   ## write(stdout, x, 1)
+14   # fd = 1 (stdout)
+15   bb/copy                                                                                                                         1/imm32           # copy 1 to EBX
+16   # initialize x (location to write result to)
+17   b9/copy                                                                                                                         0x08049097/imm32  # copy to ECX
+18   # initialize size
+19   ba/copy                                                                                                                         0x08049093/imm32  # copy to EDX
+20   8b/copy                         0/mod/indirect  2/rm32/edx                                          2/r32/edx                                     # copy *EDX to EDX
+21   # write(fd, x, size)
+22   b8/copy                                                                                                                         4/imm32           # copy 4 to EAX
+23   cd/syscall                                                                                                                      0x80/imm8         # int 80h
+24 
+25   ## exit(EBX)
+26   b8/copy                                                                                                                         1/imm32           # copy 1 to EAX
+27   cd/syscall                                                                                                                      0x80/imm8         # int 80h
+28 
+29 == 0x08049093
+30 # size of string
+31 0e 00 00 00
+32 # string
+33   48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21 0a
+34 # h  e  l  l  o  ,  ␣  w  o  r  l  d  !  newline
+35 
+36 # vim:ft=subx:nowrap
+
+ + + -- cgit 1.4.1-2-gfad0