home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / sms32 / jz_jnz.asm < prev    next >
Encoding:
Assembly Source File  |  1997-03-15  |  967 b   |  33 lines

  1. ; A program to test JZ and JNZ.
  2.  
  3. ; The 'Z' or zero flag in the status register (SR) is set
  4. ; whenever a calculation gives a zero result.  The JZ
  5. ; and JNZ commands work in conjunction with the 'Z' flag.
  6. ; JZ causes the program to jump if the 'Z' flag is set.
  7. ; JNZ causes the program to jump if the 'Z' flag is not set.
  8.  
  9. ; A count down loop that terminates when AL becomes zero.
  10. ; This loop exercises the JZ (jump zero) command.
  11.  
  12. start:
  13.     mov    al,5    ; Initialise AL register counter to 5.
  14. foo:
  15.     dec    al    ; Decrement AL.
  16.     jz    bar    ; Jump out of loop if zero bit is set.
  17.     jmp    foo    ; Jump back and repeat the loop.
  18.  
  19.  
  20. ; A count down loop that terminates when AL becomes zero.
  21. ; This loop exercises the JNZ (jump not zero) command.
  22.  
  23. bar:
  24.     mov    al,5    ; Initialise AL register counter to 5.
  25. puppy:
  26.     dec    al    ; Decrement AL.
  27.     jnz    puppy    ; Jump back and repeat the loop 
  28.             ; if the zero bit is not set.
  29.  
  30.     jmp    start    ; PRESS ESCAPE TO STOP THE PROGRAM
  31.  
  32.     end
  33.