home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol264 / zlib1.lbr / Z3IFELSE.Z80 < prev    next >
Encoding:
Text File  |  1986-03-23  |  1.0 KB  |  48 lines

  1. ;
  2. ; Z3LIB Module Name:  Z3IFELSE
  3. ; Author:  Richard Conn
  4. ; Z3LIB  Version Number:  1.3
  5. ; Module Version Number:  1.1
  6. ;
  7.     public    ifelse
  8.  
  9.     ext    getmsg
  10.  
  11. ;
  12. ;    IFELSE complements the Active Bit for the Current IF.  Return with
  13. ; A=0 and Zero Flag Set (Z) if there is no current IF.
  14. ;
  15. ifelse:
  16.     push    hl        ;save regs
  17.     push    bc
  18.     call    getmsg        ;pt to messages
  19.     inc    hl        ;pt to IF byte
  20.     ld    a,(hl)        ;get IF byte
  21.     or    a        ;any active IFs?
  22.     jp    z,iferr
  23.     ld    b,a        ;get IF byte in B
  24.     inc    hl        ;pt to IF active byte
  25.     ld    a,(hl)        ;get it
  26.     cpl            ;flip bits
  27.     and    b        ;look at only interested bit
  28.     ld    c,a        ;result in C
  29.     ld    a,b        ;complement IF byte
  30.     cpl
  31.     ld    b,a
  32.     ld    a,(hl)        ;get active byte
  33.     and    b        ;mask in only uninterested bits
  34.     or    c        ;mask in complement of interested bit
  35.     ld    (hl),a        ;save result
  36.     pop    bc        ;restore registers
  37.     pop    hl
  38.     xor    a        ;return NZ
  39.     dec    a
  40.     ret
  41. iferr:
  42.     pop    bc        ;restore registers
  43.     pop    hl
  44.     xor    a        ;return Z
  45.     ret
  46.  
  47.     end
  48.