diff options
| author | Drahflow <drahflow@gmx.de> | 2014-12-22 17:06:50 +0100 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2014-12-22 17:06:50 +0100 |
| commit | 2016623c77f7b0b4c0ce9e0724722aafd96282b4 (patch) | |
| tree | 1c28fd4781a109d1556c78060374c71a0a5a4f2e /compiler | |
| parent | d961abf61255429f84b8a6578fe04f2cfedf9395 (diff) | |
Correctly handling negative indices
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/elymasAsmOps.ey | 5 | ||||
| -rw-r--r-- | compiler/elymasGlobal.ey | 49 |
2 files changed, 43 insertions, 11 deletions
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 |
