Interrupt vector and Minerva

Anything QL Software or Programming Related.
spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Interrupt vector and Minerva

Post by spkr »

Sure. Now we're getting away further from the actual problem. But I have a piece of init code that relocates the code, because PC relative coding is just not needed ;)

Code: Select all

;----------------------------------------------
; BOOTSTRAP RELOCATION CODE - relocate the relocator!
;----------------------------------------------
	trap		#0				; get into supervisor mode
	or.w   	#$700,sr			; shut down all interrupts
	lea		reloc_start(pc),a0	; start of reloc code
	lea		$30000,a1			; target of reloc code
	move.l	#(reloc_end-reloc_start)/4,d7
.c		move.l	(a0)+,(a1)+	; reloc the reloc code!
	dbra	d7,.c
	lea		code_start(pc),a5	; prep values, a5 is start of program to actually relocate
	move.l	#ORG_LOC,a6		; a6 is destination of relocation code
	jmp		$30000			; jump to the relocation code, that will relocate the code, and in turn jump to start of relocated code
;----------------------------------------------
; Relocation code
;----------------------------------------------
reloc_start
	move.l	#(code_end-code_start)/4,d0		; size of demo code
reloc_loop:	
	move.l	(a5)+,(a6)+						; relocate the demo code
	dbra	d0,reloc_loop					; iter
	jmp		ORG_LOC							; run demo
reloc_end
In this code ORG_LOC is $30100.

I read from some manual that when using Minerva one should not change the stack pointer. In the Minerva romcode itself, I see there are assumptions made about the location of the stack pointer. Some minimal testing shows that this matters (in my code SP is set to $30100, and Minerva makes assumptions about the upper word of the addres.....).

Im sure this stuff is all nice if you color inside the lines, but I never care much for lines :)

Kind regards,
Wietze


User avatar
janbredenbeek
Super Gold Card
Posts: 633
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: Interrupt vector and Minerva

Post by janbredenbeek »

Hi Wietze,
spkr wrote: Wed Feb 07, 2024 7:06 am I read from some manual that when using Minerva one should not change the stack pointer. In the Minerva romcode itself, I see there are assumptions made about the location of the stack pointer. Some minimal testing shows that this matters (in my code SP is set to $30100, and Minerva makes assumptions about the upper word of the addres.....).
In Minerva, there is a relation between the SSP and register A6 (which points to the system variables, at least within the system itself). In QDOS, A6 was fixed at $28000 but that precludes the use of the second screen, so when Minerva is configured for dual screen A6 will be $30000.
Now in order to find the location of the system variables, Minerva assumes that the SSP is within the same $8000 segment as the system variables (the SSP area is normally $180 to $480 bytes above A6).

You may move your program and the stack anywhere you want in RAM, but then most of the operating system features of QDOS or Minerva should be disabled (by entering supervisor mode and disabling interrupts). Reading the keyboard is still possible using the MT.IPCOM trap (KEYROW function), but you can forget about using most of the other I/O functions and have to write this code yourself (e.g. writing to the screen). I guess most games work this way...

Best Regards, Jan.


Post Reply