Page 1 of 1
where is org from 68k asm code?
Posted: Sun Feb 13, 2022 3:42 pm
by nitrofurano
i have another noob questiion: is there some asm code around having org (defining where the code will be placed), or are all addresses relative? i'm asking this because i found no 68k asm code yet with org - or am i keeping bad habits from z80? xD
another question: where should we find good ql asm examples for trying out on vasm?
Re: where is org from 68k asm code?
Posted: Sun Feb 13, 2022 4:15 pm
by NormanDunbar
QL code should always be position independent. Some old games expected things to be in certain places, and were written that way. Memory expansions or floppy interfaces bolloxed those programs.
C/Pascal compiled code usually has a startup routine at the front which has a table of all the explicit addresses in the code that follows, and retargets those to be relative to the start of the job in RAM, which need not be the same place in any two or more consecutive executions.
Assembly in the QL comes in three main types:
Jobs: these are EXEC/EXEC_W'd or EX/EW'd or similar depedning on the toolkit you are using. They must be position independent as they will most likely load to a different address each time.
Basic Extensions: Again, should be position independent as they get memory allocated (ALCHP or RESPR), loaded (LBYTES) and called (CALL) to install the extensions. Then the new functions and procedures can be called as S*BASIC commands/functions/procedures.
Callable Code: Again, should be position independent as they get memory allocated (ALCHP or RESPR), loaded (LBYTES) and called (CALL) to execute whatever the code is supposed to do.
VASM/VLINK for the QL are used in the Free Pascal Compiler suite for cross compiling for the QL. I help maintain it. (Some of the QL stuff, not VASM/VLINK) and I'm pretty certain that the code produced by those might have a relocation table at the start, as the FPC compiler output certainly does. Just out of interest, if you were assembling and linking the file ql.asm, which commands for vasm/vlink would you be using?
Cheers,
Norm.
Re: where is org from 68k asm code?
Posted: Sun Feb 13, 2022 4:51 pm
by nitrofurano
interesting, thanks!
i still didn't heart a thing of ql.asm (i'm getting curious now, taking a look what is there..., where from do we find it?) - for now i'm only about to try asm code generated from SecondBasic (cleaning it before compiling), or some very small code for learning 68k asm, without any included library code for now
Re: where is org from 68k asm code?
Posted: Sun Feb 13, 2022 5:14 pm
by NormanDunbar
Sorry, my bad. I meant to type:
if you were assembling a file named ql.asm, what vasm/vlink commands/options would you use?
Cheers,
Norm.
Re: where is org from 68k asm code?
Posted: Tue Apr 12, 2022 1:19 pm
by spkr
nitrofurano wrote:i have another noob questiion: is there some asm code around having org (defining where the code will be placed), or are all addresses relative? i'm asking this because i found no 68k asm code yet with org - or am i keeping bad habits from z80? xD
another question: where should we find good ql asm examples for trying out on vasm?
Hi there. I use org and absolute code myself together with a relocatie to load program and run it. I'm sure there are limitations to the use case, but I think it depends on your aim of your code. I target stock machine specifically it and don't intend to be system friendly; so there you have it.
I use vasm to do my QL code, and I'm happy to share some of it with you. You can use it any kind you wish.