diff --git a/codeGenVirtual/src/prog8/codegen/virtual/CodeGen.kt b/codeGenVirtual/src/prog8/codegen/virtual/CodeGen.kt index eab914cc5..b97faf3fd 100644 --- a/codeGenVirtual/src/prog8/codegen/virtual/CodeGen.kt +++ b/codeGenVirtual/src/prog8/codegen/virtual/CodeGen.kt @@ -279,6 +279,7 @@ class CodeGen(internal val program: PtProgram, code += addConstMem(loopvarDt, loopvarAddress.toUInt(), step) code += VmCodeInstruction(Opcode.LOADM, loopvarDt, reg1 = indexReg, value = loopvarAddress) } else { + // TODO WHY THID DISTINCTION? code += VmCodeInstruction(Opcode.LOADM, loopvarDt, reg1 = indexReg, value = loopvarAddress) code += addConstReg(loopvarDt, indexReg, step) code += VmCodeInstruction(Opcode.STOREM, loopvarDt, reg1 = indexReg, value = loopvarAddress) @@ -318,6 +319,7 @@ class CodeGen(internal val program: PtProgram, code += addConstMem(loopvarDt, loopvarAddress.toUInt(), step) code += VmCodeInstruction(Opcode.LOADM, loopvarDt, reg1 = indexReg, value = loopvarAddress) } else { + // TODO WHY THIS DISTICTION ? code += VmCodeInstruction(Opcode.LOADM, loopvarDt, reg1 = indexReg, value = loopvarAddress) code += addConstReg(loopvarDt, indexReg, step) code += VmCodeInstruction(Opcode.STOREM, loopvarDt, reg1 = indexReg, value = loopvarAddress) @@ -383,13 +385,13 @@ class CodeGen(internal val program: PtProgram, if(value>0) { code += VmCodeInstruction(Opcode.LOADM, dt, reg1=valueReg, value=address.toInt()) code += VmCodeInstruction(Opcode.LOAD, dt, reg1=operandReg, value=value) - code += VmCodeInstruction(Opcode.ADDR, dt, reg1 = valueReg, reg2 = operandReg) + code += VmCodeInstruction(Opcode.ADDR, dt, reg1 = valueReg, reg2 = operandReg) // TODO USE ADDM? code += VmCodeInstruction(Opcode.STOREM, dt, reg1=valueReg, value=address.toInt()) } else { code += VmCodeInstruction(Opcode.LOADM, dt, reg1=valueReg, value=address.toInt()) code += VmCodeInstruction(Opcode.LOAD, dt, reg1=operandReg, value=-value) - code += VmCodeInstruction(Opcode.SUBR, dt, reg1 = valueReg, reg2 = operandReg) + code += VmCodeInstruction(Opcode.SUBR, dt, reg1 = valueReg, reg2 = operandReg) // TODO USE ADDM? code += VmCodeInstruction(Opcode.STOREM, dt, reg1=valueReg, value=address.toInt()) } } diff --git a/compiler/res/prog8lib/conv.p8 b/compiler/res/prog8lib/conv.p8 index a7b74ca4c..2e050a2e5 100644 --- a/compiler/res/prog8lib/conv.p8 +++ b/compiler/res/prog8lib/conv.p8 @@ -416,6 +416,9 @@ _loop beq _stop cmp #7 ; screencode letters A-F are 1-6 bcc _add_letter + and #127 + cmp #97 + bcs _try_iso ; maybe letter is iso:'a'-iso:'f' (97-102) cmp #'g' bcs _stop cmp #'a' @@ -451,6 +454,11 @@ _add_letter sta P8ZP_SCRATCH_B1 pla jmp _calc +_try_iso + cmp #103 + bcs _stop + and #63 + bne _add_letter }} } diff --git a/compiler/res/prog8lib/virtual/conv.p8 b/compiler/res/prog8lib/virtual/conv.p8 index 6518366c8..43b0d7d0c 100644 --- a/compiler/res/prog8lib/virtual/conv.p8 +++ b/compiler/res/prog8lib/virtual/conv.p8 @@ -251,4 +251,13 @@ sub bin2uword(str string) -> uword { } } +sub any2uword(str string) -> uword { + ; -- convert any number string (any prefix allowed) to uword. + when string[0] { + '$' -> return hex2uword(string) + '%' -> return bin2uword(string) + else -> return str2uword(string) + } +} + } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index d904be634..b3c5fd8ba 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,9 +3,10 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- conv.any2uword doesn't accept uppercase hex letters - see if we can let for loops skip the loop if end just 2 special cases in CodeGen. ...