Program Code and Calculation

Write a MARIE program to check if a given number is prime or not. Also, explain the address structure and module organization for high-order and low-order interleaving in a memory consisting of 32 4Kx8-bit chips.

6 Pages724 Words148 Views

This document discusses program code and calculation. It provides examples of program code and explains how to perform calculations. The document also includes answers to common questions and explores different techniques related to program code and calculation.

Program Code and Calculation

Write a MARIE program to check if a given number is prime or not. Also, explain the address structure and module organization for high-order and low-order interleaving in a memory consisting of 32 4Kx8-bit chips.

BookmarkShareRelated Documents
Running head: PROGRAM CODE AND CALCULATION
PROGRAM CODE AND CALCULATION
Name of the Student:
Name of the University:
Author Note:
PROGRAM CODE AND CALCULATION
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
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)

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
|5
|878
|18

|6
|757
|96

Tools

+1 306 205-2269

Chat with our experts. we are online and ready to help.