Skip to content

Commit 211c8d5

Browse files
committed
crook
1 parent a4117e6 commit 211c8d5

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

hoax-plus/compile-ops.rkt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,12 @@
230230
(seq (Pop r10)
231231
(Pop r8)
232232
(assert-vector r8)
233-
(assert-integer r10)
234-
(Cmp r10 0)
235-
(Jl 'err)
236-
(Xor r8 type-vect) ; r8 = ptr
237-
(Mov r9 (Mem r8)) ; r9 = len
238-
(Sar r10 int-shift) ; r10 = index
239-
(Sub r9 1)
240-
(Cmp r9 r10)
241-
(Jl 'err)
242-
(Sal r10 3)
243-
(Add r8 r10)
244-
(Mov (Mem r8 8) rax)
233+
(assert-natural r10)
234+
(Mov r9 (Mem r8 (- type-vect)))
235+
(Cmp r10 r9)
236+
(Jge 'err)
237+
(Sar r10 1) ; convert to byte offset
238+
(Mov (Mem r8 r10 (- 8 type-vect)) rax)
245239
(Mov rax (value->bits (void))))]))
246240

247241
(define (type-pred mask type)

iniquity-plus/compile-ops.rkt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,12 @@
218218
(seq (Pop r10)
219219
(Pop r8)
220220
(assert-vector r8)
221-
(assert-integer r10)
222-
(Cmp r10 0)
223-
(Jl 'err)
224-
(Xor r8 type-vect) ; r8 = ptr
225-
(Mov r9 (Mem r8)) ; r9 = len
226-
(Sar r10 int-shift) ; r10 = index
227-
(Sub r9 1)
228-
(Cmp r9 r10)
229-
(Jl 'err)
230-
(Sal r10 3)
231-
(Add r8 r10)
232-
(Mov (Mem r8 8) rax)
221+
(assert-natural r10)
222+
(Mov r9 (Mem r8 (- type-vect)))
223+
(Cmp r10 r9)
224+
(Jge 'err)
225+
(Sar r10 1) ; convert to byte offset
226+
(Mov (Mem r8 r10 (- 8 type-vect)) rax)
233227
(Mov rax (value->bits (void))))]))
234228

235229
(define (type-pred mask type)

knock-plus/compile-ops.rkt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,12 @@
218218
(seq (Pop r10)
219219
(Pop r8)
220220
(assert-vector r8)
221-
(assert-integer r10)
222-
(Cmp r10 0)
223-
(Jl 'err)
224-
(Xor r8 type-vect) ; r8 = ptr
225-
(Mov r9 (Mem r8)) ; r9 = len
226-
(Sar r10 int-shift) ; r10 = index
227-
(Sub r9 1)
228-
(Cmp r9 r10)
229-
(Jl 'err)
230-
(Sal r10 3)
231-
(Add r8 r10)
232-
(Mov (Mem r8 8) rax)
221+
(assert-natural r10)
222+
(Mov r9 (Mem r8 (- type-vect)))
223+
(Cmp r10 r9)
224+
(Jge 'err)
225+
(Sar r10 1) ; convert to byte offset
226+
(Mov (Mem r8 r10 (- 8 type-vect)) rax)
233227
(Mov rax (value->bits (void))))]))
234228

235229
;; OpN Natural -> Asm

0 commit comments

Comments
 (0)