From ce2c1efc41470764126e9a1a7f4e0cfec4213587 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 14 Jul 2019 09:42:36 -0700 Subject: . --- html/subx/074print-int-decimal.subx.html | 537 +++++++++++++++---------------- 1 file changed, 264 insertions(+), 273 deletions(-) (limited to 'html/subx/074print-int-decimal.subx.html') diff --git a/html/subx/074print-int-decimal.subx.html b/html/subx/074print-int-decimal.subx.html index cbfcbb8d..f84532a3 100644 --- a/html/subx/074print-int-decimal.subx.html +++ b/html/subx/074print-int-decimal.subx.html @@ -3,8 +3,8 @@ Mu - subx/074print-int-decimal.subx - - + + @@ -14,17 +14,16 @@ pre { font-family: monospace; color: #000000; background-color: #c6c6c6; } body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.subxH1Comment { color: #005faf; text-decoration: underline; } .subxComment { color: #005faf; } -.Constant { color: #008787; } -.LineNr { } .subxS1Comment { color: #0000af; } -.CommentedCode { color: #8a8a8a; } -.subxFunction { color: #af5f00; text-decoration: underline; } +.LineNr { } .subxTest { color: #5f8700; } -.Folded { color: #080808; background-color: #949494; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } +.Folded { color: #080808; background-color: #949494; } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Constant { color: #008787; } .subxS2Comment { color: #8a8a8a; } -.subxH1Comment { color: #005faf; text-decoration: underline; } --> @@ -41,7 +40,7 @@ function JumpToLine() if (lineNum.indexOf('L') == -1) { lineNum = 'L'+lineNum; } - lineElem = document.getElementById(lineNum); + var lineElem = document.getElementById(lineNum); /* Always jump to new location even if the line was hidden inside a fold, or * we corrected the raw number to a line ID. */ @@ -67,289 +66,281 @@ if ('onhashchange' in window) { 5 # . op subop mod rm32 base index scale r32 6 # . 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 7 - 8 #? Entry: # run a single test, while debugging - 9 #? e8/call test-print-int32-decimal-negative/disp32 - 10 #? - 11 #? # syscall(exit, Num-test-failures) - 12 #? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX - 13 #? b8/copy-to-EAX 1/imm32/exit - 14 #? cd/syscall 0x80/imm8 - 15 - 16 print-int32-decimal: # out : (address stream), n : int32 - 17 # works by generating characters from lowest to highest and pushing them - 18 # to the stack, before popping them one by one into the stream - 19 # - 20 # pseudocode: - 21 # push sentinel - 22 # EAX = abs(n) - 23 # while true - 24 # sign-extend EAX into EDX - 25 # EAX, EDX = EAX/10, EAX%10 - 26 # EDX += '0' - 27 # push EDX - 28 # if (EAX == 0) break - 29 # if n < 0 - 30 # push '-' - 31 # w = out->write - 32 # curr = &out->data[out->write] - 33 # max = &out->data[out->length] - 34 # while true - 35 # pop into EAX - 36 # if (EAX == sentinel) break - 37 # if (curr >= max) abort - 38 # *curr = AL - 39 # ++curr - 40 # ++w - 41 # out->write = w - 42 # (based on K&R itoa: https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa) - 43 # (this pseudocode contains registers because operations like division - 44 # require specific registers in x86) - 45 # - 46 # . prolog - 47 55/push-EBP - 48 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 49 # . save registers - 50 50/push-EAX - 51 51/push-ECX - 52 52/push-EDX - 53 53/push-EBX - 54 57/push-EDI - 55 # ten/ECX = 10 - 56 b9/copy-to-ECX 0xa/imm32 - 57 # push sentinel - 58 68/push 0/imm32/sentinel - 59 # EAX = abs(n) - 60 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 . # copy *(EBP+12) to EAX - 61 3d/compare-EAX-with 0/imm32 - 62 7d/jump-if-greater-or-equal $print-int32-decimal:read-loop/disp8 - 63 $print-int32-decimal:negative: - 64 f7 3/subop/negate 3/mod/direct 0/rm32/EAX . . . . . . # negate EAX - 65 $print-int32-decimal:read-loop: - 66 # EAX, EDX = EAX / 10, EAX % 10 - 67 99/sign-extend-EAX-into-EDX - 68 f7 7/subop/idiv 3/mod/direct 1/rm32/ECX . . . . . . # divide EDX:EAX by ECX, storing quotient in EAX and remainder in EDX - 69 # EDX += '0' - 70 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 0x30/imm32 # add to EDX - 71 # push EDX - 72 52/push-EDX - 73 # if (EAX == 0) break - 74 3d/compare-EAX-and 0/imm32 - 75 7f/jump-if-greater $print-int32-decimal:read-loop/disp8 - 76 $print-int32-decimal:read-break: - 77 # if (n < 0) push('-') - 78 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 0/imm32 # compare *(EBP+12) - 79 7d/jump-if-greater-or-equal $print-int32-decimal:write/disp8 - 80 $print-int32-decimal:push-negative: - 81 68/push 0x2d/imm32/- - 82 $print-int32-decimal:write: - 83 # EDI = out - 84 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI - 85 # w/EDX = out->write - 86 8b/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy *EDI to EDX - 87 # curr/ECX = &out->data[out->write] - 88 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 1/r32/ECX 0xc/disp8 . # copy EBX+EDX+12 to ECX - 89 # max/EBX = &out->data[out->length] - 90 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 8/disp8 . # copy *(EDI+8) to EBX - 91 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 3/index/EBX . 3/r32/EBX 0xc/disp8 . # copy EDI+EBX+12 to EBX - 92 $print-int32-decimal:write-loop: - 93 # pop into EAX - 94 58/pop-to-EAX - 95 # if (EAX == sentinel) break - 96 3d/compare-EAX-and 0/imm32/sentinel - 97 74/jump-if-equal $print-int32-decimal:write-break/disp8 - 98 # if (curr >= max) abort - 99 39/compare 3/mod/direct 1/rm32/ECX . . . 3/r32/EBX . . # compare ECX with EBX -100 7d/jump-if-greater-or-equal $print-int32-decimal:abort/disp8 -101 $print-int32-decimal:write-char: -102 # *curr = AL -103 88/copy-byte 0/mod/indirect 1/rm32/ECX . . . 0/r32/AL . . # copy AL to byte at *ECX -104 # ++curr -105 41/increment-ECX -106 # ++w -107 42/increment-EDX -108 eb/jump $print-int32-decimal:write-loop/disp8 -109 $print-int32-decimal:write-break: -110 # out->write = w -111 89/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy EDX to *EDI -112 $print-int32-decimal:end: -113 # . restore registers -114 5f/pop-to-EDI -115 5b/pop-to-EBX -116 5a/pop-to-EDX -117 59/pop-to-ECX -118 58/pop-to-EAX -119 # . epilog -120 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -121 5d/pop-to-EBP -122 c3/return -123 -124 $print-int32-decimal:abort: -125 # . _write(2/stderr, error) -126 # . . push args -127 68/push "print-int32-decimal: out of space\n"/imm32 -128 68/push 2/imm32/stderr -129 # . . call -130 e8/call _write/disp32 -131 # . . discard args -132 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -133 # . syscall(exit, 1) -134 bb/copy-to-EBX 1/imm32 -135 b8/copy-to-EAX 1/imm32/exit -136 cd/syscall 0x80/imm8 -137 # never gets here -138 -139 test-print-int32-decimal: -140 # - check that a single-digit number converts correctly -141 # setup -142 # . clear-stream(_test-stream) -143 # . . push args + 8 print-int32-decimal: # out : (address stream), n : int32 + 9 # works by generating characters from lowest to highest and pushing them + 10 # to the stack, before popping them one by one into the stream + 11 # + 12 # pseudocode: + 13 # push sentinel + 14 # EAX = abs(n) + 15 # while true + 16 # sign-extend EAX into EDX + 17 # EAX, EDX = EAX/10, EAX%10 + 18 # EDX += '0' + 19 # push EDX + 20 # if (EAX == 0) break + 21 # if n < 0 + 22 # push '-' + 23 # w = out->write + 24 # curr = &out->data[out->write] + 25 # max = &out->data[out->length] + 26 # while true + 27 # pop into EAX + 28 # if (EAX == sentinel) break + 29 # if (curr >= max) abort + 30 # *curr = AL + 31 # ++curr + 32 # ++w + 33 # out->write = w + 34 # (based on K&R itoa: https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa) + 35 # (this pseudocode contains registers because operations like division + 36 # require specific registers in x86) + 37 # + 38 # . prolog + 39 55/push-EBP + 40 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 41 # . save registers + 42 50/push-EAX + 43 51/push-ECX + 44 52/push-EDX + 45 53/push-EBX + 46 57/push-EDI + 47 # ten/ECX = 10 + 48 b9/copy-to-ECX 0xa/imm32 + 49 # push sentinel + 50 68/push 0/imm32/sentinel + 51 # EAX = abs(n) + 52 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 . # copy *(EBP+12) to EAX + 53 3d/compare-EAX-with 0/imm32 + 54 7d/jump-if-greater-or-equal $print-int32-decimal:read-loop/disp8 + 55 $print-int32-decimal:negative: + 56 f7 3/subop/negate 3/mod/direct 0/rm32/EAX . . . . . . # negate EAX + 57 $print-int32-decimal:read-loop: + 58 # EAX, EDX = EAX / 10, EAX % 10 + 59 99/sign-extend-EAX-into-EDX + 60 f7 7/subop/idiv 3/mod/direct 1/rm32/ECX . . . . . . # divide EDX:EAX by ECX, storing quotient in EAX and remainder in EDX + 61 # EDX += '0' + 62 81 0/subop/add 3/mod/direct 2/rm32/EDX . . . . . 0x30/imm32 # add to EDX + 63 # push EDX + 64 52/push-EDX + 65 # if (EAX == 0) break + 66 3d/compare-EAX-and 0/imm32 + 67 7f/jump-if-greater $print-int32-decimal:read-loop/disp8 + 68 $print-int32-decimal:read-break: + 69 # if (n < 0) push('-') + 70 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 0/imm32 # compare *(EBP+12) + 71 7d/jump-if-greater-or-equal $print-int32-decimal:write/disp8 + 72 $print-int32-decimal:push-negative: + 73 68/push 0x2d/imm32/- + 74 $print-int32-decimal:write: + 75 # EDI = out + 76 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI + 77 # w/EDX = out->write + 78 8b/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy *EDI to EDX + 79 # curr/ECX = &out->data[out->write] + 80 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 1/r32/ECX 0xc/disp8 . # copy EBX+EDX+12 to ECX + 81 # max/EBX = &out->data[out->length] + 82 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 8/disp8 . # copy *(EDI+8) to EBX + 83 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 3/index/EBX . 3/r32/EBX 0xc/disp8 . # copy EDI+EBX+12 to EBX + 84 $print-int32-decimal:write-loop: + 85 # pop into EAX + 86 58/pop-to-EAX + 87 # if (EAX == sentinel) break + 88 3d/compare-EAX-and 0/imm32/sentinel + 89 74/jump-if-equal $print-int32-decimal:write-break/disp8 + 90 # if (curr >= max) abort + 91 39/compare 3/mod/direct 1/rm32/ECX . . . 3/r32/EBX . . # compare ECX with EBX + 92 73/jump-if-greater-or-equal-unsigned $print-int32-decimal:abort/disp8 + 93 $print-int32-decimal:write-char: + 94 # *curr = AL + 95 88/copy-byte 0/mod/indirect 1/rm32/ECX . . . 0/r32/AL . . # copy AL to byte at *ECX + 96 # ++curr + 97 41/increment-ECX + 98 # ++w + 99 42/increment-EDX +100 eb/jump $print-int32-decimal:write-loop/disp8 +101 $print-int32-decimal:write-break: +102 # out->write = w +103 89/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy EDX to *EDI +104 $print-int32-decimal:end: +105 # . restore registers +106 5f/pop-to-EDI +107 5b/pop-to-EBX +108 5a/pop-to-EDX +109 59/pop-to-ECX +110 58/pop-to-EAX +111 # . epilog +112 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +113 5d/pop-to-EBP +114 c3/return +115 +116 $print-int32-decimal:abort: +117 # . _write(2/stderr, error) +118 # . . push args +119 68/push "print-int32-decimal: out of space\n"/imm32 +120 68/push 2/imm32/stderr +121 # . . call +122 e8/call _write/disp32 +123 # . . discard args +124 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +125 # . syscall(exit, 1) +126 bb/copy-to-EBX 1/imm32 +127 b8/copy-to-EAX 1/imm32/exit +128 cd/syscall 0x80/imm8 +129 # never gets here +130 +131 test-print-int32-decimal: +132 # - check that a single-digit number converts correctly +133 # setup +134 # . clear-stream(_test-stream) +135 # . . push args +136 68/push _test-stream/imm32 +137 # . . call +138 e8/call clear-stream/disp32 +139 # . . discard args +140 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +141 # print-int32-decimal(_test-stream, 9) +142 # . . push args +143 68/push 9/imm32 144 68/push _test-stream/imm32 145 # . . call -146 e8/call clear-stream/disp32 +146 e8/call print-int32-decimal/disp32 147 # . . discard args -148 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -149 # print-int32-decimal(_test-stream, 9) +148 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +149 # check-stream-equal(_test-stream, "9", msg) 150 # . . push args -151 68/push 9/imm32 -152 68/push _test-stream/imm32 -153 # . . call -154 e8/call print-int32-decimal/disp32 -155 # . . discard args -156 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -157 # check-stream-equal(_test-stream, "9", msg) -158 # . . push args -159 68/push "F - test-print-int32-decimal"/imm32 -160 68/push "9"/imm32 -161 68/push _test-stream/imm32 -162 # . . call -163 e8/call check-stream-equal/disp32 -164 # . . discard args -165 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -166 # . end -167 c3/return -168 -169 test-print-int32-decimal-zero: -170 # - check that 0 converts correctly -171 # setup -172 # . clear-stream(_test-stream) -173 # . . push args +151 68/push "F - test-print-int32-decimal"/imm32 +152 68/push "9"/imm32 +153 68/push _test-stream/imm32 +154 # . . call +155 e8/call check-stream-equal/disp32 +156 # . . discard args +157 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +158 # . end +159 c3/return +160 +161 test-print-int32-decimal-zero: +162 # - check that 0 converts correctly +163 # setup +164 # . clear-stream(_test-stream) +165 # . . push args +166 68/push _test-stream/imm32 +167 # . . call +168 e8/call clear-stream/disp32 +169 # . . discard args +170 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +171 # print-int32-decimal(_test-stream, 0) +172 # . . push args +173 68/push 0/imm32 174 68/push _test-stream/imm32 175 # . . call -176 e8/call clear-stream/disp32 +176 e8/call print-int32-decimal/disp32 177 # . . discard args -178 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -179 # print-int32-decimal(_test-stream, 0) +178 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +179 # check-stream-equal(_test-stream, "0", msg) 180 # . . push args -181 68/push 0/imm32 -182 68/push _test-stream/imm32 -183 # . . call -184 e8/call print-int32-decimal/disp32 -185 # . . discard args -186 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -187 # check-stream-equal(_test-stream, "0", msg) -188 # . . push args -189 68/push "F - test-print-int32-decimal-zero"/imm32 -190 68/push "0"/imm32 -191 68/push _test-stream/imm32 -192 # . . call -193 e8/call check-stream-equal/disp32 -194 # . . discard args -195 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -196 # . end -197 c3/return -198 -199 test-print-int32-decimal-multiple-digits: -200 # - check that a multi-digit number converts correctly -201 # setup -202 # . clear-stream(_test-stream) -203 # . . push args +181 68/push "F - test-print-int32-decimal-zero"/imm32 +182 68/push "0"/imm32 +183 68/push _test-stream/imm32 +184 # . . call +185 e8/call check-stream-equal/disp32 +186 # . . discard args +187 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +188 # . end +189 c3/return +190 +191 test-print-int32-decimal-multiple-digits: +192 # - check that a multi-digit number converts correctly +193 # setup +194 # . clear-stream(_test-stream) +195 # . . push args +196 68/push _test-stream/imm32 +197 # . . call +198 e8/call clear-stream/disp32 +199 # . . discard args +200 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +201 # print-int32-decimal(_test-stream, 10) +202 # . . push args +203 68/push 0xa/imm32 204 68/push _test-stream/imm32 205 # . . call -206 e8/call clear-stream/disp32 +206 e8/call print-int32-decimal/disp32 207 # . . discard args -208 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -209 # print-int32-decimal(_test-stream, 10) +208 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +209 # check-stream-equal(_test-stream, "10", msg) 210 # . . push args -211 68/push 0xa/imm32 -212 68/push _test-stream/imm32 -213 # . . call -214 e8/call print-int32-decimal/disp32 -215 # . . discard args -216 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -217 # check-stream-equal(_test-stream, "10", msg) -218 # . . push args -219 68/push "F - test-print-int32-decimal-multiple-digits"/imm32 -220 68/push "10"/imm32 -221 68/push _test-stream/imm32 -222 # . . call -223 e8/call check-stream-equal/disp32 -224 # . . discard args -225 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -226 # . end -227 c3/return -228 -229 test-print-int32-decimal-negative: -230 # - check that a negative single-digit number converts correctly -231 # setup -232 # . clear-stream(_test-stream) -233 # . . push args +211 68/push "F - test-print-int32-decimal-multiple-digits"/imm32 +212 68/push "10"/imm32 +213 68/push _test-stream/imm32 +214 # . . call +215 e8/call check-stream-equal/disp32 +216 # . . discard args +217 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +218 # . end +219 c3/return +220 +221 test-print-int32-decimal-negative: +222 # - check that a negative single-digit number converts correctly +223 # setup +224 # . clear-stream(_test-stream) +225 # . . push args +226 68/push _test-stream/imm32 +227 # . . call +228 e8/call clear-stream/disp32 +229 # . . discard args +230 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +231 # print-int32-decimal(_test-stream, -9) +232 # . . push args +233 68/push -9/imm32 234 68/push _test-stream/imm32 235 # . . call -236 e8/call clear-stream/disp32 +236 e8/call print-int32-decimal/disp32 237 # . . discard args -238 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -239 # print-int32-decimal(_test-stream, -9) -240 # . . push args -241 68/push -9/imm32 -242 68/push _test-stream/imm32 -243 # . . call -244 e8/call print-int32-decimal/disp32 -245 # . . discard args -246 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -247 +-- 26 lines: #? # dump _test-stream --------------------------------------------------------------------------------------------------------------------- -273 # check-stream-equal(_test-stream, "-9", msg) -274 # . . push args -275 68/push "F - test-print-int32-decimal-negative"/imm32 -276 68/push "-9"/imm32 -277 68/push _test-stream/imm32 -278 # . . call -279 e8/call check-stream-equal/disp32 -280 # . . discard args -281 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -282 # . end -283 c3/return -284 -285 test-print-int32-decimal-negative-multiple-digits: -286 # - check that a multi-digit number converts correctly -287 # setup -288 # . clear-stream(_test-stream) -289 # . . push args +238 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +239 +-- 26 lines: #? # dump _test-stream --------------------------------------------------------------------------------------------------------------------- +265 # check-stream-equal(_test-stream, "-9", msg) +266 # . . push args +267 68/push "F - test-print-int32-decimal-negative"/imm32 +268 68/push "-9"/imm32 +269 68/push _test-stream/imm32 +270 # . . call +271 e8/call check-stream-equal/disp32 +272 # . . discard args +273 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +274 # . end +275 c3/return +276 +277 test-print-int32-decimal-negative-multiple-digits: +278 # - check that a multi-digit number converts correctly +279 # setup +280 # . clear-stream(_test-stream) +281 # . . push args +282 68/push _test-stream/imm32 +283 # . . call +284 e8/call clear-stream/disp32 +285 # . . discard args +286 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +287 # print-int32-decimal(_test-stream, -10) +288 # . . push args +289 68/push -0xa/imm32 290 68/push _test-stream/imm32 291 # . . call -292 e8/call clear-stream/disp32 +292 e8/call print-int32-decimal/disp32 293 # . . discard args -294 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -295 # print-int32-decimal(_test-stream, -10) +294 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +295 # check-stream-equal(_test-stream, "-10", msg) 296 # . . push args -297 68/push -0xa/imm32 -298 68/push _test-stream/imm32 -299 # . . call -300 e8/call print-int32-decimal/disp32 -301 # . . discard args -302 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -303 # check-stream-equal(_test-stream, "-10", msg) -304 # . . push args -305 68/push "F - test-print-int32-decimal-negative-multiple-digits"/imm32 -306 68/push "-10"/imm32 -307 68/push _test-stream/imm32 -308 # . . call -309 e8/call check-stream-equal/disp32 -310 # . . discard args -311 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -312 # . end -313 c3/return -314 -315 # . . vim:nowrap:textwidth=0 +297 68/push "F - test-print-int32-decimal-negative-multiple-digits"/imm32 +298 68/push "-10"/imm32 +299 68/push _test-stream/imm32 +300 # . . call +301 e8/call check-stream-equal/disp32 +302 # . . discard args +303 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +304 # . end +305 c3/return +306 +307 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0