diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-02-05 23:29:15 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-02-05 23:29:15 -0800 |
commit | f070557859fd1e8396d8bdbdc3ba6162c1d7e118 (patch) | |
tree | e0d8c008124de35270e9eaea3a2de969956856a5 /subx/055stream.subx | |
parent | ddd2e9891e843279cf1c190c1ee7c5ceef9ef96b (diff) | |
download | mu-f070557859fd1e8396d8bdbdc3ba6162c1d7e118.tar.gz |
4952
Diffstat (limited to 'subx/055stream.subx')
-rw-r--r-- | subx/055stream.subx | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/subx/055stream.subx b/subx/055stream.subx index 602a6e28..0d196311 100644 --- a/subx/055stream.subx +++ b/subx/055stream.subx @@ -5,10 +5,9 @@ # read : int # index that we've read until # data : (array byte) # prefixed by length as usual # -# primitives for operating on streams: +# some primitives for operating on streams: # - clear-stream (clears everything but the data length) -# - stream-equal? (compares stream data with a string; ignores read pointer) -# - rewind-reads (resets read pointer; not yet implemented) +# - rewind-stream (resets read pointer) == code # instruction effective address register displacement immediate @@ -59,3 +58,21 @@ $clear-stream:end: 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP 5d/pop-to-EBP c3/return + +rewind-stream: # f : (address stream) -> <void> + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # . save registers + 50/push-EAX + # EAX = f + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX + # f->read = 0 + c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) +$rewind-stream:end: + # . restore registers + 58/pop-to-EAX + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return |