Z88 Developers' Notes
Contents   Contents of System Calls

GN_Xin, insert an entry into a linked list

RST 20H, DEFW $4609

IN:

     HL = pointer to a 9-byte parameter block (usually on the stack):
     (HL+0) ... (HL+2) = pointer of block to insert
     (HL+3) ... (HL+5) = pointer to previous block
     (HL+6) ... (HL+8) = pointer to next block
OUT, if call successful:
     Fc = 0
OUT, if call failed:
     Fc = 1
     A = error code:
          RC_BAD ($04), if pointer to block to insert = 0.
Registers changed after return:
     ..BCDEHL/IXIY same
     AF....../.... different
Notes:
     Algorithm: Assuming inserting entry I between entries X and Y:
     *I = X XOR Y
     *X = *X XOR Y XOR I
     *Y = *Y XOR X XOR I

     If X and Y are zero then the link is cleared.
Bugs:

Related calls:

GN_Xdl, delete an entry from a linked list
GN_Xnx, index next entry in linked list