Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

With the program below it needs to run 10 times then stop: NOTE it is in Assembl

ID: 3549365 • Letter: W

Question

With the program below it needs to run 10 times then stop: NOTE it is in Assembly Language


CLO ; Close unwanted windows.

MOV BL,0

Start:

; Turn off all the traffic lights.

CMP BL,3

ADD BL,1

MOV AL,0 ; Copy 00000000 into the AL register.

OUT 01 ; Send AL to Port One (The traffic lights).

; Turn on all the traffic lights.

MOV AL,80 ; Copy 10000000 into the AL register.

OUT 01

MOV AL,40 ; Copy 01000000 into the AL register.

OUT 01

MOV AL,20 ; Copy 00100000 into the AL register.

OUT 01

MOV AL,10 ; Copy 00010000 into the AL register.

OUT 01

MOV AL,8 ; Copy 00001000 into the AL register.

OUT 01

MOV AL,4 ; Copy 00000100 into the AL register.

OUT 01

; Send AL to Port One (The traffic lights).

JMP Start ; Jump back to the start.

END ; Program ends.

Explanation / Answer


for index := 1 to count loop
... { body of loop }
end for;
-----------------------------------------------------------
mov ecx, 10 ; number of iterations
forCounter: . ; body of loop
.
.
dec ecx ; decrement loop counter
jecxz endFor ; exit if counter = 0
jmp forCounter ; otherwise repeat body
endFor:
------------------------------------------------------------
YOUR CODE BELOW
------------------------------------------------------------


MOV BL,0

MOV ECX , 10 ; number of iterations

Start:     ; Turn off all the traffic lights.

CMP BL,3

ADD BL,1

MOV AL,0 ; Copy 00000000 into the AL register.

OUT 01 ; Send AL to Port One (The traffic lights).

; Turn on all the traffic lights.

MOV AL,80 ; Copy 10000000 into the AL register.

OUT 01

MOV AL,40 ; Copy 01000000 into the AL register.

OUT 01

MOV AL,20 ; Copy 00100000 into the AL register.

OUT 01

MOV AL,10 ; Copy 00010000 into the AL register.

OUT 01

MOV AL,8 ; Copy 00001000 into the AL register.

OUT 01

MOV AL,4 ; Copy 00000100 into the AL register.

OUT 01    ; Send AL to Port One (The traffic lights).

DEC ECX ; decrement loop counter

JECXZ END ; exit if counter = 0

JMP Start ; Jump back to the start.


END ; Program ends.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote