diff --git a/apps/zasm/symbol.asm b/apps/zasm/symbol.asm index 33a7aaa..1504bd3 100644 --- a/apps/zasm/symbol.asm +++ b/apps/zasm/symbol.asm @@ -110,12 +110,14 @@ symRegister: ; Is our new name going to make us go out of bounds? push hl ; --> lvl 2 push de ; --> lvl 3 + ld d, 0 + ld e, c + add hl, de ; if carry set here, sbc will carry too ld e, (ix+2) ; DE --> pointer to record list, which is also ld d, (ix+3) ; the end of names pool ; DE --> names end - ld a, c - call addHL - call cpHLDE + + sbc hl, de ; compares hl and de destructively pop de ; <-- lvl 3 pop hl ; <-- lvl 2 jr nc, .outOfMemory ; HL >= DE @@ -190,9 +192,15 @@ _symFind: jr z, .end ; match! Z already set, IY and HL placed. .skip: ; ok, next! - ld a, (iy) ; name len again - call addHL ; advance HL by A chars - inc iy \ inc iy \ inc iy + + push de ; --> lvl 1 + ld de, 0x0003 + add iy, de ; faster and shorter than three inc's + ld e, (iy-3) ; offset is also compulsory, so no extra bytes used + ; (iy-3) holds the name length of the string just processed + add hl, de ; advance HL by (iy-3) characters + pop de ; <-- lvl 1 + djnz .loop ; end of the chain, nothing found .nothing: diff --git a/kernel/core.asm b/kernel/core.asm index a88cf2f..1289351 100644 --- a/kernel/core.asm +++ b/kernel/core.asm @@ -53,28 +53,25 @@ intoIX: ret ; add the value of A into HL +; affects carry flag according to the 16-bit addition, Z, S and P untouched. addHL: - push af - add a, l - jr nc, .end ; no carry? skip inc - inc h -.end: - ld l, a - pop af + push de + ld d, 0 + ld e, a + add hl, de + pop de ret + ; subtract the value of A from HL +; affects flags according to the 16-bit subtraction. subHL: - push af - ; To avoid having to swap L and A, we sub "backwards", that is, we add - ; a NEGated value. This means that the carry flag is inverted - neg - add a, l - jr c, .end ; if carry, no carry. :) - dec h -.end: - ld l, a - pop af + push de + ld d, 0 + ld e, a + or a ;reset carry flag + sbc hl, de ;There is no 'sub hl, de', so we must use sbc + pop de ret ; Compare HL with DE and sets Z and C in the same way as a regular cp X where