diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-01-20 22:50:44 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-01-20 22:50:44 -0800 |
commit | 332cbba31f60c3915ba109a14105d4e8f7369a7a (patch) | |
tree | db7d26fc1be0ae8719e8be54ff86d099caab7d68 /subx/apps/pack.subx | |
parent | 1f0f3813034921607771bf9627d973ba40fec9e4 (diff) | |
download | mu-332cbba31f60c3915ba109a14105d4e8f7369a7a.tar.gz |
4937
Diffstat (limited to 'subx/apps/pack.subx')
-rw-r--r-- | subx/apps/pack.subx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index d7052b0b..f09a6b2f 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -86,27 +86,43 @@ $main:end: # read first word as opcode and write-slice # if 0f or f2 or f3 read second opcode and write-slice # if 'f2 0f' or 'f3 0f' read third opcode and write-slice -# scan words +# while true: +# word-slice = next-word +# if empty(word-slice) break # if has metadata 'mod', parse into mod # if has metadata 'rm32', parse into rm32 # if has metadata 'r32', parse into r32 # if has metadata 'subop', parse into r32 # if at least one of the 3 was present, print-byte -# scan words +# while true: +# word-slice = next-word +# if empty(word-slice) break # if has metadata 'base', parse into base # if has metadata 'index', parse into index # if has metadata 'scale', parse into scale # if at least one of the 3 was present, print-byte # parse errors => <abort> -# scan words +# while true: +# word-slice = next-word +# if empty(word-slice) break # if has metadata 'disp8', emit as 1 byte # if has metadata 'disp16', emit as 2 bytes # if has metadata 'disp32', emit as 4 bytes -# scan words +# while true: +# word-slice = next-word +# if empty(word-slice) break # if has metadata 'imm8', emit # if has metadata 'imm32', emit as 4 bytes # finally, emit line prefixed with a ' # ' +# has-metadata?(word-slice, m): +# next-token2(word-slice, '/') # skip +# while true: +# slice = next-token2(word-slice, '/') +# if empty?(slice) break +# if equal(slice, m) return true +# return false + # simplifications since we perform zero error handling (continuing to rely on the C++ version for that): # missing fields are always 0-filled # bytes never mentioned are silently dropped; if you don't provide /mod, /rm32 or /r32 you don't get a 0 modrm byte. You get *no* modrm byte. @@ -123,6 +139,7 @@ $main:end: # # we won't bother saving the internal structure of lines; reparsing should be cheap using two primitives: # next-token(stream, delim char) -> slice (start, end pointers) +# next-token(stream, slice, delim char) -> slice' # slice-equal?(slice, string) # helpers: |