Offsets

JMP $FCE2
ajordison
Developer
Developer
Posts: 59
Joined: Wed Apr 16, 2014 1:28 pm
Location: Hartlepool, UK
Contact:

Re: Offsets

Post by ajordison » Sun Nov 09, 2014 10:29 pm

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...


Try out CBM prg Studio for all your Commodore development needs!
Stay a while...stay for erm quite a while!

dudz
Member
Member
Posts: 140
Joined: Tue Jun 17, 2014 5:40 am

Re: Offsets

Post by dudz » Mon Nov 10, 2014 1:28 am

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

ajordison
Developer
Developer
Posts: 59
Joined: Wed Apr 16, 2014 1:28 pm
Location: Hartlepool, UK
Contact:

Re: Offsets

Post by ajordison » Mon Nov 10, 2014 2:37 pm

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?
Try out CBM prg Studio for all your Commodore development needs!
Stay a while...stay for erm quite a while!

dudz
Member
Member
Posts: 140
Joined: Tue Jun 17, 2014 5:40 am

Re: Offsets

Post by dudz » Mon Nov 10, 2014 3:35 pm

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

ajordison
Developer
Developer
Posts: 59
Joined: Wed Apr 16, 2014 1:28 pm
Location: Hartlepool, UK
Contact:

Re: Offsets

Post by ajordison » Mon Nov 10, 2014 3:50 pm

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?
Try out CBM prg Studio for all your Commodore development needs!
Stay a while...stay for erm quite a while!

dudz
Member
Member
Posts: 140
Joined: Tue Jun 17, 2014 5:40 am

Re: Offsets

Post by dudz » Mon Nov 10, 2014 6:30 pm

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.

ajordison
Developer
Developer
Posts: 59
Joined: Wed Apr 16, 2014 1:28 pm
Location: Hartlepool, UK
Contact:

Re: Offsets

Post by ajordison » Mon Nov 10, 2014 11:26 pm

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?
Try out CBM prg Studio for all your Commodore development needs!
Stay a while...stay for erm quite a while!

Prime

Re: Offsets

Post by Prime » Tue Nov 11, 2014 1:12 am

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.

ajordison
Developer
Developer
Posts: 59
Joined: Wed Apr 16, 2014 1:28 pm
Location: Hartlepool, UK
Contact:

Re: Offsets

Post by ajordison » Tue Nov 11, 2014 9:30 am

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?
Try out CBM prg Studio for all your Commodore development needs!
Stay a while...stay for erm quite a while!

satpro

Re: Offsets

Post by satpro » Tue Nov 11, 2014 12:32 pm

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.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 1 guest