This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

ASM6 immediates from labels

ASM6 immediates from labels
by on (#78837)
Here is what I want:
Code:
.org $8000
string: .db "ABC"

lda #<string
sta <pointer     ;$00
lda #>string
sta >pointer     ;$01

here's what I get:
Code:
lda $0000
sta $0000
lda $0080
sta $0001

I've tried <#string and #<string and #(<string) and <(#string). Is there any way to get ASM6 to make an immediate from an address?

Also is there any way to force zero-page?

by on (#78838)
Wow, that is really strange. That is the same code I have used with my ASM6 programs and did not have an issue.

My program only did this within a macro. Maybe that has something to do with it?

by on (#78840)
Wat?
This is what I get:

Code:
08000 41 42 43                   string: .db "ABC"
08003
08003 A9 00                      lda #<string
08005 85 00                      sta <pointer     ;$00
08007 A9 80                      lda #>string
08009 85 00                      sta >pointer     ;$01


Also, isn't this what you want? Or am I misunderstanding what you're trying to do?

Code:
lda #<string
sta pointer       ;$00
lda #>string
sta pointer+1     ;$01

by on (#78851)
The only problem I see with your code is "<pointer" and ">pointer", which should be "pointer" ("+0" is optional, but I use it for clarity) and "pointer+1".

by on (#78865)
What's wrong with <pointer and >pointer? Shouldn't it resolve either way when you want zero-page or just to split an address? I could have sworn I've seen this convention.

So it turns out it was <#string that caused:
Code:
$8003:A5 00     LDA $0000 = #$00
$8005:85 00     STA $0000 = #$00
$8007:A5 80     LDA $0080 = #$00
$8009:85 00     STA $0000 = #$00

I guess I didn't check #<string's disassembly afterall, which works.

by on (#78867)
kyuusaku wrote:
What's wrong with <pointer and >pointer?

Your pointer is a variable, variables are just nicknames for addresses. When you use "<" you get the lower byte of the address your variable is a nickname for, and ">" will get you the high byte of that address. If your variable is in ZP, the high byte will always be $00, there's no way it can be anything else.

What's confusing you is probably the fact that your variable is a pointer, so not only your variable is stored at an address, but it also contains an address. In your mind it seemed logical that ">" would allow you to access the high byte of the address it points to, but what you actually get is the high byte of the address where the variable is.

by on (#78879)
Yup you're right Tokumaru, I was expecting the assembler to both return the label's MSB (for lda #<address) and the address of a defined word's MSB (implied address+1), which of course doesn't happen.