Program Code and Calculation
Added on 2022-11-29
6 Pages724 Words148 Views
|
|
|
Running head: PROGRAM CODE AND CALCULATION
PROGRAM CODE AND CALCULATION
Name of the Student:
Name of the University:
Author Note:
PROGRAM CODE AND CALCULATION
Name of the Student:
Name of the University:
Author Note:
![Program Code and Calculation_1](/_next/image/?url=https%3A%2F%2Fdesklib.com%2Fmedia%2Fimages%2Fwj%2Fe232cf8aac76419aa213fbe05a13cb27.jpg&w=3840&q=10)
PROGRAM CODE AND CALCULATION
1
ANSWER 1:-
MSG DB “1” (Message database 1) // press a key to continue 0
NMSG DB “0” (Message database 0)
NUM DB 75H; (Enter the required no 75H means binary 1110101)
START: MOV AX,@DATA (16 bit data register moved in AX)
MOV DS, AX (Move the data register in DS)
MOV AL, NUM (Copy a number into the register)
MOV BL, 02H; (The Separating starts from 2, Therefore BH is link to 02H)
MOV DX,0000H ; (To evade Divide overflow mistake)//DX
MOV AH,00H ; (To evade Divide overflow error)//AH
L1:DIV BL (Loop checking for prime number)
CMP AH,00H ; (Remains is equated with 00H (AH))
JNE NEXT (Conditional Obstacle for the next)
INC BH ; (BH is incremented if the Number is divisible by BL value)
NEXT:CMP BH,02H ; ( compare the value If BH > 02H so it is not prime )
JE FALSE ; ( Jump in equal if statement is not a Prime No)
INC BL ; ( Increase BL value)
MOV AX,0000H ; //(To evade Divide overflow mistake)
MOV DX,0000H ; //(To evade Divide overflow mistake)
MOV AL,NUM ; (Move the Defaulting no to AL)
CMP BL,NUM ; ( Route the loop until BL matches Value).
JNE L1; (Jump to check again with incremented rate of BL number)
//To show the assumed no is a Prime No//
TRUE: LEA DX, MSG (IF statement is true then LEA assign in the DX)
MOV AH, 07H; (Moved the number and Used to print a string)
INT 21H (Assume one integer value)
JMP EXIT ( Jump the exit value and show this number prime or
not)
FALSE: LEA DX, NMSG (If the prime condition is not match then address the in
bit message 0). (Elarde)
MOV AH, 07H; (Used to print a string)
INT 21H (Show this integer value)
1
ANSWER 1:-
MSG DB “1” (Message database 1) // press a key to continue 0
NMSG DB “0” (Message database 0)
NUM DB 75H; (Enter the required no 75H means binary 1110101)
START: MOV AX,@DATA (16 bit data register moved in AX)
MOV DS, AX (Move the data register in DS)
MOV AL, NUM (Copy a number into the register)
MOV BL, 02H; (The Separating starts from 2, Therefore BH is link to 02H)
MOV DX,0000H ; (To evade Divide overflow mistake)//DX
MOV AH,00H ; (To evade Divide overflow error)//AH
L1:DIV BL (Loop checking for prime number)
CMP AH,00H ; (Remains is equated with 00H (AH))
JNE NEXT (Conditional Obstacle for the next)
INC BH ; (BH is incremented if the Number is divisible by BL value)
NEXT:CMP BH,02H ; ( compare the value If BH > 02H so it is not prime )
JE FALSE ; ( Jump in equal if statement is not a Prime No)
INC BL ; ( Increase BL value)
MOV AX,0000H ; //(To evade Divide overflow mistake)
MOV DX,0000H ; //(To evade Divide overflow mistake)
MOV AL,NUM ; (Move the Defaulting no to AL)
CMP BL,NUM ; ( Route the loop until BL matches Value).
JNE L1; (Jump to check again with incremented rate of BL number)
//To show the assumed no is a Prime No//
TRUE: LEA DX, MSG (IF statement is true then LEA assign in the DX)
MOV AH, 07H; (Moved the number and Used to print a string)
INT 21H (Assume one integer value)
JMP EXIT ( Jump the exit value and show this number prime or
not)
FALSE: LEA DX, NMSG (If the prime condition is not match then address the in
bit message 0). (Elarde)
MOV AH, 07H; (Used to print a string)
INT 21H (Show this integer value)
![Program Code and Calculation_2](/_next/image/?url=https%3A%2F%2Fdesklib.com%2Fmedia%2Fimages%2Fxz%2F428db7d7029e4a72a799df7f74607892.jpg&w=3840&q=10)
PROGRAM CODE AND CALCULATION
2
EXIT: // (Exit this program)//
MOV AH, 4CH (If prime, so it is move)
INT 21H
END START (End this program and continue to the loop)
2
EXIT: // (Exit this program)//
MOV AH, 4CH (If prime, so it is move)
INT 21H
END START (End this program and continue to the loop)
![Program Code and Calculation_3](/_next/image/?url=https%3A%2F%2Fdesklib.com%2Fmedia%2Fimages%2Fby%2Fa1fdf3d56eed474c99aaeb38d6aff2da.jpg&w=3840&q=10)
End of preview
Want to access all the pages? Upload your documents or become a member.
Related Documents