QMAC Assembler

Anything QL Software or Programming Related.
Post Reply
Martin_Head
Aurora
Posts: 854
Joined: Tue Dec 17, 2013 1:17 pm

QMAC Assembler

Post by Martin_Head »

I was trying to do something in QMAC, but I could not get it to work. I don't know if I am just doing something wrong, or if it's just not possible.

I want to assemble a program to create a ROM image. So it needs to be 16384 bytes long .

What I was trying to do, was to have a DS.B instruction at the end of the program to automatically pad out the assembly file to 16384 bytes.

I tried things like

Code: Select all

label ds.b 16384-label
and

Code: Select all

label equ *
      ds.b  16384-label
But whatever I tried, It would not assemble without error.


User avatar
Pr0f
QL Wafer Drive
Posts: 1308
Joined: Thu Oct 12, 2017 9:54 am

Re: QMAC Assembler

Post by Pr0f »

I've seen similar fill's in the Minerva source - not sure if that helps at all - at work so I don't have access to any notes / info to assist further.


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

Re: QMAC Assembler

Post by tofro »

Martin_Head wrote: Tue Nov 07, 2023 10:42 am I tried things like

Code: Select all

label ds.b 16384-label
and

Code: Select all

label equ *
      ds.b  16384-label
But whatever I tried, It would not assemble without error.
You are actually trying to get a reloctable program into the format of an absolute one. You may be better off starting a program targetted to ROM with an

Code: Select all

ORG 0
and end it with an

Code: Select all

ORG 16383
DC.b 0
and the linker will fill the space automatically. I have found that RORG works best for me, however (see below).

If you absolutely don't want to use the ORG directive, maybe something like

Code: Select all

          SECTION   code
          OFFSET 32767
codeend:  DS.B      0
might do the trick (OFFSET forces the next label to be at exactly that position in the relocatable section). The problem is that OFFSET doesn't allow you anything but allocation of space, so this might only work in data sections.

If that doesn't work, simply use the RORG directive to place a label at an exact offset to the beginning of a SECTION (I have found that works best for me):

Code: Select all

        RORG 32767
        dc.b 0


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QMAC Assembler

Post by Derek_Stewart »

Martin_Head wrote: Tue Nov 07, 2023 10:42 am I was trying to do something in QMAC, but I could not get it to work. I don't know if I am just doing something wrong, or if it's just not possible.

I want to assemble a program to create a ROM image. So it needs to be 16384 bytes long .

What I was trying to do, was to have a DS.B instruction at the end of the program to automatically pad out the assembly file to 16384 bytes.

I tried things like

Code: Select all

label ds.b 16384-label
and

Code: Select all

label equ *
      ds.b  16384-label
But whatever I tried, It would not assemble without error.
Hi Martin,

What is the error message?


Regards,

Derek
User avatar
Mark Swift
ROM Dongle
Posts: 31
Joined: Fri Jul 18, 2014 9:13 am
Location: Blackpool, Lancs, UK
Contact:

Re: QMAC Assembler

Post by Mark Swift »

Hi Martin,

I've not checked the syntax, but I usually do something like this to pad to the nearest 16K...

Code: Select all

BASE:
	DC.B	'Put your code here',$A,$0

PAD16K:
	DCB.W ((0-(PAD16K-BASE))&$3FFF)/2,$4E71


Martin_Head
Aurora
Posts: 854
Joined: Tue Dec 17, 2013 1:17 pm

Re: QMAC Assembler

Post by Martin_Head »

Thanks for the response's
Derek_Stewart wrote: Tue Nov 07, 2023 5:42 pm Hi Martin,

What is the error message?
I can't remember exactly offhand. But I think it's something to do with relocatable objects.

I'm still fairly new to using QMAC (I'm used to the Talent/Quanta Assembler Workbench). I have not delved into things like linking or macros. I just assemble with the -NOLINK option.

The QMAC manual's not too helpful, if you don't know what you are doing in the first place.

Now I know it can be done, I will have a further play with the suggestions made. I think Mark Swifts solution looks like a good bet. I take it, that it just pads out with NOP's.


Martin_Head
Aurora
Posts: 854
Joined: Tue Dec 17, 2013 1:17 pm

Re: QMAC Assembler

Post by Martin_Head »

I tried Mark's solution and it works fine.

I wondered why the calculation looked so complicated. So I tried to simplify it, but I got the errors back on trying to assemble it

Code: Select all

5016                          
5017 00 000022F4 31820000     cg_pat2a move.w   d2,(a0,d0.w)                  ;set instruction
5018                          
5019                          
5020                          
5021 00 000022F8 7000         cg_exit2 moveq    #$00,d0                       ;exit with no error
5022 00 000022FA 4E75                  rts
5023                          
5024                          
5025                          ; **************************************************
5026                          ; Uncomment the following when creating a ROM image
5027                          
5028                          ;prog_end dcb.w    ((0-(prog_end-start))&$3fff)/2,$4e71
5029                          
5030 00 000022FC              prog_end dcb.w    (16384-prog_end)/2,$4e71
                                                                |
****** ERROR 14 -- line 5030 -    0 - relocatable value not allowed here
5031                          ; **************************************************
5032                          
5033                                   
5034                                   end
****** TOTAL ERRORS    1 (line 5030)
**** TOTAL WARNINGS    0 (line    0)
       memory usage   71 kbytes
Both calculations give the same result - $1D04. I don't know what the first calculation doe's that's different. Unless the 16384 looks like some kind of forward reference.


Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: QMAC Assembler

Post by Silvester »

Isn't it because prog_end-start can be resolved immediately as an absolute number. But 16384-prog_end can't because prog_end position can't be resolved until linking/assembly? (16384 seen as fixed address, thus dcb.w size can't be resolved). QMAC manual page 29 Relocation factors: +1-1 (=0 absolute), +1 (+1 simple relocatable).

Edit: Just tried this and it also worked

Code: Select all

 prog_end   dcb.w    (16384-(prog_end-start))/2,$4e71
BTW for ROM shouldn't it be pad with $FF ?


David
ansar
ROM Dongle
Posts: 44
Joined: Fri Nov 11, 2022 10:50 pm

Re: QMAC Assembler

Post by ansar »

Dear Martin,

Do not place the label in the same line.
Place it in the next one as for instance

......... ds.b xxxxx-(finish-start)
finish end

ds.b is not mandatory but any other directive
as ds.w or whatever can be used

Regards,
ansar


Post Reply