From cf02c20bb02f5d2fbfee5557baf68c0e2ca5a042 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 4 Dec 2018 00:29:06 -0800 Subject: 4832 Let's start adding ':end' labels in all functions, just because it helps us visualize where function calls end in traces, thanks to the '--map' commandline argument. --- html/subx/063print-byte.subx.html | 171 +++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 85 deletions(-) (limited to 'html/subx/063print-byte.subx.html') diff --git a/html/subx/063print-byte.subx.html b/html/subx/063print-byte.subx.html index de66d1b4..0dfe9269 100644 --- a/html/subx/063print-byte.subx.html +++ b/html/subx/063print-byte.subx.html @@ -119,91 +119,92 @@ if ('onhashchange' in window) { 54 e8/call write-byte/disp32 55 # . . discard args 56 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 57 # . restore registers - 58 59/pop-to-ECX - 59 58/pop-to-EAX - 60 # . epilog - 61 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 62 5d/pop-to-EBP - 63 c3/return - 64 - 65 # extract lowest 4 bits and convert to 8-byte ascii - 66 # return 0xffffffff if more than 4 bits are set - 67 hex-char: # n : num -> char_or_error/EAX - 68 # . prolog - 69 55/push-EBP - 70 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 71 # EAX = n - 72 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX - 73 # if it's <= 9 add '0' to it - 74 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0x9/imm32 # compare EAX - 75 7f/jump-if-greater $hex-char:check2/disp8 - 76 05/add-to-EAX 0x30/imm32/'0' - 77 eb/jump $hex-char:end/disp8 - 78 $hex-char:check2: - 79 # else if it's <= 15 add ('a' - 10) to it - 80 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xf/imm32 # compare EAX - 81 7f/jump-if-greater $hex-char:error/disp8 - 82 05/add-to-EAX 0x57/imm32 # 'a' - 10 - 83 eb/jump $hex-char:end/disp8 - 84 $hex-char:error: - 85 # otherwise return 0xffffffff - 86 b8/copy-to-EAX 0xffffffff/imm32 - 87 $hex-char:end: - 88 # . epilog - 89 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 90 5d/pop-to-EBP - 91 c3/return - 92 - 93 test-print-byte: - 94 # - check that print-byte prints the hex textual representation - 95 # setup - 96 # . clear-stream(_test-stream) - 97 # . . push args - 98 68/push _test-stream/imm32 - 99 # . . call -100 e8/call clear-stream/disp32 -101 # . . discard args -102 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -103 # . clear-stream(_test-buffered-file+4) -104 # . . push args -105 b8/copy-to-EAX _test-buffered-file/imm32 -106 05/add-to-EAX 4/imm32 -107 50/push-EAX -108 # . . call -109 e8/call clear-stream/disp32 -110 # . . discard args -111 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -112 # print-byte(_test-buffered-file, 0xa) # exercises digit, non-digit as well as leading zero -113 # . . push args -114 68/push 0xa/imm32 -115 68/push _test-buffered-file/imm32 -116 # . . call -117 e8/call print-byte/disp32 -118 # . . discard args -119 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -120 # flush(_test-buffered-file) -121 # . . push args -122 68/push _test-buffered-file/imm32 -123 # . . call -124 e8/call flush/disp32 -125 # . . discard args -126 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -127 # check-ints-equal(*_test-stream->data, '0a', msg) -128 # . . push args -129 68/push "F - test-print-byte"/imm32 -130 68/push 0x6130/imm32/0a -131 # . . push *_test-stream->data -132 b8/copy-to-EAX _test-stream/imm32 -133 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) -134 # . . call -135 e8/call check-ints-equal/disp32 -136 # . . discard args -137 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -138 # . end -139 c3/return -140 -141 # . . vim:nowrap:textwidth=0 + 57 $print-byte:end: + 58 # . restore registers + 59 59/pop-to-ECX + 60 58/pop-to-EAX + 61 # . epilog + 62 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 63 5d/pop-to-EBP + 64 c3/return + 65 + 66 # extract lowest 4 bits and convert to 8-byte ascii + 67 # return 0xffffffff if more than 4 bits are set + 68 hex-char: # n : num -> char_or_error/EAX + 69 # . prolog + 70 55/push-EBP + 71 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 72 # EAX = n + 73 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX + 74 # if it's <= 9 add '0' to it + 75 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0x9/imm32 # compare EAX + 76 7f/jump-if-greater $hex-char:check2/disp8 + 77 05/add-to-EAX 0x30/imm32/'0' + 78 eb/jump $hex-char:end/disp8 + 79 $hex-char:check2: + 80 # else if it's <= 15 add ('a' - 10) to it + 81 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xf/imm32 # compare EAX + 82 7f/jump-if-greater $hex-char:error/disp8 + 83 05/add-to-EAX 0x57/imm32 # 'a' - 10 + 84 eb/jump $hex-char:end/disp8 + 85 $hex-char:error: + 86 # otherwise return 0xffffffff + 87 b8/copy-to-EAX 0xffffffff/imm32 + 88 $hex-char:end: + 89 # . epilog + 90 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 91 5d/pop-to-EBP + 92 c3/return + 93 + 94 test-print-byte: + 95 # - check that print-byte prints the hex textual representation + 96 # setup + 97 # . clear-stream(_test-stream) + 98 # . . push args + 99 68/push _test-stream/imm32 +100 # . . call +101 e8/call clear-stream/disp32 +102 # . . discard args +103 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +104 # . clear-stream(_test-buffered-file+4) +105 # . . push args +106 b8/copy-to-EAX _test-buffered-file/imm32 +107 05/add-to-EAX 4/imm32 +108 50/push-EAX +109 # . . call +110 e8/call clear-stream/disp32 +111 # . . discard args +112 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +113 # print-byte(_test-buffered-file, 0xa) # exercises digit, non-digit as well as leading zero +114 # . . push args +115 68/push 0xa/imm32 +116 68/push _test-buffered-file/imm32 +117 # . . call +118 e8/call print-byte/disp32 +119 # . . discard args +120 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +121 # flush(_test-buffered-file) +122 # . . push args +123 68/push _test-buffered-file/imm32 +124 # . . call +125 e8/call flush/disp32 +126 # . . discard args +127 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +128 # check-ints-equal(*_test-stream->data, '0a', msg) +129 # . . push args +130 68/push "F - test-print-byte"/imm32 +131 68/push 0x6130/imm32/0a +132 # . . push *_test-stream->data +133 b8/copy-to-EAX _test-stream/imm32 +134 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) +135 # . . call +136 e8/call check-ints-equal/disp32 +137 # . . discard args +138 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +139 # . end +140 c3/return +141 +142 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0