From 0b2d2d97284c41ad095e9dbbe6657b857af1c7b9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 25 May 2019 00:39:16 -0700 Subject: new primitive for tests: check-string-equal --- subx/054string-equal.subx | 53 ++++++++++++++++++++++++++++++++++++++++++++++ subx/apps/assort | Bin 22506 -> 22646 bytes subx/apps/crenshaw2-1 | Bin 19675 -> 19815 bytes subx/apps/crenshaw2-1b | Bin 20234 -> 20374 bytes subx/apps/factorial | Bin 18591 -> 18731 bytes subx/apps/handle | Bin 19418 -> 19558 bytes subx/apps/hex | Bin 22684 -> 22824 bytes subx/apps/pack | Bin 37316 -> 37456 bytes 8 files changed, 53 insertions(+) (limited to 'subx') diff --git a/subx/054string-equal.subx b/subx/054string-equal.subx index 6c23fccb..caeb0ea0 100644 --- a/subx/054string-equal.subx +++ b/subx/054string-equal.subx @@ -179,4 +179,57 @@ test-compare-inequal-strings-equal-lengths: 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP c3/return +# helper for later tests +check-string-equal: # s : (address string), expected : (address string), msg : (address string) + # . 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 = string-equal?(s, expected) + # . . push args + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) + # . . call + e8/call string-equal?/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check-ints-equal(EAX, 1, msg) + # . . push args + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 . # push *(EBP+16) + 68/push 1/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-string-equal: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 + +# test the helper +test-check-string-equal: + # check-string-equal?("Abc", "Abc") + # . . push args + 68/push "Abc"/imm32 + 68/push "Abc"/imm32 + # . . call + e8/call check-string-equal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # check-ints-equal(EAX, 1, msg) + # . . push args + 68/push "F - test-check-string-equal"/imm32 + 68/push 0/imm32/false + 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 + c3/return + # . . vim:nowrap:textwidth=0 diff --git a/subx/apps/assort b/subx/apps/assort index 9a0c6bbe..20cef59b 100755 Binary files a/subx/apps/assort and b/subx/apps/assort differ diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index 4c15f534..20110cc2 100755 Binary files a/subx/apps/crenshaw2-1 and b/subx/apps/crenshaw2-1 differ diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index 4f629ee2..b93d10c2 100755 Binary files a/subx/apps/crenshaw2-1b and b/subx/apps/crenshaw2-1b differ diff --git a/subx/apps/factorial b/subx/apps/factorial index af0ddc65..b3aa69c5 100755 Binary files a/subx/apps/factorial and b/subx/apps/factorial differ diff --git a/subx/apps/handle b/subx/apps/handle index fc09834c..c99743af 100755 Binary files a/subx/apps/handle and b/subx/apps/handle differ diff --git a/subx/apps/hex b/subx/apps/hex index 5bf09dcc..1ac76865 100755 Binary files a/subx/apps/hex and b/subx/apps/hex differ diff --git a/subx/apps/pack b/subx/apps/pack index c72f538a..002dbda7 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ -- cgit 1.4.1-2-gfad0