7.11 Write an assembly program with the following specifications. a. In the main
ID: 3850330 • Letter: 7
Question
7.11 Write an assembly program with the following specifications. a. In the main block, you should have two registers R4 and R5. They should be checked in an infinite loop. If R4 is greater than R5, then the greater subroutine will be called. If R4 is less than R5, then the less subroutine will be called. If R4 equals R5, then no operations will be done. b. In the greater subroutine, your code will fill the decimal numbers 1, 2, 3, 4, 5 in hexadecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one. c. In the less subroutine, your code will fill the decimal numbers 10, 9, 8, 7, 6 in hexadecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one. T
his is an assembly code written as (mov.w #00, R4)please!!!
Explanation / Answer
Here in answer:
MY_TABLE is some memory location where we want to write.
START:
CMP R4,R5;
JG greater; // if R4 is greater than R5 jump to greater label
JL less; // if R4 is less than R5 jump to less label
JMP START; // jump to start infinite loop
greater :
MOV EBX, [MY_TABLE]; // move address to EBX
MOV [EBX], 1;
ADD EBX,4; // Suppose 4 bytes of each block
MOV [EBX], 2;
ADD EBX, 4;
MOV [EBX], 3;
ADD EBX, 4;
MOV [EBX], 4;
ADD EBX, 4;
MOV [EBX], 5;
DEC [R4];
ret
less :
MOV EBX, [MY_TABLE]; // move address to EBX
MOV [EBX], 10;
ADD EBX,4; // Suppose 4 bytes of each block
MOV [EBX], 9;
ADD EBX, 4;
MOV [EBX], 8;
ADD EBX, 4;
MOV [EBX], 7;
ADD EBX, 4;
MOV [EBX], 6;
DEC [R4];
ret
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.