From 0e9173a89aaa1c0b28e17775f012caa563544e97 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 12 Nov 2019 19:45:56 -0500 Subject: [PATCH] zasm: optimize handleRST a little bit --- apps/zasm/instr.asm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index a7401e8..d25b808 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.asm @@ -559,16 +559,14 @@ handleLDrr: handleRST: ld a, (INS_CURARG1+1) ; verify that A is either 0x08, 0x10, 0x18, 0x20, 0x28, 0x30 or 0x38. - ; Good news: they're all multiples of 8. - ; to verify that we're within range, we to 8-bit rotation. If any of - ; the first 3 bytes are set (thus not a multiple of 8), the cp 8 - ; later will yield NC because those bits will now be upwards. - rrca \ rrca \ rrca - cp 8 - jr nc, .error - ; good, we have a proper arg. Now let's get those 3 bits in position - rlca \ rlca \ rlca - or 0b11000111 + ; Good news: the relevant bits (bits 5:3) are already in place. We only + ; have to verify that they're surrounded by zeroes. + ld c, 0b11000111 + and c + jr nz, .error + ; We're in range. good. + ld a, (INS_CURARG1+1) + or c ld (INS_UPCODE), a ld c, 1 ret