6597
This commit is contained in:
parent
1afc882890
commit
59cf3ae983
|
@ -175,7 +175,7 @@ test-write-byte-hex-buffered:
|
|||
# . end
|
||||
c3/return
|
||||
|
||||
print-int32: # f: (addr stream byte), n: int
|
||||
write-int32-hex: # f: (addr stream byte), n: int
|
||||
# pseudocode:
|
||||
# write(f, "0x")
|
||||
# ecx = 28
|
||||
|
@ -194,7 +194,7 @@ print-int32: # f: (addr stream byte), n: int
|
|||
51/push-ecx
|
||||
# ecx = 28
|
||||
b9/copy-to-ecx 0x1c/imm32
|
||||
$print-int32:print-hex-prefix:
|
||||
$write-int32-hex:print-hex-prefix:
|
||||
# write(f, "0x")
|
||||
# . . push args
|
||||
68/push "0x"/imm32
|
||||
|
@ -203,10 +203,10 @@ $print-int32:print-hex-prefix:
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
$print-int32:loop:
|
||||
$write-int32-hex:loop:
|
||||
# if (ecx < 0) break
|
||||
81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0/imm32 # compare ecx
|
||||
7c/jump-if-< $print-int32:end/disp8
|
||||
7c/jump-if-< $write-int32-hex:end/disp8
|
||||
# eax = n >> ecx
|
||||
8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0xc/disp8 . # copy *(ebp+12) to eax
|
||||
d3/>>ecx 5/subop/pad-zeroes 3/mod/direct 0/rm32/eax . . . . . . # shift eax right by ecx bits, padding zeroes
|
||||
|
@ -223,8 +223,8 @@ $print-int32:loop:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# ecx -= 4
|
||||
81 5/subop/subtract 3/mod/direct 1/rm32/ecx . . . . . 4/imm32 # subtract from ecx
|
||||
eb/jump $print-int32:loop/disp8
|
||||
$print-int32:end:
|
||||
eb/jump $write-int32-hex:loop/disp8
|
||||
$write-int32-hex:end:
|
||||
# . restore registers
|
||||
59/pop-to-ecx
|
||||
58/pop-to-eax
|
||||
|
@ -233,8 +233,8 @@ $print-int32:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
test-print-int32:
|
||||
# - check that print-int32 prints the hex textual representation
|
||||
test-write-int32-hex:
|
||||
# - check that write-int32-hex prints the hex textual representation
|
||||
# setup
|
||||
# . clear-stream(_test-stream)
|
||||
# . . push args
|
||||
|
@ -243,17 +243,17 @@ test-print-int32:
|
|||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp
|
||||
# print-int32(_test-stream, 0x8899aa)
|
||||
# write-int32-hex(_test-stream, 0x8899aa)
|
||||
# . . push args
|
||||
68/push 0x8899aa/imm32
|
||||
68/push _test-stream/imm32
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# check-stream-equal(_test-stream, "0x008899aa", msg)
|
||||
# . . push args
|
||||
68/push "F - test-print-int32"/imm32
|
||||
68/push "F - test-write-int32-hex"/imm32
|
||||
68/push "0x008899aa"/imm32
|
||||
68/push _test-stream/imm32
|
||||
# . . call
|
||||
|
|
|
@ -154,14 +154,14 @@ $print-byte:end:
|
|||
c3/return
|
||||
|
||||
# just because Mu has no support for global variables yet
|
||||
print-int32-to-screen: # n: int
|
||||
write-int32-hex-to-screen: # n: int
|
||||
# . prologue
|
||||
55/push-ebp
|
||||
89/<- %ebp 4/r32/esp
|
||||
#
|
||||
(write-int32-hex-buffered Stdout *(ebp+8))
|
||||
(flush Stdout)
|
||||
$print-int32-to-screen:end:
|
||||
$write-int32-hex-to-screen:end:
|
||||
# . epilogue
|
||||
89/<- %esp 5/r32/ebp
|
||||
5d/pop-to-ebp
|
||||
|
|
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.
|
@ -915,12 +915,12 @@ $emit-string-literal-data:emit-length:
|
|||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print(out, "#{len}/imm32 ")
|
||||
# . print-int32(out, len)
|
||||
# . write-int32-hex(out, len)
|
||||
# . . push args
|
||||
50/push-eax
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8)
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . write(out, "/imm32 ")
|
||||
|
|
BIN
apps/factorial
BIN
apps/factorial
Binary file not shown.
|
@ -7817,7 +7817,7 @@ new-block-name: # fn: (addr function), out: (addr handle var)
|
|||
(write %edx "$")
|
||||
(write %edx %eax)
|
||||
(write %edx ":")
|
||||
(print-int32 %edx *Next-block-index)
|
||||
(write-int32-hex %edx *Next-block-index)
|
||||
ff 0/subop/increment *Next-block-index
|
||||
# var s/eax: slice = {name->data, name->data + name->write} (clobbering edx)
|
||||
# . eax = name->write
|
||||
|
|
BIN
apps/sigils
BIN
apps/sigils
Binary file not shown.
BIN
apps/survey
BIN
apps/survey
Binary file not shown.
|
@ -3628,12 +3628,12 @@ trace-sssns: # s1: (addr array byte), s2: (addr array byte), s3: (addr array by
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print-int32(*Trace-stream, n4)
|
||||
# write-int32-hex(*Trace-stream, n4)
|
||||
# . . push args
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x14/disp8 . # push *(ebp+20)
|
||||
ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# trace(s5) # implicitly adds a newline and finalizes the trace line
|
||||
|
@ -3719,12 +3719,12 @@ trace-snsns: # s1: (addr array byte), n2: int, s3: (addr array byte), n4: int,
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print-int32(*Trace-stream, n2)
|
||||
# write-int32-hex(*Trace-stream, n2)
|
||||
# . . push args
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# write(*Trace-stream, s3)
|
||||
|
@ -3735,12 +3735,12 @@ trace-snsns: # s1: (addr array byte), n2: int, s3: (addr array byte), n4: int,
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print-int32(*Trace-stream, n4)
|
||||
# write-int32-hex(*Trace-stream, n4)
|
||||
# . . push args
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x14/disp8 . # push *(ebp+20)
|
||||
ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# trace(s5) # implicitly adds a newline and finalizes the trace line
|
||||
|
@ -3967,12 +3967,12 @@ trace-slsns: # s1: (addr array byte), l2: (addr slice), s3: (addr array byte),
|
|||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# print-int32(*Trace-stream, n4)
|
||||
# write-int32-hex(*Trace-stream, n4)
|
||||
# . . push args
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x14/disp8 . # push *(ebp+20)
|
||||
ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream
|
||||
# . . call
|
||||
e8/call print-int32/disp32
|
||||
e8/call write-int32-hex/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# trace(s5) # implicitly adds a newline and finalizes the trace line
|
||||
|
|
BIN
apps/tests
BIN
apps/tests
Binary file not shown.
Loading…
Reference in New Issue