Expert Answer
- Comment
Step 1: Code
.data
myMsg BYTE "Enter a number to be evaluated:",0dh,0ah,0
factor DWORD 2
hold DWORD ?
.code
main PROC
call Clrscrmov edx,offset myMsg
call WriteString ;Displays myMsg
call ReadDec ;Puts the value into EAX register
mov edi, factor
call prime
exit
main ENDPprime PROC
step1: mov hold, eax
mov eax, hold
xor edx, edx
div edi
cmp edx, 0
je step2
add factor, 1
mov edi, factor
jmp step1step2: mov hold, eax
mov eax, edi
call WriteDec
mov eax, hold
CMP eax, 1
jz step3
jmp step1step3:
exit
prime ENDP
END mainStep 2: Summary
I hope this code help you. Thank you.
Expert Answer
- Comment
.model small
.stack 100h
.data
num db ?
msg db 'Multiplication table of :$'
string db 5 dup(?)
.code
main proc
MOV AX, @data
MOV DS, AXLEA DX, msg ;; PRINT THE INPUT NUMBER
MOV AH, 9
int 21h
MOV AH, 1
int 21h
SUB AL, 48 ;; CONVERTING INTO NUMBER
MOV num, ALXOR BX, BX
MOV BL, 1
MOV CX, 10
TOP:MOV AL, num
MUL BL
PUSH BX
PUSH CX
LEA SI, stringMOV BX, 10
XOR CX, CX
DIVISION: XOR DX,DX
DIV BX
PUSH DX
INC CX
CMP AX, 0
JNE DIVISION
STORE: POP DX
ADD DL, 48
MOV [SI], DL
INC SI
LOOP STORE
MOV [SI], '$ 'POP CX
POP BX
MOV DL, 13
MOV AH, 2
INT 21h
MOV DL, 10
MOV AH, 2
INT 21h
LEA DX, STRING
MOV AH, 9
INT 21hINC BL
LOOP TOPMOV AH, 4ch ;; END
INT 21h
MAIN ENDP
END
ليست هناك تعليقات:
إرسال تعليق