1. Write a function named CHECK to implement the following flowchart. Preserve a
ID: 3826342 • Letter: 1
Question
1. 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
CHECK
movb #$FF, PORTH
label1`:
dec PORTH
cmp PORTJ, $80
jne label1
movb $00 PORTH
RTS
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.