
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
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