Assembly programming

Anything QL Software or Programming Related.
Post Reply
ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Assembly programming

Post by ecdhe »

Hello,

Are there some examples of assembly programming for the QL? In particular when the program is written and assembled on a host machine and running in an emulator. I am knowledgeable enough in 6800x programming, it's everything else I'm missing, e.g.
  • A skeleton "Hello world" program for the QL (any things to setup in particular? Where is the program loaded in memory)
  • Once the program is assembled on the host machine, how to copy the binary on a microdrive file
  • How to execute the file in an emulator
  • How to wait for the vertical blank
Cheers


User avatar
tofro
Font of All Knowledge
Posts: 3133
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Assembly programming

Post by tofro »

ecdhe wrote: Sat Jun 21, 2025 4:47 pm Hello,

Are there some examples of assembly programming for the QL? In particular when the program is written and assembled on a host machine and running in an emulator. I am knowledgeable enough in 6800x programming, it's everything else I'm missing, e.g.
  • A skeleton "Hello world" program for the QL (any things to setup in particular? Where is the program loaded in memory)
A QL program needs to be prepared to be loaded anywhere in memory - That means it needs to be written using PC-relative addressing only (or must contain a self-relocating loader).
Norman's QL assembly books linked above by Andrew should contain a number of simple programs to start from.
ecdhe wrote: Sat Jun 21, 2025 4:47 pm
[*]Once the program is assembled on the host machine, how to copy the binary on a microdrive file
That's a tricky one. Transferring to a BBQL is best done using floppies or SD card solutions. There are a number available. Without additional hardware, there's still the serial port or the QL network and a QLUB adapter (search the forum for that)
ecdhe wrote: Sat Jun 21, 2025 4:47 pm
[*]How to execute the file in an emulator
I would recommend to build assembly programs natively (i.e. not cross-assemble) - That makes things a lot easier. Use an emulator like QPC2, you can still use a Windows IDE to edit, QPC2 can access Windows or Linux native file systems. Then you can simply run the program there.
ecdhe wrote: Sat Jun 21, 2025 4:47 pm
[*]How to wait for the vertical blank
Diving right in, don't you?
The simplest way to do that would be to

Code: Select all

	trap #0 ; go into supervisor mode
	stop #$0700 ; wait for an interrupt, then back to user mode
On an unexpanded QL, the 50Hz (or VBL) interrupt is the only one that can occur. (obviously only works on an unexpanded QL with no additional interrupt sources and needs to be packed into a tight loop)
[/list]


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Re: Assembly programming

Post by ecdhe »

Thank you all for the tips, I was able to get started.

And I prefer writing and assembling the program on the host machine. I have very bad memory of writing assembly on the actual machine.


spkr
Brittle Membrane
Posts: 111
Joined: Tue May 04, 2021 6:52 pm

Re: Assembly programming

Post by spkr »

All is adressed at: https://github.com/spkrsmfx/qlsys

If you have any questions let me know.


Post Reply