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

In the ?rst And instruction in Figure 3.4 the immediate value 2 is used when che

ID: 1715653 • Letter: I

Question

In the ?rst And instruction in Figure 3.4 the immediate value 2 is used when checking the KIN ?ag, but in Figure 3.5 the immediate value 1 is used in the ?rst Test Bit instruction when checking the same ?ag. Explain the difference

R2, #LOC Initialize pointer register R2 to point to the ove address of the first location in main memory where the characters are to be stored Load ASCII code for Carriage Return into R3. Wait for a character to be entered. Check the KIN flag. MoveByte READ: LoadByte R3, #CR R4, KBD_STATUS R4, R4, #2 nc Branch if IR4-0READ LoadByte R5, KBD_DATARead the character from KBD DATA (this clears KIN to 0) Write the character into the main memory and R5, (R2) R2, R2, #1 R4, DISP_STATUS R4, R4, #4 ECHO R5, DISP_DATA Move the character just read to the display StoreByte Add increment the pointer to main memory Wait for the display to become ready. Check the DOUT flag ECHO: LoadByte And Branch-ir_1 R41=0 StoreByte buffer register (this clears DOUT to 0) Branch-ir_1 R51#1R31 READ Check if the character just read is the Carriage Return. If it is not, then branch back and read another character igure 3.4 A RISC-style program that reads a line of characters and displays it

Explanation / Answer

The difference is that Figure 3.4 uses a RISC – style program

The Figure 3.5 uses a CISC – style program.

In CISC – style you can perform operations directly on operands in memory which is why you can use value 1 in Figure 3.5.

and also,

Figure 3.4 which is a RISC-style program increments by the immediate value of two during the and instruction because it is checking the second bit of memory stored in register R4.

This is the location of the Kin flag, and will loop when != 0. This is a continuous waiting loop, that checks the flag, and when the flag is 1, this will exit the branch instruction and continue on with the rest of the instructions.

Figure 3.5, which is a CISC-style program. the instruction TestBit is initializing the KBD_Status to 1 meaning there is a changer entered and skips over the branch instruction T

his moves the bit to R@ and resets the KBD_Status to 0, sending it into a wait loop.