wla-dx icon indicating copy to clipboard operation
wla-dx copied to clipboard

16-bit Inference Observation

Open bazz1tv opened this issue 8 years ago • 11 comments

copy the bug_exhibition/65816/template_project directory and use the following code snippet as your main.s, then simply use make

Please read the headline blurb below


;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
; 65816 bug exhibition -- 16-bit Inference Observation
;
; This demonstrates that WLA-DX can already infer labels as 16-bit naturally,
; by the immediate addressing mode, and via JMP.
; However, not for the absolute addressing mode. What gives?
;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

.MEMORYMAP
DEFAULTSLOT 0
SLOTSIZE $2000
SLOT 0 $0000
SLOT 1 $2000
SLOT 2 $4000
SLOT 3 $6000
SLOT 4 $8000
.ENDME

.ROMBANKMAP
BANKSTOTAL 1
BANKSIZE $2000
BANKS 1
.ENDRO

;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
; main
;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

.DEF INFER

.bank 0 slot 4
.org 0
.section "derpface"

label:
  rep #$20
  lda #label    ; correctly inferred
.IFNDEF INFER
.16bit
.ENDIF
  lda label     ; "FIX_REFERENCES: Value ($8000) of "label" is too much to be a 8bit value."
  jmp label     ; correctly inferrred

.ends

bazz1tv avatar Apr 25 '16 00:04 bazz1tv

so tell me, why can we do jmp label but not lda label ?

bazz1tv avatar Apr 30 '16 08:04 bazz1tv

There is no 8-bit jmp, so 16-bit becomes the default.

nicklausw avatar Apr 30 '16 15:04 nicklausw

OK, and why does lda #label work?

On Sat, Apr 30, 2016 at 11:25 AM, nicklausw [email protected] wrote:

There is no 8-bit jmp, so 16-bit becomes the default.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/vhelin/wla-dx/issues/107#issuecomment-215973126


Michael Bazzinotti ​Technologist & Musician​ ​ http://www.bazz1.com

[image: Attleboro-low rez] http://locations.schoolofrock.com/attleboro http://locations.schoolofrock.com/attleboro

bazz1tv avatar Apr 30 '16 16:04 bazz1tv

Not sure. Will try to find out next time I'm at a computer.

nicklausw avatar Apr 30 '16 21:04 nicklausw

https://github.com/vhelin/wla-dx/blob/master/opcodes_65816.c Odd...there is no lda #16-bit-value. There is, however, a lda 16-bit-value. Your example, when linked, uses 0xA9 for lda #label which is not the right opcode. I think it has to do with opcode typing; the linker thinks that with absolute addressing, the 8-bit kind is just the universal kind. With immediate addressing, however, it knows that there is a 16-bit version to be used.

I need to investigate how opcode types are carried into the linker, if at all. They might just be used by the assembler.

nicklausw avatar May 01 '16 20:05 nicklausw

Well wait, WLA appears to pick up on opcode size on its own. That's probably why the absolute addressing makes no error, it knows to be 16-bit.

nicklausw avatar May 01 '16 20:05 nicklausw

...And apparently WLA doesn't use the wrong opcode for absolute addressing, either. I'm stupid.

nicklausw avatar May 01 '16 20:05 nicklausw

Your example, when linked, uses 0xA9 for lda #label which is not the right opcode.

Actually, that's the right opcode.

bazz1tv avatar May 02 '16 00:05 bazz1tv

Everybody, the point of the conversation is deduct why immediate addressing of a label without hinting works fine for 16-bit, but not absolute addressing (and likely the other non-immediate addressing modes as well), and to see if this ability can be transversed into the other addressing modes.

bazz1tv avatar May 02 '16 00:05 bazz1tv

As I said, opcode size tracking. WLA knows that a is 16-bit, so lda #label works because it assumes label is 16-bit. However, lda label could be anything.

nicklausw avatar May 02 '16 01:05 nicklausw

Sounds right. That's much clearer

bazz1tv avatar May 02 '16 03:05 bazz1tv