06 May 2016, 22:54 | #1 |
Registered User
Join Date: Apr 2014
Location: Calgary/Canada
Posts: 26
|
Calculate offset using labels
First off let me say I have no idea what I am doing. I'm just starting to figure out 68k assembly. Now that thats out of the way... I'm working on some code that as part of its operation, relocates itself and then continues on using an offset address. This code was originally written for Macro68 but I'm using DevPac 3.
The part where I'm struggling is where the program relocates itself and then jumps to the new address which is calculated as an offset of the new memory block. The code in question looks like: ; a3 is a pointer to the newly allocated block of memory donewithreloc: jmp (newaddress,a3) ;execute from now on from the allocated newaddress:;memory space ;Allocate four 220K chunks of memory for the big buffer moveq #$16,d4When this is assembled in DevPac I get an error "Relative not allowed" at the jmp. So my question is, Is there another way to calculate this offset in DevPac without getting the "Relative not allowed" error? I am pretty sure there must be a way to do this but since I'm not experienced in 68k assembly I have to turn to more knowledgable folk. |
06 May 2016, 23:00 | #2 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
Quote:
|
|
06 May 2016, 23:35 | #3 |
Registered User
Join Date: Apr 2014
Location: Calgary/Canada
Posts: 26
|
The offset will be significantly smaller than 220k, just enough to jump over the initial copy code.
|
06 May 2016, 23:59 | #4 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,958
|
Quote:
lea (RamPtr+FastBoot),a4 |
|
07 May 2016, 01:02 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
It's not surprising that Devpac doesn't like the "jmp (newaddress,a3)".
"newaddress" is a label, so it cannot be used as 16-bit displacement on A3. But I'm not sure if I, or anybody else here, understood what you are trying to do. Am I correct that you want to relocate the code below "newaddress", and you already copied it to a new memory region with its base address stored in A3? Then you only have to jump to this address: "jmp (a3)". : |
08 May 2016, 08:30 | #6 |
Registered User
Join Date: Apr 2014
Location: Calgary/Canada
Posts: 26
|
yes, newaddress is where I want to jump to at a3. The code starting at a3 will have the relocation code. Once that has executed I don't need to execute it again so I want to skip over it.
|
08 May 2016, 10:38 | #7 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
You have to compute the offset with
jmp (start-orig, a3), but I would just do as phx suggested and not move the relocation code at all. |
09 May 2016, 18:56 | #8 |
Registered User
Join Date: Apr 2014
Location: Calgary/Canada
Posts: 26
|
Your suggestion seems to do the trick. I can't believe I didn't think of this myself.
thanks! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
gfxbase negative offset | Asman | Coders. System | 14 | 28 May 2015 23:24 |
Calculate Time-Tracks Pixel width? | AGS | Coders. General | 22 | 10 March 2015 19:19 |
Calculate a color gradient. | AGS | Coders. Asm / Hardware | 13 | 11 February 2015 11:20 |
Program Counter with Offset - why? | Jherek Carnelia | Coders. General | 26 | 21 March 2011 10:49 |
GfxRip Palette and Offset questions | stef80 | project.Sprites | 2 | 06 July 2007 19:59 |
|
|