Question

My Question

Building the code below i get: "319920C30020C30A20FBED563E00C600CA0520F33E55D3073E00FBC9"

My Problem is I assumed that this would be padded with zeros such that each block of code is at the requested addresses 0000H, 0038H, and 2000H in program memory.

Immediately I can see a work around of manually doing the padding, but how are Z80 processors loaded with the above program, to be at the correct addresses?

Code

STACK .EQU 2099H
.ORG 0000H
    ld  SP, STACK
    jp 2000H

.ORG 0038H
    jp  service_routine

.ORG 2000H
    EI
    IM 1 
    LD  A, 00H

LOOP:
    ADD A, 00H
    jp  z, LOOP

service_routine:
    DI
    ld  A, 55H
    out (07H),A
    ld  A, 00H
    EI
    ret
Was it helpful?

Solution

The ORG directive merely tells the assembler what you think the PC is at that point in the code. The assembler can then use this to compute the correct code for a relative jump. It does not direct the assembler or the loader to actually load the code at that address.

OTHER TIPS

The process of converting a disk image to a running program can be quite complex. In the old days a block of 1k zeros was seen as a severe waste of disk space, but it's just as true today at a different scale - you might sneer at 1K zeros but no one will doubt that 1G zeros in a file would be a waste.

Depending on the machine architecture, the process might involve a lot more than just relocating blocks of code and data. For example jump addresses within the code might have to be patched to refer to the correct address of external modules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top