From 1a4de9dd58201bb57a07ea931d1764064fc52e64 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 22 Sep 2018 00:32:03 -0700 Subject: 4588 --- html/subx/examples/ex5.subx.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'html/subx/examples/ex5.subx.html') diff --git a/html/subx/examples/ex5.subx.html b/html/subx/examples/ex5.subx.html index 6034b3f2..aa4f9761 100644 --- a/html/subx/examples/ex5.subx.html +++ b/html/subx/examples/ex5.subx.html @@ -64,38 +64,38 @@ if ('onhashchange' in window) { 9 # op subop mod rm32 base index scale r32 10 # 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 11 -12 ## function main +12 # main: 13 # prolog 14 55/push # push EBP 15 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP # copy ESP to EBP 16 # allocate x on the stack 17 81 5/subop/subtract 3/mod/direct 4/rm32/ESP 4/imm32 # subtract 4 bytes from ESP 18 -19 ## read(stdin, x, 1) -20 # fd = 0 (stdin) +19 # read(stdin, x, 1) +20 # fd = 0 (stdin) 21 bb/copy 0/imm32 # copy 0 to EBX -22 # initialize x (location to write result to) +22 # initialize x (location to write result to) 23 89/copy 3/mod/direct 1/rm32/ECX 5/r32/EBP # copy EBP to ECX -24 # size = 1 character +24 # size = 1 character 25 ba/copy 1/imm32 # copy 1 to EDX -26 # read(fd, x, size) -27 b8/copy 3/imm32 # copy 3 to EAX -28 cd/syscall 0x80/imm8 # int 80h +26 # read(fd, x, size) +27 b8/copy 3/imm32/read # copy 3 to EAX +28 cd/syscall 0x80/imm8 29 -30 ## write(stdout, x, 1) -31 # fd = 1 (stdout) +30 # write(stdout, x, 1) +31 # fd = 1 (stdout) 32 bb/copy 1/imm32 # copy 1 to EBX -33 # initialize x (location to read from) +33 # initialize x (location to read from) 34 89/copy 3/mod/direct 1/rm32/ECX 5/r32/EBP # copy EBP to ECX -35 # size = 1 character +35 # size = 1 character 36 ba/copy 1/imm32 # copy 1 to EDX -37 # write(fd, x, size) -38 b8/copy 4/imm32 # copy 4 to EAX -39 cd/syscall 0x80/imm8 # int 80h +37 # write(fd, x, size) +38 b8/copy 4/imm32/write # copy 4 to EAX +39 cd/syscall 0x80/imm8 40 -41 ## exit(EBX) -42 b8/copy 1/imm32 # copy 1 to EAX -43 cd/syscall 0x80/imm8 # int 80h +41 # exit(EBX) +42 b8/copy 1/imm32/exit # copy 1 to EAX +43 cd/syscall 0x80/imm8 44 45 # vim:ft=subx:nowrap -- cgit 1.4.1-2-gfad0 href='#n157'>157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203