write down the algoritmics steps and the machine code to find the maximum of thr
ID: 3623867 • Letter: W
Question
write down the algoritmics steps and the machine code to find the maximum of three numbers stored in memory cells 00,01 and 02.Store the maximum value at memory cell 03.The opcode table is given below.Op-code Operand Description
1 RXY LOAD reg. R from cell XY
2 RXY LOAD reg. R with cell XY
3 RXY STORE reg. R at XY
4 0RS MOVE R To S.
5 NXY STORE ON TO CELL XY
6 RST ADD S AND T into R
7 RST SUB S and T into R. (R<- S - T)
8 RST OR S and T into R.
9 0ST LOAD reg. S from cell pointed by T
A RST XOR S and T into R.
B R0X ROTATE reg. R X times.
C 0XY JUMP to XY.
D RXY JUMP TO XY If R=Reg. 0.
E RXY JUMP TO XY If R>0.
F 000 HALT
<- means arrow
Explanation / Answer
; Program name: Maximum of three numbers.
; Code segment ; start of the code segment.
Load R1,[00] ;Load register R1 with [00]
Load R2,[01] ; Load register R2 with [01]
Load R3,[02] ;Load register R3 with [02]
Load R4,[03] ;Load register R4 with [03]
jmpLE R1<=R2, XX ;Compare R1 With R2
Move R1, R3 ; Move contents of R3 into R1
XY: Store R4, R1 ; store the result in R4
Halt ; Halt the program
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.