64tass "linker"

You can talk about almost anything that you want to on this board.

Moderator: Moderators

Post Reply
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

64tass "linker"

Post by Oziphantom »

from viewtopic.php?t=23959
the question is
You have me curious now why the 64tass manual says it includes a "linker" with the word "linker" in quotes. :lol:
So 64tass has a linker but its internal. I.e it has the full power of a linker just you don't have to run an external tool to get it.

This is a RAM problem not a ROM problem. But lets say you have a game and you have an IRQ chain, now that IRQ chain has to change depending upon if you are PAL or NTSC. Because they have a different number of lines, and different clocks per line. So you make a NTSC IRQ chain and an PAL IRQ chain. When you load the game or copy from cart to RAM, you want put it into memory at the same spot so the function addresses still line up, and you want to make sure that the gap you leave in the code is big enough to hold the larger of the two. ie. you have

Code: Select all

functions here
<IRQ BLOCK HERE>
more functions here
without a linker you would just have to put in a gap and hope it was big enough. but with 64TASS you can :
put each IRQ into a section. So sPALIRQ and sNTSCIRQ now you code can have

Code: Select all

functions here
.fill size([size(sPALIRQ), size(sNTSCIRQ)]) >? ... ; this will leave the maximum size of the sections
functions here
in that 64tass will assemble the code in both sections first, then it will be able to find the size, work out the maximum size and then leave the right size gap in order to place them in to it. This is basically making each one as a .o file then a linker measures them and then leaves space in the final linked positions it outputs.
you can then also do this on a per function bases so that each part of the IRQ has the same address. Ie.
PALTOP and NTSCTOP have the same address and PALMID and NTSCMID have the same address. Thus all the other code can have a fixed address for the labels and there is enough space to hold all of them, with gaps left as needed.
So it can assemble modules of code, then move and place them in the memory map as a linker does, only its all internal and done as part of the assemble stage. This gives it more power as it can then do partial links, then full assembly passes over the partial links to then generate more linking/assembling. This is why 64Tass is N pass, it will keep assembling and linking and assembling and linking as it needs to until it reaches a completed output file. Typically I run about 5 passes in my code, but the code that needed the example above was 9 passes to build.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: 64tass "linker"

Post by Oziphantom »

it also has sections which you can just send things to and it will collected and output in a pass somewhere.

for example I like to write code like this sometimes

Code: Select all

    ldx #size(TopString)-1
-
    lda TopString,x
        .section Data
        .enc "ingamefont"
        TopString .text "my game name here"
        .send ; Data
    sta kVectors.Screen+20-size(TopString)/2,x
    sta kVectors.Screen2+20-size(TopString)/2,x
    dex
    bpl -
this way the data my function is using and consuming is referenced directly where it is being read, while in the actual PRG file that are in very different addresses. While "linkers" insist you have a section declaration, in 64tass you instance the sections directly in the asm files without a separate config file.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: 64tass "linker"

Post by jeffythedragonslayer »

Interesting. I noticed that 64tass tells you how many passes were involved by default. I don't know any other languages that do that. What value does that bring, know how many passes happened?
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: 64tass "linker"

Post by Oziphantom »

well it gives you an idea of your code complexity. Its also a performance concern each pass takes time. You are thinking in the 3Ghz 64 bit CPU era and well 3 pass vs 9 pass is a fraction of a second you don't notice. But if I'm running the code on an A500 then dropping a pass by rearranging my code is going to be a solid performance boost and worth my time doing, and something I would like to know that I could potentially do.

Its not a language thing, its a this assembler thing. Most tools are fixed pass. C/C++ compiler is single pass(+ pre processor pre pass), Ca65 is 2 pass, 6510+ is 3 pass, Fortran is 2 pass etc there is no point telling you how many passes it has done because it is fixed. But if you look at the output of 6510+ it prints out
PASS 1

PASS 2

PASS 3

and Merlin assembler also does pass 1 and pass2 outputs.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: 64tass "linker"

Post by Pokun »

I guess telling you how many passes it does is normal for a multipass assembler. Asm6 does that too while assembling so you have an idea what it's doing.
Multipass means it does as many passes it needs to resolve all symbols and calculations so there is no need to declare symbols on beforehand like in C/C++ and to some extent in 2-pass assemblers like ca65.
Post Reply