about summary refs log tree commit diff stats
path: root/subx/ex5.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-26 12:19:02 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-26 12:19:02 -0700
commit6e51c60c699f795f14e49744a10f91d9609b044e (patch)
tree56b7b3372929abb8850a99141341395d50518c47 /subx/ex5.subx
parent7da8da495fbe9422f13198a83193d4b5477bf8f6 (diff)
downloadmu-6e51c60c699f795f14e49744a10f91d9609b044e.tar.gz
4424
Clean up format of example programs.
Diffstat (limited to 'subx/ex5.subx')
-rw-r--r--subx/ex5.subx37
1 files changed, 18 insertions, 19 deletions
diff --git a/subx/ex5.subx b/subx/ex5.subx
index b74af463..65ca4807 100644
--- a/subx/ex5.subx
+++ b/subx/ex5.subx
@@ -5,44 +5,43 @@
 #   $ subx run ex5
 
 == 0x08048054  # code segment, after leaving room for ELF header and segment headers
-# instruction                     effective address                                         operand     displacement    immediate
-# op          subop               mod           rm32          base      index     scale     r32
-# 1-3 bytes                                                                                             0/1/2/4 bytes   0/1/2/4 bytes
+# instruction                     effective address                                           operand     displacement    immediate
+# op          subop               mod             rm32          base      index     scale     r32
+# 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
 
 ## function main
   # prolog
-  55                                                                                                                                  # push EBP
-  89                              3/mod/direct  5/rm32/EBP                                  4/r32/ESP                                 # copy ESP to EBP
+  55                                                                                                                                        # push EBP
+  89                              3/mod/direct    5/rm32/EBP                                  4/r32/ESP                                     # copy ESP to EBP
   # allocate x on the stack
-  81            5/subop/subtract  3/mod/direct  4/rm32/ESP                                                              4/imm32       # subtract 4 bytes from ESP
+  81            5/subop/subtract  3/mod/direct    4/rm32/ESP                                                              4/imm32           # subtract 4 bytes from ESP
 
   ## read(stdin, x, 1)
   # fd = 0 (stdin)
-  bb                                                                                                                    0/imm32       # copy 0 to EBX
+  bb                                                                                                                      0/imm32           # copy 0 to EBX
   # set location to read character to
-  89                              3/mod/direct  1/rm32/ECX                                  5/r32/EBP                                 # copy EBP to ECX
+  89                              3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
   # size = 1 character
-  ba                                                                                                                    1/imm32       # copy 1 to EDX
+  ba                                                                                                                      1/imm32           # copy 1 to EDX
   # syscall = read
-  b8                                                                                                                    3/imm32       # copy 3 to EAX
+  b8                                                                                                                      3/imm32           # copy 3 to EAX
   # call
-  cd                                                                                                                    0x80/imm8     # int 80h
+  cd                                                                                                                      0x80/imm8         # int 80h
 
   ## write(stdout, x, 1)
   # fd = 1 (stdout)
-  bb                                                                                                                    1/imm32       # copy 1 to EBX
+  bb                                                                                                                      1/imm32           # copy 1 to EBX
   # set location of character to write out
-  89                              3/mod/direct  1/rm32/ECX                                  5/r32/EBP                                 # copy EBP to ECX
-                # ModR/M: 11 (direct mode) 101 (src EBP) 001 (dest ECX)
+  89                              3/mod/direct    1/rm32/ECX                                  5/r32/EBP                                     # copy EBP to ECX
   # size = 1 character
-  ba                                                                                                                    1/imm32       # copy 1 to EDX
+  ba                                                                                                                      1/imm32           # copy 1 to EDX
   # syscall = write
-  b8                                                                                                                    4/imm32       # copy 4 to EAX
+  b8                                                                                                                      4/imm32           # copy 4 to EAX
   # call
-  cd                                                                                                                    0x80/imm8     # int 80h
+  cd                                                                                                                      0x80/imm8         # int 80h
 
   ## exit(EBX)
-  b8                                                                                                                    1/imm32       # copy 1 to EAX
-  cd                                                                                                                    0x80/imm8     # int 80h
+  b8                                                                                                                      1/imm32           # copy 1 to EAX
+  cd                                                                                                                      0x80/imm8         # int 80h
 
 # vim:ft=subx:nowrap