A noob's guide to QL machine code

Anything QL Software or Programming Related.
User avatar
RalfR
QL Wafer Drive
Posts: 1163
Joined: Fri Jun 15, 2018 8:58 pm

Re: A noob's guide to QL machine code

Post by RalfR »

Thank you Dilwyn. This is useful, as I like to keep EXEC programs always in their native format.


7000 4E75
User avatar
bwinkel67
QL Wafer Drive
Posts: 1500
Joined: Thu Oct 03, 2019 2:09 am

Re: A noob's guide to QL machine code

Post by bwinkel67 »

I use Q-emuLator on a classic 68K/PPC Mac (i.e. pre-2000s). On those, the QL file header information is kept in the resource fork QFHD and seems to only be 10 bytes in length. With the move to Unix BSD, I don't think file is split into two parts anymore so I don't know how its stored on a modern Mac.


User avatar
M68008
Gold Card
Posts: 264
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: A noob's guide to QL machine code

Post by M68008 »

Derek_Stewart wrote: Tue Dec 31, 2024 9:03 am I think I will personally adopt the XTcc trailer method for storing executables programmes on non-QL filesystem.
I thought that XTcc was only used by cross-compilers, but not sure.

Q-emuLator doesn't currently understand XTcc. While it could, it is already inspecting the start of files and also looking at the end of each would not be ideal.
The Q-emuLator header (also supported by QPC and other tools) can store some additional metadata. It's rarely used, but for example Eye-Q stores some extra header information when saving images.


User avatar
M68008
Gold Card
Posts: 264
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: A noob's guide to QL machine code

Post by M68008 »

bwinkel67 wrote: Fri Jan 03, 2025 8:18 pm I use Q-emuLator on a classic 68K/PPC Mac (i.e. pre-2000s). On those, the QL file header information is kept in the resource fork QFHD and seems to only be 10 bytes in length. With the move to Unix BSD, I don't think file is split into two parts anymore so I don't know how its stored on a modern Mac.
The OS X version uses the same header mechanism as the Windows version. There was also a last 68K update that can read both the resource fork and the modern in-file header.


User avatar
M68008
Gold Card
Posts: 264
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: A noob's guide to QL machine code

Post by M68008 »

dilwyn wrote: Fri Jan 03, 2025 3:12 pm Taking things a little step further, here's a short SuperBASIC program to remove the native file format header from QemuLator files (and probably other emulator native files which use this format, but that's untested).
Thank you Dilwyn. To avoid confusion (or rather to add to it?? :) ), I'd like to comment that this should not be needed in normal use as tools should automatically remove extra headers when appropriate.

There are two types of file systems, QDOS-aware ones (e.g. WIN containers, MDV images, QDOS floppy disks, QDOS ZIP files) and non-QDOS-aware (e.g. PC file system).
The rules to avoid issues are very simple:
1) If a tool or emulator is used to move a file from QDOS-aware to non-QDOS-aware, then the same program should be used to go in the other direction.
2) Only access QDOS zip files by running the QDOS zip/unzip programs on a QSOS-compatible OS, both when expanding them and creating them. This is the main one that trips up people new to the QL, especially as they may not be aware that there is a separate version, where to find it and how to use it.

If these guidelines are not followed and a file ends with a wrong extra header, Q-emuLator includes utilities to fix the files from a QDOS system. However, it may be a chicken and egg problem, as those programs are executables that need to be transferred in the correct way, so a SuperBASIC version is useful! (Q-emuLator never creates a file header for SuperBASIC source code, text files and any other files that don't need to store extra QDOS metadata like the executable dataspace size.)


User avatar
XorA
Site Admin
Posts: 1596
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: A noob's guide to QL machine code

Post by XorA »

2) Only access QDOS zip files by running the QDOS zip/unzip programs on a QSOS-compatible OS, both when expanding them and creating them. This is the main one that trips up people new to the QL, especially as they may not be aware that there is a separate version, where to find it and how to use it.
I wrote https://github.com/xxoraa/qem-unzip to address this point! It adds Q-Emulator headers to files based on info in the zip!


User avatar
M68008
Gold Card
Posts: 264
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: A noob's guide to QL machine code

Post by M68008 »

XorA wrote: Sat Jan 11, 2025 11:39 pm
2) Only access QDOS zip files by running the QDOS zip/unzip programs on a QSOS-compatible OS, both when expanding them and creating them. This is the main one that trips up people new to the QL, especially as they may not be aware that there is a separate version, where to find it and how to use it.
I wrote https://github.com/xxoraa/qem-unzip to address this point! It adds Q-Emulator headers to files based on info in the zip!
Nice! I didn't know about it.


Derek_Stewart
Font of All Knowledge
Posts: 4634
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: A noob's guide to QL machine code

Post by Derek_Stewart »

In the other message thread concerning the Qliberator self modifying code, I have been trying to understand what is, modifying code and how to write it.

Is there any Assembley language tutorials with regards to this?


Regards,

Derek
User avatar
pjw
QL Wafer Drive
Posts: 1601
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A noob's guide to QL machine code

Post by pjw »

Derek_Stewart wrote: Wed Jan 15, 2025 6:15 pm In the other message thread concerning the Qliberator self modifying code, I have been trying to understand what is, modifying code and how to write it.
<>
I once had the problem of running out of spare registers so rather than doing what youre supposed to, ie:

Code: Select all

        move.w  ut.cstr,a2
        jsr     a2
I came up with this naughty trick:

Code: Select all

init
        lea.l   str_comp,a2         ;hard-wire in some vectors
        move.w  ut.cstr,2(a2)
        ..
        ..

str_comp
        jsr     0
Thats an example of self-modifying code.

Since this only happened during the intialisation of the toolkit the code
was still re-entrant, because however many times the code would be
initialised the result would be the same. However, it would not be ROMable,
because you cant change code in ROM (without re-proramming the chip).


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
Derek_Stewart
Font of All Knowledge
Posts: 4634
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: A noob's guide to QL machine code

Post by Derek_Stewart »

Does this work for other vectors?

e.g. opw.con or mem.achp


Regards,

Derek
Post Reply