vhelin / wla-dx

WLA DX - Yet Another GB-Z80/Z80/Z80N/6502/65C02/65CE02/65816/68000/6800/6801/6809/8008/8080/HUC6280/SPC-700/SuperFX Multi Platform Cross Assembler Package
Other
549 stars 98 forks source link

16-bit Inference Observation #107

Open bazz1tv opened 8 years ago

bazz1tv commented 8 years ago

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 commented 8 years ago

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

nicklausw commented 8 years ago

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

bazz1tv commented 8 years ago

OK, and why does lda #label work?

On Sat, Apr 30, 2016 at 11:25 AM, nicklausw notifications@github.com 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

nicklausw commented 8 years ago

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

nicklausw commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

bazz1tv commented 8 years ago

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

Actually, that's the right opcode.

bazz1tv commented 8 years ago

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.

nicklausw commented 8 years ago

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.

bazz1tv commented 8 years ago

Sounds right. That's much clearer