aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--compiler/elymasAsmOps.ey5
-rw-r--r--compiler/elymasGlobal.ey49
3 files changed, 43 insertions, 14 deletions
diff --git a/TODO b/TODO
index 5f05810..d92febf 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,3 @@
-* abstract data types (trees)
-* negative array index access (also fix lists) (maybe introduce imod?)
- * afterwards fix the 'l len 1 sub' into '1 neg' in tree.ey again
* lt/gt/le/ge on strings
* hashed nametables
* utf8
diff --git a/compiler/elymasAsmOps.ey b/compiler/elymasAsmOps.ey
index d74cc33..64b80f2 100644
--- a/compiler/elymasAsmOps.ey
+++ b/compiler/elymasAsmOps.ey
@@ -534,6 +534,11 @@ memoryAddressingVariants keys { ==variant memoryAddressingVariants variant . =*p
} each
{
+ 1 /none /none /none rex
+ %99
+} /cqo deff
+
+{
%FC
} /cld deff
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index bf34103..a43cd12 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -467,7 +467,13 @@
:ud2
@nonEmpty
- /rcx :divqReg
+ :cqo
+ /rcx :idivqReg
+ 0 /rdx :cmpqImm8Reg
+ /positiveArrayIndex :jgeLbl8
+
+ /rcx /rdx :addqRegReg
+ @positiveArrayIndex
# rsi == array object on heap
# rdx == correct array index
@@ -583,7 +589,13 @@
:ud2
@nonEmptyString
- /rcx :divqReg
+ :cqo
+ /rcx :idivqReg
+ 0 /rdx :cmpqImm8Reg
+ /positiveStringIndex :jgeLbl8
+
+ /rcx /rdx :addqRegReg
+ @positiveStringIndex
# rsi == array object on heap
# rdx == correct string index
@@ -738,10 +750,14 @@
3 /rcx :shrqImm8Reg # divide by object pointer size
/rcx :decqReg # rcx == number of elements in array
- /rdx /rdx :xorqRegReg
-
# TODO: think about skipping this if index fits
- /rcx :divqReg
+ :cqo
+ /rcx :idivqReg
+ 0 /rdx :cmpqImm8Reg
+ /positiveArrayIndex :jgeLbl8
+
+ /rcx /rdx :addqRegReg
+ @positiveArrayIndex
# rbx == array object on heap
# rdx == correct array index
@@ -757,8 +773,13 @@
/rax ::unboxInteger
16 /rbx /rcx :movqMemDisp8Reg # load string length
- /rdx /rdx :xorqRegReg
- /rcx :divqReg
+ :cqo
+ /rcx :idivqReg
+ 0 /rdx :cmpqImm8Reg
+ /positiveStringIndex :jgeLbl8
+
+ /rcx /rdx :addqRegReg
+ @positiveStringIndex
# rbx == string object on heap
# rdx == correct string offset
@@ -3349,13 +3370,19 @@
] [
:fmulp
] 0 makeFullArith /eymul defv
- [
+ [[
/rax :pushqReg
/rdx /rax :movqRegReg
- /rdx /rdx :xorqRegReg
- /rcx :divqReg
+ :cqo
+ /rcx :idivqReg
+ 0 /rdx :cmpqImm8Reg
+ /positive :jgeLbl8
+
+ /rcx /rdx :addqRegReg
+ @positive
+
/rax :popqReg
- ] [[ "mod" floatUnsupported ]] 0 makeFullArith /eymod defv
+ ]] [[ "mod" floatUnsupported ]] 0 makeFullArith /eymod defv
[
/rax :pushqReg
/rdx /rax :movqRegReg