From cb3d96bc29d86fbf4c35bbff50894d11252d15f9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 26 May 2019 10:37:28 -0700 Subject: new primitive: check-array-equal --- subx/075array-equal.subx | 68 +++++++++++++++++++++++++++++++++++++++++++++++ subx/apps/assort | Bin 23949 -> 24109 bytes subx/apps/crenshaw2-1 | Bin 21147 -> 21307 bytes subx/apps/crenshaw2-1b | Bin 21706 -> 21866 bytes subx/apps/factorial | Bin 20063 -> 20223 bytes subx/apps/handle | Bin 20869 -> 21029 bytes subx/apps/hex | Bin 24156 -> 24316 bytes subx/apps/pack | Bin 38788 -> 38948 bytes 8 files changed, 68 insertions(+) diff --git a/subx/075array-equal.subx b/subx/075array-equal.subx index e2b973f8..57eb3934 100644 --- a/subx/075array-equal.subx +++ b/subx/075array-equal.subx @@ -555,6 +555,74 @@ test-parse-array-of-ints-extra-whitespace: 5d/pop-to-EBP c3/return +# helper for later tests +# compare an array with a string representation of an array literal +check-array-equal: # a : (address array int), 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 + # var b/ECX = parse-array-of-ints(Heap, expected) + # . EAX = parse-array-of-ints(Heap, expected) + # . . push args + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) + 68/push Heap/imm32 + # . . call + e8/call parse-array-of-ints/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . b = EAX + 89/copy 3/mod/direct 1/rm32/ECX . . . 0/r32/EAX . . # copy EAX to ECX + # EAX = array-equal?(a, b) + # . . push args + 51/push-ECX + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) + # . . call + e8/call array-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-array-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-check-array-equal: + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # var ECX = [1, 2, 3] + 68/push 3/imm32 + 68/push 2/imm32 + 68/push 1/imm32 + 68/push 0xc/imm32/size + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # check-array-equal(ECX, "1 2 3", "msg") + # . . push args + 68/push "F - test-check-array-equal"/imm32 + 68/push "1 2 3"/imm32 + 51/push-ECX + # . . call + e8/call check-array-equal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/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 + == data Heap: diff --git a/subx/apps/assort b/subx/apps/assort index dc280d0a..c6a8840c 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 15856474..25fc3d05 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 ba29e49c..4c24542b 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 02c3a2d4..26b881fd 100755 Binary files a/subx/apps/factorial and b/subx/apps/factorial differ diff --git a/subx/apps/handle b/subx/apps/handle index ea47b0d4..916c6ec1 100755 Binary files a/subx/apps/handle and b/subx/apps/handle differ diff --git a/subx/apps/hex b/subx/apps/hex index b70b32c6..13c58d02 100755 Binary files a/subx/apps/hex and b/subx/apps/hex differ diff --git a/subx/apps/pack b/subx/apps/pack index 3c0c501e..26497e17 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ -- cgit 1.4.1-2-gfad0