can some help me write this LC3 Assembly language program? this program must rea
ID: 3705534 • Letter: C
Question
can some help me write this LC3 Assembly language program?
this program must read in two seperate integers and call a subroutine (LARGER) which returns the larger int. the result returned by the subroutine is then displayed by main. the inputs must be passed to the subroutine by the main into register 1 and register 2, and the result (larger) is returned by the subroutine in into register 0.
You must document the protocols for passing parameters and returning the result to/from the subroutine and also follow the convention of saving and restoring registers inside your subroutine.
Explanation / Answer
DATA SEGMENT NUM1 DB ? NUM2 DB ? MSG1 DB 10,13,"ENTER FIRST NUMBER TO COMPARE : $" MSG2 DB 10,13,"ENTER SECOND NUMBER TO COMPARE : $" MSG3 DB 10,13,"LARGER NUMBER IS : $" ENDS CODE SEGMENT ASSUME DS:DATA CS:CODE START: MOV AX,DATA MOV DS,AX LEA DX,MSG1 MOV AH,9 INT 21H MOV AH,1 INT 21H MOV NUM1,AL LEA DX,MSG2 MOV AH,9 INT 21H MOV AH,1 INT 21H MOV NUM2,AL LEA DX,MSG3 MOV AH,9 INT 21H MOV AL,NUM1 CMP AL,NUM2 JG SECOND FIRST: MOV AH,2 MOV DL,NUM1 INT 21H JMP EXIT SECOND: MOV AH,2 MOV DL,NUM2 INT 21H EXIT: MOV AH,4CH INT 21H ENDS END START
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.