Write a function named CHECK to implement the following flowchart. Preserve all
ID: 3826810 • Letter: W
Question
Write a function named CHECK to implement the following flowchart. Preserve all registers used in the function. Some things to keep in mind: It is not necessarily the case that one rectangle equals one line of assembly language. Sometimes you need several lines of assembly language to carry out the step shown inside the rectangle. Your function needs to start with the label CHECK, and end with an RTS (since it's a function) Push registers (onto the stack)first. At the end, pull the registers in reverse order before calling RTS. In order to read or check a PORT, you need to read it into a register (like register A or register B). In order to write or update a PORT, you need to write to it from a register (like register A or register B). So, to "decrement" a PORT, you need to read it into a register, decrement the value, and then write it back. Since PORTH and PORTJ are 8-bits ports, you cannot use register X, Y, or D - you have to use register A or B.Explanation / Answer
PUSH A
MOV A, 99h
OUT PORTH,A
BACK : IN A, PORTJ
DEC A
OUT PORTJ, A
CMP A, 80h
JNZ BACK
MOV A, 00h
OUT PORTH,A
POP A
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.