Another QMAC question.....

Anything QL Software or Programming Related.
Post Reply
prime
Trump Card
Posts: 192
Joined: Fri Feb 18, 2011 8:58 pm

Another QMAC question.....

Post by prime »

Ok,

So I'm trying to port the released QLSD source for use in my own hardware implementation. This will be on a standard expansion card and so i will need to put the I/O registers at a specified offset from the beginning of the ROM and **NOT** an absolute address.

I just can't figure out how to do this in QMAC :(

I know i will need something like :

Code: Select all

 REGBASE	equ	$3ff0

	lea	REGBASE(PC),a5
	
this however generates the error :

Code: Select all

  86 01 00000020 4BFA3FCE     	lea	IFBASE(PC),a5
                                   |
****** ERROR 31 -- line   86 -    0 - wrong relocation for PC-relative address
Any idea what I can do to fix this ?

Cheers.

Phill.


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

Re: Another QMAC question.....

Post by tofro »

Phill,

try an indexed register, somewhat like that:

Code: Select all

ROMSTART:              dc.l $4afb0001
CODESTART:             lea ROMSTART(PC),a0
                       move.l     #register_offset,d0
                       lea 0(a0,d0.w),a0
This should work. PC-relative addressing doesn't like absolute offsets that are directly equated (I pretty much doubt that even if it had worked you'd be ending up at the correct address - I guess you put in the absolute offset of the registers from the beginning instead of the the difference between the PC and the register...). It want's to see these in your code and calculate on its own....

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
ql_freak
Super Gold Card
Posts: 543
Joined: Sun Jan 18, 2015 1:29 am

Re: Another QMAC question.....

Post by ql_freak »

prime wrote:Ok,

So I'm trying to port the released QLSD source for use in my own hardware implementation. This will be on a standard expansion card and so i will need to put the I/O registers at a specified offset from the beginning of the ROM and **NOT** an absolute address.

I just can't figure out how to do this in QMAC :(

I know i will need something like :

Code: Select all

 REGBASE	equ	$3ff0

	lea	REGBASE(PC),a5
	
this however generates the error :

Code: Select all

  86 01 00000020 4BFA3FCE     	lea	IFBASE(PC),a5
                                   |
****** ERROR 31 -- line   86 -    0 - wrong relocation for PC-relative address
Any idea what I can do to fix this ?
You load relative to the PC (program counter) with LEA (load effective address?) an absolute address(?). Relative addressing on the 68k is only -32768 to +32767 (it is not a real 32-bit processor). So if your program is loaded in the TPA, this relative addressing is too large?

Don't know, if this is correct (I haven't do any programming for 68k for long times) - so the assembler (the 68k-processor) can't relocate (do) this (physically not cabable).


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
ppe
Trump Card
Posts: 171
Joined: Tue Dec 14, 2010 10:48 am
Location: Espoo, Finland

Re: Another QMAC question.....

Post by ppe »

prime wrote:Ok,

I know i will need something like :

Code: Select all

 REGBASE	equ	$3ff0

	lea	REGBASE(PC),a5
	
Any idea what I can do to fix this ?

Cheers.

Phill.
Hi Phill,

I think you need to leave out the "(pc)" bit in assembler source and just specify the offset, i.e, go for

Code: Select all

        lea    REGBASE,a5
Kind regards,
Petri


User avatar
ql_freak
Super Gold Card
Posts: 543
Joined: Sun Jan 18, 2015 1:29 am

Re: Another QMAC question.....

Post by ql_freak »

ppe wrote:
prime wrote:I think you need to leave out the "(pc)" bit in assembler source and just specify the offset, i.e, go for

Code: Select all

        lea    REGBASE,a5
I think you are right. The assembler calculates the distance from the PC to the address - programmers are lazy and this saves 4 characters typing ;-)


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
prime
Trump Card
Posts: 192
Joined: Fri Feb 18, 2011 8:58 pm

Re: Another QMAC question.....

Post by prime »

Just as a quick update I fixed it by defining a symbol ROMSTART at the beginning of the ROM then doing :

Code: Select all


	GENIF 	IS_ROMREL = 1
	lea     ROMSTART(PC),a5		; point to base of ROM
	ENDGEN
	
	GENIF 	IS_ROMREL = 0
	move.l	#IF_BASE,a5		; a5=Pointer to QLROMEXT control registers
	ENDGEN
And then defining all the offsets for the IO relative to the start of the ROM if ROMREL=1, and relative to IF_BASE if not.

Cheers.

Phill.


Post Reply