Page 2 of 3

Re: Offsets

Posted: Sun Nov 09, 2014 10:29 pm
by ajordison
Let's all kiss and make up eh?

Right then, so now we're back on track what's the best way to control the offset directive? Could it be something as simple as using 'offs <value>' to set it and then 'offs' without a value to cancel it? Sounds too easy to me...

Re: Offsets

Posted: Mon Nov 10, 2014 1:28 am
by dudz
yes, that was my whole point. use directives, and dont tie it to a scope (like kickassembler does) - because that creates the problems that kickassembler does have =P

Re: Offsets

Posted: Mon Nov 10, 2014 2:37 pm
by ajordison
A couple more questions:

1) Does the offset only apply to 16 bit addresses, or could you apply it to zero page too?

2) Does the 65816 us offsets in the same way?

Re: Offsets

Posted: Mon Nov 10, 2014 3:35 pm
by dudz
Does the offset only apply to 16 bit addresses, or could you apply it to zero page too?
it should be applied to all addresses that are located between the .offs and .endoffs (or whatever you call it) directives
Does the 65816 us offsets in the same way?
that technique can be used in any architecture, so yes, sure

Re: Offsets

Posted: Mon Nov 10, 2014 3:50 pm
by ajordison
How can offsets be applied to zero page? For example if I've set a 1000 byte offset and then assemble some zero page code, I would end up with a 16 bit address which would change the addressing mode. Or should I just guard against this and return an error of the address is too large for the instruction's address mode?

Re: Offsets

Posted: Mon Nov 10, 2014 6:30 pm
by dudz
first off all, dont think "offset" but "program counter base" - which is what it really is. look at this:

Code: Select all

* = $1000 ; place code at $1000
.org $02 ; assemble as if it is placed at $02
lda tab ; assembles lda zp
tab: .byte 0
.reloc
basically in your assemble you need to have two address pointers, one that is (only) used for placing the code in memory, and another that is used as the program counter when generating ml code.

Re: Offsets

Posted: Mon Nov 10, 2014 11:26 pm
by ajordison
dudz wrote:basically in your assemble you need to have two address pointers, one that is (only) used for placing the code in memory, and another that is used as the program counter when generating ml code.
Yes, but what if the code is like this:

Code: Select all

* = $1000 ; place code at $1000
.org $2000 ; assemble as if it is placed at $2000
lda tab ; assembles lda zp
tab: .byte 0
.reloc
'tab' isn't in page zero now, or am I missing something here?

Re: Offsets

Posted: Tue Nov 11, 2014 1:12 am
by Prime
ajordison wrote:
dudz wrote:basically in your assemble you need to have two address pointers, one that is (only) used for placing the code in memory, and another that is used as the program counter when generating ml code.
Yes, but what if the code is like this:

Code: Select all

* = $1000 ; place code at $1000
.org $2000 ; assemble as if it is placed at $2000
lda tab ; assembles lda zp
tab: .byte 0
.reloc
'tab' isn't in page zero now, or am I missing something here?
You've answered your own question there Arthur.

Re: Offsets

Posted: Tue Nov 11, 2014 9:30 am
by ajordison
My mistake. :oops: The code was supposed to be:

Code: Select all

* = $02 ; place code at $02
.org $2000 ; assemble as if it is placed at $2000
lda tab ; assembles lda zp
tab: .byte 0
.reloc
So like I said, 'tab' is effectively at $2002 now so how could this work?

Re: Offsets

Posted: Tue Nov 11, 2014 12:32 pm
by satpro
AJ,
For a decent explanation of how all this works (instead of getting your info here in small pieces) you might want to take a look at Soci's 64Tass assembler docs (and source). The assembler has actually been around long before Soci took it over. It's written in C and covers everything you're asking about. We're getting into multiple concepts here, too, and not just offset coding. The zero page data sounds more like a thing called a section in 64Tass.

I sat here last night trying to answer your question about the zp data, and I kept turning my answer into spaghetti. That's when I realized it's an answer too long for a forum post. If you need help finding any of that stuff, give me a jingle.