Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16-bit Inference Observation #107

Open
bazz1tv opened this issue Apr 25, 2016 · 11 comments
Open

16-bit Inference Observation #107

bazz1tv opened this issue Apr 25, 2016 · 11 comments

Comments

@bazz1tv
Copy link

@bazz1tv bazz1tv commented Apr 25, 2016

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
Copy link
Author

@bazz1tv bazz1tv commented Apr 30, 2016

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

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented Apr 30, 2016

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

Loading

@bazz1tv
Copy link
Author

@bazz1tv bazz1tv commented Apr 30, 2016

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
#107 (comment)


Michael Bazzinotti
​Technologist & Musician​

http://www.bazz1.com

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

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented Apr 30, 2016

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

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented May 1, 2016

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.

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented May 1, 2016

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.

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented May 1, 2016

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

Loading

@bazz1tv
Copy link
Author

@bazz1tv bazz1tv commented May 2, 2016

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

Actually, that's the right opcode.

Loading

@bazz1tv
Copy link
Author

@bazz1tv bazz1tv commented May 2, 2016

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.

Loading

@nicklausw
Copy link
Contributor

@nicklausw nicklausw commented May 2, 2016

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.

Loading

@bazz1tv
Copy link
Author

@bazz1tv bazz1tv commented May 2, 2016

Sounds right. That's much clearer

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants