TRSE
TRSE copied to clipboard
Target 65816 STY with improper bit-width
I have this line of code which is part of a case.. of
block:
100: if (Players[0].direction=23) then Players[0].direction:=0
else inc(Players[0].direction); // "d" turn right
Which produces this assembly code:
lda #$64
cmp tb ;keep
bne TestCar_casenext309
; LineNumber: 945
; Binary clause INTEGER: EQUALS
; Load Integer array
sep #$10 ; disable X/Y 16-bit
ldx #0 ; watch for bug, Integer array has max index of 128
lda Players_Player_Type_Player_Type_direction,x
ldy Players_Player_Type_Player_Type_direction+1,x
rep #$10 ; enable X/Y 16-bit
sta TestCar_rightvarInteger_var318
sty TestCar_rightvarInteger_var318+1 ;**** LOOK HERE ****
; Compare INTEGER with pure num / var optimization. GREATER.
lda TestCar_rightvarInteger_var318+1 ; compare high bytes
cmp #$00 ;keep
bne TestCar_elseblock313
lda TestCar_rightvarInteger_var318
cmp #$17 ;keep
bne TestCar_elseblock313
jmp TestCar_ConditionalTrueBlock312
On the line that says **** LOOK HERE ****
the STY will write a 16-bit value into TestCar_rightvarInteger_var318+1
. It needs a SEP #$10 to change the index register to 8-bit and then followup with a REP #$10 to change it back to 16-bit. Otherwise the address after TestCar_rightvarInteger_var318+1 will be corrupted.
could you provide some more info here? When I'm testing this, the temp value is a zero page address and you get the correct "sep #$10", so I am unable to reproduce this..
ok should be fixed, but having some trouble with building a new release. If you see a new release, please download and verify!