fachat / xa65

6502/65816 cross assembler
http://www.floodgap.com/retrotech/xa/
55 stars 8 forks source link

Immediate mode 65816, 16-bit value generates overflow error #12

Closed anoxic83 closed 1 year ago

anoxic83 commented 1 year ago

xa -w test.asm ldx #$5654 test.asm:line 6: 0006:Overflow error Break after 1 errors

documentation of WDC65C816 (https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf): 3.5.18 Immediate-# With Immediate (#) addressing the operand is the second byte (second and third bytes when in the 16-bit mode) of the instruction.

classilla commented 1 year ago

The X register is still in 8-bit mode. 16-bit registers aren't assumed by default in 65816 mode. You need .xl to tell the assembler that X is now 16-bit (make sure you have whatever processor flags set correctly beforehand).

.xl
ldx #$5654
xa-2.3.14/% xa -w test.xa
xa-2.3.14/% xd a.o65
0000000    ?   T   V
          a2  54  56
0000003
classilla commented 1 year ago

(See this and other related pseudo-ops: http://www.floodgap.com/retrotech/xa/xa.1.html )