From 68666b07b88fb4d72ff824550dd271b84520fdf5 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 19 Sep 2019 15:19:07 -0700 Subject: 5669 --- 069allocate.subx | 28 ++++++++++++++++++++++++++++ 075array-equal.subx | 26 -------------------------- apps/assort | Bin 40175 -> 40175 bytes apps/braces | Bin 39569 -> 39569 bytes apps/calls | Bin 44930 -> 44930 bytes apps/crenshaw2-1 | Bin 33919 -> 33919 bytes apps/crenshaw2-1b | Bin 34478 -> 34478 bytes apps/dquotes | Bin 45364 -> 45364 bytes apps/factorial | Bin 32931 -> 32931 bytes apps/handle | Bin 33785 -> 33785 bytes apps/hex | Bin 42573 -> 42573 bytes apps/pack | Bin 52846 -> 52846 bytes apps/sigils | Bin 52868 -> 52868 bytes apps/survey | Bin 49448 -> 49448 bytes apps/tests | Bin 38992 -> 38992 bytes 15 files changed, 28 insertions(+), 26 deletions(-) diff --git a/069allocate.subx b/069allocate.subx index 8845c8c3..f7063d2e 100644 --- a/069allocate.subx +++ b/069allocate.subx @@ -16,11 +16,39 @@ # very same 'allocate' helper. They just need a new allocation descriptor for # their book-keeping. +# A default allocation descriptor for programs to use. +== data +Heap: + # curr + 0/imm32 + # limit + 0/imm32 + == code # instruction effective address register displacement immediate # . op subop mod rm32 base index scale r32 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes +# Let's start initializing the default allocation descriptor. + +Entry: + # initialize heap + # . Heap = new-segment(64KB) + # . . push args + 68/push Heap/imm32 + 68/push 0x10000/imm32/64KB + # . . call + e8/call new-segment/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp + + e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'. +$array-equal-main:end: + # syscall(exit, Num-test-failures) + 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx + b8/copy-to-eax 1/imm32/exit + cd/syscall 0x80/imm8 + # Claim the next 'n' bytes of memory starting at ad->curr and update ad->curr. # Abort if there isn't enough memory in 'ad'. allocate: # ad : (address allocation-descriptor), n : int -> address-or-null/eax diff --git a/075array-equal.subx b/075array-equal.subx index 7f5109f9..d6dec878 100644 --- a/075array-equal.subx +++ b/075array-equal.subx @@ -5,24 +5,6 @@ # . op subop mod rm32 base index scale r32 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes -Entry: - # initialize heap - # . Heap = new-segment(64KB) - # . . push args - 68/push Heap/imm32 - 68/push 0x10000/imm32/64KB - # . . call - e8/call new-segment/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - - e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'. -$array-equal-main:end: - # syscall(exit, Num-test-failures) - 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32 # copy *Num-test-failures to ebx - b8/copy-to-eax 1/imm32/exit - cd/syscall 0x80/imm8 - array-equal?: # a : (address array int), b : (address array int) -> eax : boolean # pseudocode: # lena = a->length @@ -618,12 +600,4 @@ test-check-array-equal: 5d/pop-to-ebp c3/return -== data - -Heap: - # curr - 0/imm32 - # limit - 0/imm32 - # . . vim:nowrap:textwidth=0 diff --git a/apps/assort b/apps/assort index 69d3436b..d04fab27 100755 Binary files a/apps/assort and b/apps/assort differ diff --git a/apps/braces b/apps/braces index 67c0f75a..187567e5 100755 Binary files a/apps/braces and b/apps/braces differ diff --git a/apps/calls b/apps/calls index 2ec41b22..863bd993 100755 Binary files a/apps/calls and b/apps/calls differ diff --git a/apps/crenshaw2-1 b/apps/crenshaw2-1 index e8992622..fd28bf3a 100755 Binary files a/apps/crenshaw2-1 and b/apps/crenshaw2-1 differ diff --git a/apps/crenshaw2-1b b/apps/crenshaw2-1b index cddb2555..8c96482d 100755 Binary files a/apps/crenshaw2-1b and b/apps/crenshaw2-1b differ diff --git a/apps/dquotes b/apps/dquotes index ede07c89..108a74bb 100755 Binary files a/apps/dquotes and b/apps/dquotes differ diff --git a/apps/factorial b/apps/factorial index 19f57d7a..0fa9ab2b 100755 Binary files a/apps/factorial and b/apps/factorial differ diff --git a/apps/handle b/apps/handle index 1ac9ea30..1ebf8f81 100755 Binary files a/apps/handle and b/apps/handle differ diff --git a/apps/hex b/apps/hex index f0828df4..c9241871 100755 Binary files a/apps/hex and b/apps/hex differ diff --git a/apps/pack b/apps/pack index 56826bf4..95a306bd 100755 Binary files a/apps/pack and b/apps/pack differ diff --git a/apps/sigils b/apps/sigils index 4a4bebf1..f4f1834d 100755 Binary files a/apps/sigils and b/apps/sigils differ diff --git a/apps/survey b/apps/survey index ec7e318f..6097c5df 100755 Binary files a/apps/survey and b/apps/survey differ diff --git a/apps/tests b/apps/tests index 36ba05ea..8def31f9 100755 Binary files a/apps/tests and b/apps/tests differ -- cgit 1.4.1-2-gfad0