home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / zenlib / lst9_12.asm < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  29 lines

  1. ;
  2. ; *** Listing 9-12 ***
  3. ;
  4. ; Illustrates the use of a word-sized DEC for the outer
  5. ; loop, taking advantage of the knowledge that the counter
  6. ; for the inner loop is always 0 when the outer loop is
  7. ; counted down. This code uses no registers other than
  8. ; CX, and would be used when registers are in such short
  9. ; supply that no other registers are available. Otherwise,
  10. ; word-sized DECs would be used for both loops. (Ideally,
  11. ; a LOOP would also be used instead of DEC CX/JNZ.)
  12. ;
  13. ; Note: This is a sample code fragment, and is not intended
  14. ; to either be run under the Zen timer or assembled as a
  15. ; standalone program.
  16. ;
  17.     mov    cl,5    ;outer loop is performed 5 times
  18. OuterLoop:
  19.     mov    ch,10    ;inner loop is performed 10 times
  20.             ; each time through the outer loop
  21. InnerLoop:
  22. ;<<<working code goes here>>>
  23.     dec    ch    ;count down inner loop
  24.     jnz    InnerLoop
  25.     dec    cx    ;CH is always 0 at this point, so
  26.             ; we can use the shorter & faster
  27.             ; word DEC to count down CL
  28.     jnz    OuterLoop
  29.