YACOC

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
User avatar
marste
Posts: 97
Joined: Sun Aug 10, 2014 8:58 pm
Location: Italy
Contact:

YACOC

Post by marste » Fri Oct 06, 2017 10:18 pm

(yet another code optimization challenge! :))

As the previous one (viewtopic.php?f=6&t=2597), here another one to get the teeth on:

It should be checked if d is zero or not, but depending on the value of one bit of b the jump should be taken if it is zero (if bit is also zero) or alternatively if it is not zero (as the bit of b).

As usual a starting piece of code:

Code: Select all

      ld a,d
      bit FLAGBIT,b
      jr z,checkforzerovalue
  checkforvaluenonzero:
      or a
      jr z,conditionistrue
      jr continuesinceconditionisfalse
  checkforzerovalue:
      or a
      jr nz,conditionistrue
  continuesinceconditionisfalse:
Let's start the dances!
:)

User avatar
marste
Posts: 97
Joined: Sun Aug 10, 2014 8:58 pm
Location: Italy
Contact:

Re: YACOC

Post by marste » Sat Oct 21, 2017 12:29 am

Two byte less with:
(clearly the "mask" is the byte with the corresponding FLAGBIT bit high and the rest low)

Code: Select all

    ld a,d
    or a
    jr z,diszero
    ld a,FLAGBITMASK
diszero:
    xor b 
    and FLAGBITMASK
    jr z,conditionistrue
continuesinceconditionisfalse:
cannot be improved :?:

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest