lab3 - Stanford University€¦ · CS247L Lab3 Wednesday April 16, 2014 Please Download
CS 206D Computer Organization Lab3
-
Upload
cole-lynch -
Category
Documents
-
view
31 -
download
1
description
Transcript of CS 206D Computer Organization Lab3
CS 111
CS 206D Computer OrganizationLab3
CS 111
LOOP Instruction • The LOOP instruction can be used to implement a for loop.
• Syntax:
; initialize CX to loop_count destnation_lable:
; body of the loopLOOP destnation_lable
CS 111
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.
For loop
CS 111
• Example: Write some code to display a row of 20 stars.
• Solution: Pseudo code:
FOR 20 times DO display '*'END_IF
For loop
CS 111
• Example: Write some code to display a row of 20 stars.
It can be coded as follows:MOV CX, 20 ; initialize CX to 80MOV AH, 2MOV DL, '*'
TOP:INT 21hLOOP TOP
Exercise :
CS 111
• Example: Write some code to display all English alphabets (A TO Z)
Exercise :
CS 111
• Example: Write some code to display all English alphabets (A TO Z)