6594 - start standardizing the meaning of 'print'
This commit is contained in:
parent
40323d3388
commit
05dabd816a
|
@ -1,4 +1,4 @@
|
|||
# Print the (hex) textual representation of numbers.
|
||||
# Write out the (hex) textual representation of numbers.
|
||||
|
||||
== code
|
||||
# instruction effective address register displacement immediate
|
||||
|
@ -90,7 +90,7 @@ test-append-byte-hex:
|
|||
c3/return
|
||||
|
||||
# print the hex representation for the lowest byte of a number
|
||||
print-byte-buffered: # f: (addr buffered-file), n: int
|
||||
write-byte-hex-buffered: # f: (addr buffered-file), n: int
|
||||
# . prologue
|
||||
55/push-ebp
|
||||
89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp
|
||||
|
@ -123,7 +123,7 @@ print-byte-buffered: # f: (addr buffered-file), n: int
|
|||
e8/call write-byte-buffered/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
$print-byte-buffered:end:
|
||||
$write-byte-hex-buffered:end:
|
||||
# . restore registers
|
||||
58/pop-to-eax
|
||||
# . epilogue
|
||||
|
@ -131,8 +131,8 @@ $print-byte-buffered:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
test-print-byte-buffered:
|
||||
# - check that print-byte-buffered prints the hex textual representation
|
||||
test-write-byte-hex-buffered:
|
||||
# - check that write-byte-hex-buffered prints the hex textual representation
|
||||
# setup
|
||||
# . clear-stream(_test-stream)
|
||||
# . . push args
|
||||
|
@ -148,12 +148,12 @@ test-print-byte-buffered:
|
|||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# print-byte-buffered(_test-buffered-file, 0xa) # exercises digit, non-digit as well as leading zero
|
||||
# write-byte-hex-buffered(_test-buffered-file, 0xa) # exercises digit, non-digit as well as leading zero
|
||||
# . . push args
|
||||
68/push 0xa/imm32
|
||||
68/push _test-buffered-file/imm32
|
||||
# . . call
|
||||
e8/call print-byte-buffered/disp32
|
||||
e8/call write-byte-hex-buffered/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# flush(_test-buffered-file)
|
||||
|
@ -165,7 +165,7 @@ test-print-byte-buffered:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# check-stream-equal(_test-stream, "0a", msg)
|
||||
# . . push args
|
||||
68/push "F - test-print-byte-buffered"/imm32
|
||||
68/push "F - test-write-byte-hex-buffered"/imm32
|
||||
68/push "0a"/imm32
|
||||
68/push _test-stream/imm32
|
||||
# . . call
|
|
@ -51,12 +51,12 @@ error-byte: # ed: (addr exit-descriptor), out: (addr buffered-file), msg: (addr
|
|||
e8/call write-buffered/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print-byte-buffered(out, byte)
|
||||
# write-byte-hex-buffered(out, byte)
|
||||
# . . push args
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x14/disp8 . # push *(ebp+20)
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call print-byte-buffered/disp32
|
||||
e8/call write-byte-hex-buffered/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-buffered(out, Newline)
|
||||
|
|
|
@ -26,12 +26,12 @@ $emit-hex:loop:
|
|||
# if (curr >= width) break
|
||||
39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # compare ecx with edx
|
||||
7d/jump-if->= $emit-hex:end/disp8
|
||||
# print-byte-buffered(out, ebx) # only BL used
|
||||
# write-byte-hex-buffered(out, ebx) # only BL used
|
||||
# . . push args
|
||||
53/push-ebx
|
||||
57/push-edi
|
||||
# . . call
|
||||
e8/call print-byte-buffered/disp32
|
||||
e8/call write-byte-hex-buffered/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write-byte-buffered(out, ' ')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# write-int: add a single int to a stream
|
||||
# write-int: add (the binary representation of) a single int to a stream
|
||||
|
||||
== code
|
||||
# instruction effective address register displacement immediate
|
||||
|
|
BIN
apps/assort
BIN
apps/assort
Binary file not shown.
BIN
apps/braces
BIN
apps/braces
Binary file not shown.
BIN
apps/calls
BIN
apps/calls
Binary file not shown.
BIN
apps/crenshaw2-1
BIN
apps/crenshaw2-1
Binary file not shown.
Binary file not shown.
BIN
apps/dquotes
BIN
apps/dquotes
Binary file not shown.
BIN
apps/factorial
BIN
apps/factorial
Binary file not shown.
BIN
apps/sigils
BIN
apps/sigils
Binary file not shown.
BIN
apps/survey
BIN
apps/survey
Binary file not shown.
BIN
apps/tests
BIN
apps/tests
Binary file not shown.
Loading…
Reference in New Issue