Relocatable programs thanks to pc-counter only
Finally, in order to relocate any program, I think that just far-relative CALL and far-relative JP are needed, but how about management of data-addressing ?..Well...Inspired by the ARM processor instruction set, I suggest the creation of the pseudo-instruction ADR which would allow you to generate a pc-relative address in a register. (see https://www.keil.com/support/man/docs/armasm/armasm_dom1361358903373.htm ) Thus, we could use: ADR bc,label ADR de,label ADR hl,label ADR sp,label ADR ix,label ADR iy,label
What do you think of it?
Here's my 1st attempt:
for ADR hl,$100 the assembler would actually consider it as call ADRHL \ db $100-pc
ADRHL: ; with bc'=3 di exx ex af,af' pop hl ld de,(hl) add hl,bc push hl add hl,de push hl ex af,af' exx pop hl ei ret
We indeed need that, but we also need an efficient way to acess no-read only data, bss data and possibly external data