Write a program that finds the square of a number listed below in a subroutine a
ID: 3677904 • Letter: W
Question
Write a program that finds the square of a number listed below in a subroutine and stores the results into the memory locations $2100-$2104. Complete the following program and use memory dump (md) to see the result obtained. Do not forget to add comments to the each program line and explain its operation.
Hint: Multiplying a number by itself will make it square.
Numbers: $0A, $0C, $0B, $0F
ORG
$2000
LDS
#$3000
LDX
#$55AA
PSHX
LDX
.
.
PULX
SWI
SQUARE:
.
TAB
MUL
.
RTS
ORG
$2000
LDS
#$3000
LDX
#$55AA
PSHX
LDX
.
.
PULX
SWI
Explanation / Answer
DATA SEGMENT NO DB 2 DATA ENDS CODE SEGMENT SQUARE PROC NEAR ASSUME CS:CODE MOV AX,0000 MOV AL,BL MUL BL MOV CX,AX MUL BL MOV BX,AX RET SQUARE ENDP ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV BL,NO CALL SQUARE MOV BL,00H MOV AH,4CH INT 21H CODE ENDS END START ;------ ;OUTPUT ;------ -G CS:001A AX=0008 BX=0008 CX=0004 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=0BAC ES=0B9C SS=0BAC CS=0BAD IP=001A NV UP EI PL NZ NA PO NC 0BAD:001A B300 MOV BL,00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.