Question: . MODEL SMALL . STACK 1 0 0 H . DATA VAL 1 DB ? ; Define Byte ( the size is 1 byte )

.MODEL SMALL
.STACK 100H
.DATA
VAL1 DB ? ; Define Byte (the size is 1 byte), VAL1 is a variable, "?" means that the value is not initialized.
NL1 DB 0AH,0DH, 'ENTER NO: ','$' ; Prints the text, "$" represents the current address according to the assembler.
NL2 DB 0AH,0DH,'IT IS NOT PRIME','$' ; Prints the text, "$" represents the current address according to the assembler.
NL3 DB 0AH,0DH,'IT IS PRIME','$' ; Prints the text, "$" represents the current address according to the assembler.
.CODE
MAIN:
MOV AX, @DATA ; Initialize DATA segment
MOV DS, AX ; Make variables in Data Segment accessible
LEA DX, NL1 ; Load NL1 label's data into DX
MOV AH,09H ; Display the string pointed to by DX
INT 21H ; DOS interrupt for standard input/output
MOV AH,01H ; Read a character and move it into AH
INT 21H ; DOS interrupt for standard input/output
SUB AL,30H ; Convert ASCII character to numeric value
MOV VAL1, AL ; Save the result into VAL1
CMP AL,2 ; Check if the input is 2
JZ PRIME ; If it's 2, it's a prime number
MOV AH,00 ; Clear AH
MOV CL,2 ; Initialize CL for loop counters
DIV CL ; Divide the value by CL (quotient in CL, remainder in AH)
LBL1:
CMP AH,0 ; Check if remainder (AH) is 0
JZ LBL2 ; If remainder is 0, jump to LBL2(not prime)
INC CL ; Increment the divisor for the next iteration
DIV CL ; Divide the loop
CMP CL, AH ; Check if divisor equals remainder
JA LBL3 ; If divisor is greater than remainder, the number is prime
JMP LBL1 ; Repeat until end
LBL2:
LEA DX, NL2 ; Load NL2 label's data into DX
MOV AH,09H ; Display the string pointed to by DX
INT 21H ; DOS interrupt for standard input/output
JMP END_PRGM ; Jump to end program
LBL3:
LEA DX, NL3 ; Load NL3 label's data into DX
MOV AH,09H ; Display the string pointed to by DX
INT 21H ; DOS interrupt for standard input/output
; Here, you can add any additional logic or actions for handling prime numbers.
PRIME:
LEA DX, NL3 ; Load NL3 label's data into DX
MOV AH,09H ; Display the string pointed to by DX
INT 21H ; DOS interrupt for standard input/output
JMP END_PRGM ; Jump to end program
END_PRGM:
; Exit the program
MOV AH,4CH ; AH =4Ch for DOS exit
INT 21H ; DOS interrupt for program termination
END MAIN
convert this program to finds the prime numbers from 0-20.
1. Store the results in array
2. Print the prime numbers separated by comma(,)
(dont use procedure or loop)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!