diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-11-18 00:17:29 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-11-18 00:17:29 -0800 |
commit | b31455f81d8b7cecd66f577a0ce545dfe66d705b (patch) | |
tree | ccbb6c84395c3860748f1a1bdf73375508cbc274 /subx/056write.subx | |
parent | 3d9108130ff1f17865d6468976d66a0a7a8fe48d (diff) | |
download | mu-b31455f81d8b7cecd66f577a0ce545dfe66d705b.tar.gz |
4747 - subx: 'read' primitive
Diffstat (limited to 'subx/056write.subx')
-rw-r--r-- | subx/056write.subx | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/subx/056write.subx b/subx/056write.subx index e750c12d..015f9f69 100644 --- a/subx/056write.subx +++ b/subx/056write.subx @@ -15,20 +15,6 @@ # write: int # index at which writes go # data: (array byte) # prefixed by length as usual -== data - -# In-memory stream for tests to write() to. -# Also illustrates the layout of streams. -_test-stream: - # current write index - 00 00 00 00 - # current read index - 00 00 00 00 - # length (= 8) - 08 00 00 00 - # data - 00 00 00 00 00 00 00 00 # 8 bytes - == code # instruction effective address operand displacement immediate @@ -97,7 +83,7 @@ $write:end: 5d/pop-to-EBP c3/return -clear-stream: # f : (address stream) +clear-stream: # f : (address stream) -> <void> # prolog 55/push-EBP 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP @@ -151,6 +137,15 @@ test-write-single: e8/call write/disp32 # discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check-ints-equal(EAX, 2) + # push args + 68/push "F - test-read-single: return EAX"/imm32 + 68/push 2/imm32 + 50/push-EAX + # call + e8/call check-ints-equal/disp32 + # discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP # check-ints-equal(*_test-stream.data, 41/A 62/b 00 00, msg) # push args 68/push "F - test-write-single"/imm32 @@ -202,3 +197,15 @@ test-write-appends: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP # end c3/return + +== data + +_test-stream: + # current write index + 00 00 00 00 + # current read index + 00 00 00 00 + # length (= 8) + 08 00 00 00 + # data + 00 00 00 00 00 00 00 00 # 8 bytes |