1 / 7

CS 206D Computer Organization Lab3

CS 206D Computer Organization Lab3. LOOP Instruction. The LOOP instruction can be used to implement a for loop. Syntax : ; initialize CX to loop_count destnation_lable: ; body of the loop LOOP destnation_lable. LOOP instruction.

cole-lynch
Download Presentation

CS 206D Computer Organization Lab3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 206D Computer Organization Lab3 CS 111

  2. LOOP Instruction • The LOOP instruction can be used to implement a for loop. • Syntax: ; initialize CX to loop_count destnation_lable: ; body of the loop LOOP destnation_lable CS 111

  3. LOOP instruction • The counter for the loop is the register CX, which is initialized to loop_count. • Execution of the LOOP instruction causes CX to be decremented automatically. • If (CX < > 0) control transfers to destination_label else the next instruction after LOOP is done. CS 111

  4. For loop • Example: Write some code to display a row of 20 stars. • Solution: • Pseudo code: • FOR 20 times DO • display '*' • END_IF CS 111

  5. For loop • Example: Write some code to display a row of 20 stars. It can be coded as follows: MOV CX, 20 ; initialize CX to 80 MOV AH, 2 MOV DL, '*' TOP: INT 21h LOOP TOP CS 111

  6. Exercise : • Example: Write some code to display all English alphabets (A TO Z) CS 111

  7. Exercise : • Example: Write some code to display all English alphabets (A TO Z) CS 111

More Related