Sorcery icon indicating copy to clipboard operation
Sorcery copied to clipboard

Relocatable programs thanks to pc-counter only

Open ghost opened this issue 5 years ago • 1 comments

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

ghost avatar Oct 22 '20 16:10 ghost

We indeed need that, but we also need an efficient way to acess no-read only data, bss data and possibly external data

TheMachine02 avatar Oct 28 '20 22:10 TheMachine02