| |
Marvin Account closed
Registered: Oct 2003 Posts: 8 |
.offs in Tubro Macro Pro
The TMP manual gives the following example of the .offs directive:
* = $2000
start bit base0
bit base
jmp *
base0 * = $8000
base .offs base0-*
lda #>start
jmp *
This works fine if you assemble with ←3. However it fails if you try to assemble to an object file (←5).
What's the best workaround to get code that contains .offs assembled to disk?
The only thing I can think of is to assemble to memory ←3, hit 's' to start the code and then save the memory to disk. |
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
you cant have "holes" (more than one PC assignment) when assembling to disk. you could work around it by putting a loop there that assembles .byte 0 statements until it hits the address you want it to be (but remember you can only skip forwards) |
| |
soci
Registered: Sep 2003 Posts: 480 |
Almost. You can have more than one star assignment, however these must be sorted in increasing order. The reason is it can only insert padding zero bytes if the address doesn't go backwards.
For disk .offs doesn't do much unfortunately padding wise in the C64 implementations I know of, so the result will be wrong.
There's a workaround if you arrange it so that the target address is less than the compile address:
*=$1000
jmp i
.offs $100
*=*-$100 ; following assembled to $1003 with PC $f03
i jmp i
.C:1000 4C 03 0F JMP $0F03
.C:1003 4C 03 0F JMP $0F03
This gives the same result in memory as on disk. |
| |
Marvin Account closed
Registered: Oct 2003 Posts: 8 |
I don't want any padding in the final result, but maybe I'm missing something regarding the implementation?
Arranging the code so that the target address is always less than the compile address would be at least somewhat helpful, but I can't get your example to work. It writes the entire $1000 - $0f05 range to disk.
I've experimented with this before and tried additional */offs statements to get $1000 - $1005, but it doesn't work. I suppose that I only add an additional $100 bytes to the file and breaks something as I'm trying to write more than 64kb. |
| |
soci
Registered: Sep 2003 Posts: 480 |
I've used this one:
Turbo Assembler Macro +++ 20051017 |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
oh forward skipping worked with pc assignment? ok :) one thing i remember is that after assembling to disk a few times i moved to crossassemblers :=) |
| |
Six
Registered: Apr 2002 Posts: 293 |
I was going to point to the online docs, but realized you'd already referenced them. I've had enough trouble getting .offs to work properly that I've often resorted to making multiple files and including them as binaries. |
| |
Count Zero
Registered: Jan 2003 Posts: 1932 |
I think the example is a bad choice.
.offs was mostly used for code that is later copied and executed elsewhere. I used it for drive code mostly.
The PC jump here is the culprit as already explained. |
| |
Marvin Account closed
Registered: Oct 2003 Posts: 8 |
Yes, drive code and other relocatable code is what I'm after. A combination of .offs and PC-changes is the only way to make the assembler handle this for me, right? |