fix wrong branch instructions for some if_xxx

This commit is contained in:
Irmen de Jong 2020-12-08 21:29:40 +01:00
parent 8a504f8eee
commit 63332c0530
2 changed files with 16 additions and 17 deletions

View File

@ -814,12 +814,12 @@ internal class AsmGen(private val program: Program,
when (condition) {
BranchCondition.CS -> "bcc"
BranchCondition.CC -> "bcs"
BranchCondition.EQ, BranchCondition.Z -> "beq"
BranchCondition.NE, BranchCondition.NZ -> "bne"
BranchCondition.EQ, BranchCondition.Z -> "bne"
BranchCondition.NE, BranchCondition.NZ -> "beq"
BranchCondition.VS -> "bvc"
BranchCondition.VC -> "bvs"
BranchCondition.MI, BranchCondition.NEG -> "bmi"
BranchCondition.PL, BranchCondition.POS -> "bpl"
BranchCondition.MI, BranchCondition.NEG -> "bpl"
BranchCondition.PL, BranchCondition.POS -> "bmi"
}
} else {
when (condition) {
@ -1071,7 +1071,7 @@ $counterVar .byte 0""")
val jump = stmt.truepart.statements.first() as? Jump
if(jump!=null) {
// branch with only a jump
// branch with only a jump (goto)
val instruction = branchInstruction(stmt.condition, false)
out(" $instruction ${getJumpTarget(jump)}")
translate(stmt.elsepart)

View File

@ -8,6 +8,16 @@
errors {
sub tofix() {
repeat {
ubyte char3 = c64.CHRIN()
if_z
goto labeltje
if_z
break ; TODO wrong jump asm generated, works fine if you use a label instead to jump to
}
labeltje:
while c64.CHRIN() {
; TODO: the loop condition isn't properly tested because a ldx is in the way before the beq
}
@ -18,12 +28,6 @@ errors {
break
}
repeat {
ubyte char3 = c64.CHRIN()
if_z
break ; TODO wrong jump asm generated, works fine if you use a label instead to jump to
}
; TODO fix undefined symbol:
repeat {
ubyte char = c64.CHRIN()
@ -40,12 +44,7 @@ errors {
main {
sub start() {
function(&start)
errors.tofix()
test_stack.test()
}
sub function(uword param) {
txt.print_uwhex(param, 1)
param++
}
}