integration tests for desugaring indirect mode
They caught a logic error.
This commit is contained in:
parent
9191049790
commit
4f8b2bd2fb
BIN
apps/desugar
BIN
apps/desugar
Binary file not shown.
|
@ -597,6 +597,210 @@ test-convert-direct-mode:
|
|||
5d/pop-to-EBP
|
||||
c3/return
|
||||
|
||||
test-convert-register-indirect-mode:
|
||||
# . prolog
|
||||
55/push-EBP
|
||||
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
|
||||
# setup
|
||||
# . clear-stream(_test-input-stream)
|
||||
# . . push args
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-input-buffered-file+4)
|
||||
# . . push args
|
||||
b8/copy-to-EAX _test-input-buffered-file/imm32
|
||||
05/add-to-EAX 4/imm32
|
||||
50/push-EAX
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-output-stream)
|
||||
# . . push args
|
||||
68/push _test-output-stream/imm32
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-output-buffered-file+4)
|
||||
# . . push args
|
||||
b8/copy-to-EAX _test-output-buffered-file/imm32
|
||||
05/add-to-EAX 4/imm32
|
||||
50/push-EAX
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# initialize input
|
||||
# . write(_test-input-stream, "ab *ecx")
|
||||
# . . push args
|
||||
68/push "ab *ecx"/imm32
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
# convert(_test-input-buffered-file, _test-output-buffered-file)
|
||||
# . . push args
|
||||
68/push _test-output-buffered-file/imm32
|
||||
68/push _test-input-buffered-file/imm32
|
||||
# . . call
|
||||
e8/call convert/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
# check that the line just passed through
|
||||
# . flush(_test-output-buffered-file)
|
||||
# . . push args
|
||||
68/push _test-output-buffered-file/imm32
|
||||
# . . call
|
||||
e8/call flush/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
#? # dump _test-output-stream {{{
|
||||
#? # . write(2/stderr, "^")
|
||||
#? # . . push args
|
||||
#? 68/push "^"/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # . write-stream(2/stderr, _test-output-stream)
|
||||
#? # . . push args
|
||||
#? 68/push _test-output-stream/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write-stream/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # . write(2/stderr, "$\n")
|
||||
#? # . . push args
|
||||
#? 68/push "$\n"/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # }}}
|
||||
# . check-stream-equal(_test-output-stream, "ab 0/mod/indirect 0x00000001/rm32 \n", msg)
|
||||
# . . push args
|
||||
68/push "F - test-convert-indirect-mode"/imm32
|
||||
68/push "ab 0/mod/indirect 0x00000001/rm32 \n"/imm32
|
||||
68/push _test-output-stream/imm32
|
||||
# . . call
|
||||
e8/call check-stream-equal/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
|
||||
# . epilog
|
||||
89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP
|
||||
5d/pop-to-EBP
|
||||
c3/return
|
||||
|
||||
test-convert-register-indirect-mode-without-displacement:
|
||||
# . prolog
|
||||
55/push-EBP
|
||||
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
|
||||
# setup
|
||||
# . clear-stream(_test-input-stream)
|
||||
# . . push args
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-input-buffered-file+4)
|
||||
# . . push args
|
||||
b8/copy-to-EAX _test-input-buffered-file/imm32
|
||||
05/add-to-EAX 4/imm32
|
||||
50/push-EAX
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-output-stream)
|
||||
# . . push args
|
||||
68/push _test-output-stream/imm32
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# . clear-stream(_test-output-buffered-file+4)
|
||||
# . . push args
|
||||
b8/copy-to-EAX _test-output-buffered-file/imm32
|
||||
05/add-to-EAX 4/imm32
|
||||
50/push-EAX
|
||||
# . . call
|
||||
e8/call clear-stream/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
# initialize input
|
||||
# . write(_test-input-stream, "ab *(ecx)")
|
||||
# . . push args
|
||||
68/push "ab *(ecx)"/imm32
|
||||
68/push _test-input-stream/imm32
|
||||
# . . call
|
||||
e8/call write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
# convert(_test-input-buffered-file, _test-output-buffered-file)
|
||||
# . . push args
|
||||
68/push _test-output-buffered-file/imm32
|
||||
68/push _test-input-buffered-file/imm32
|
||||
# . . call
|
||||
e8/call convert/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
# check that the line just passed through
|
||||
# . flush(_test-output-buffered-file)
|
||||
# . . push args
|
||||
68/push _test-output-buffered-file/imm32
|
||||
# . . call
|
||||
e8/call flush/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP
|
||||
#? # dump _test-output-stream {{{
|
||||
#? # . write(2/stderr, "^")
|
||||
#? # . . push args
|
||||
#? 68/push "^"/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # . write-stream(2/stderr, _test-output-stream)
|
||||
#? # . . push args
|
||||
#? 68/push _test-output-stream/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write-stream/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # . write(2/stderr, "$\n")
|
||||
#? # . . push args
|
||||
#? 68/push "$\n"/imm32
|
||||
#? 68/push 2/imm32/stderr
|
||||
#? # . . call
|
||||
#? e8/call write/disp32
|
||||
#? # . . discard args
|
||||
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
|
||||
#? # }}}
|
||||
# . check-stream-equal(_test-output-stream, "ab 0/mod/indirect 0x00000001/rm32 \n", msg)
|
||||
# . . push args
|
||||
68/push "F - test-convert-indirect-mode-without-displacement"/imm32
|
||||
68/push "ab 0/mod/indirect 0x00000001/rm32 \n"/imm32
|
||||
68/push _test-output-stream/imm32
|
||||
# . . call
|
||||
e8/call check-stream-equal/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP
|
||||
# . epilog
|
||||
89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP
|
||||
5d/pop-to-EBP
|
||||
c3/return
|
||||
|
||||
# beware: modifies 'word'
|
||||
emit-direct-mode: # word : (address slice), out : (address buffered-file)
|
||||
# . prolog
|
||||
|
@ -889,11 +1093,16 @@ $next-word-or-expression:check-for-paren:
|
|||
# . compare
|
||||
3d/compare-EAX-and 0x2a/imm32/asterisk
|
||||
75/jump-if-not-equal $next-word-or-expression:regular-word/disp8
|
||||
# if (line->data[line->read] != '(') goto error1
|
||||
# if (line->data[line->read] == ' ') goto error1
|
||||
8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xd/disp8 . # copy byte at *(ESI+ECX+12+1) to AL
|
||||
# . compare
|
||||
3d/compare-EAX-and 0x20/imm32/space
|
||||
74/jump-if-equal $next-word-or-expression:error1/disp8
|
||||
# if (line->data[line->read] != '(') goto regular word
|
||||
8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xd/disp8 . # copy byte at *(ESI+ECX+12+1) to AL
|
||||
# . compare
|
||||
3d/compare-EAX-and 0x28/imm32/open-paren
|
||||
75/jump-if-not-equal $next-word-or-expression:error1/disp8
|
||||
75/jump-if-not-equal $next-word-or-expression:regular-word/disp8
|
||||
$next-word-or-expression:paren:
|
||||
# skip-until-close-paren(line)
|
||||
# . . push args
|
||||
|
|
Loading…
Reference in New Issue
Block a user