Question

Complete the following Intel assembly language program which determines whether the byte sized operand stored in...

Complete the following Intel assembly language program
which determines whether the byte sized operand stored
in memory location 'number' is prime or not. The program
will write the value of 0 into the memory location 'answer'
if the number is not prime, otherwise the initial value of '1' will
be left unmodified (indicating that the number is prime). The program
makes use of the DIV instruction to determine the value of quotient
and remainder when dividing the number by 2,3,4,... (number -1) .

section .data

; put your data in this section using
; db , dw, dd directions

number db 5
answer db 1 ; 1 means number is prime, 0 means number is not prime
section .bss

; put UNINITIALIZED data here using

section .text
global _start

_start:
mov esi, number ; get the offset of number into esi
keith: mov eax, 0 ; clear the entire eax register
mov al, [esi] ; get the number from memory into al
mov dl, al ; put it inside dl as well
mov bl, 2 ; bl holds each divisor starting from 2
loopy: div bl ; ax / bl with quot in al and rem in ah
and ax, 1111111100000000b ; isolate the rem in ah with a AND mask
; to determine whether the remainder is 0

; YOU COMPLETE THE REST OF THE CODE


HINT: The program is to implement the following high-level
pseudocode:

prime = true ;
divisor = 2 ;
while ( divisor < number )
{
if ( the remainder of number / divisor is 0 )
{
prime = false ; // we found a divisor which evenly divides number
} // so therefore number cannot be prime

divisor = divisor + 1 ; // check the next divisor and keep looping
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Complete the following Intel assembly language program which determines whether the byte sized operand stored in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assembly Language NASM create a substring ASSIGNMENT INSTRUCTIONS: Create the Substring from the Given string, beginIndex...

    Assembly Language NASM create a substring ASSIGNMENT INSTRUCTIONS: Create the Substring from the Given string, beginIndex and endIndex The program should create a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex – 1. Thus the length of the substring is endIndex-beginIndex. In other words you can say that beginIndex is inclusive and endIndex is exclusive while getting the substring. Initialize the following values in...

  • Analyze this assembly program (emu 8086) line by line! and explain the purpose of the program!...

    Analyze this assembly program (emu 8086) line by line! and explain the purpose of the program! PROGRAM: .model small .stack 100h .data    num1 db ?    num2 db ?    num3 db ?    MSG1 DB 10,13,"ENTER FIRST NUMBER : $"    MSG2 DB 10,13,"ENTER SECOND NUMBER: $"      MSG3 DB 10,13,"ENTER SECOND NUMBER: $"      MSG4 DB 10,13,"SMALLER NUMBER IS : $"    avg db ? ends .code .start    main proc        mov ax,data       ...

  • Assembly Please answer the following above, compile and single step through the program, writing...

    Assembly Please answer the following above, compile and single step through the program, writing down the value of the destination for each instruction. 1. Using Visual Studio on the system, create a project using the code given below unsigned char short int int gArray 0x09, 0xFA, 0x5A, 0x18, 0x48, 0xAC, 0xD4, 0x71 ; cAr rays 1 [ ] = { 0:09, 0xfa, Ox5A, Ox18, 0x48, OxAC, OxD4, 0x71 }; gArray! [ ] = { Ox09, OxFA, Ox5A, Ox18, 0x48, OxAC,...

  • X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code...

    X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc         .data       KeyPrompt BYTE "Enter the passphrase: ",0       TextPrompt BYTE "Enter the plaintest: ",0           str1 BYTE "The passphrase has length:",0           str2 BYTE "The plaintest has length:",0       KeyIs BYTE "The passphrase: ",0       PlainTextIs BYTE "The plaintext: ",0       CipherTextIs BYTE "The ciphertext: ",0       KMAX = 64                        ; passphrase buffer maximum size       BMAX = 128                       ; test...

  • Need help on Assembly language 1.Solve the following conditions: A. Suppose AL contains 11001011 and CF...

    Need help on Assembly language 1.Solve the following conditions: A. Suppose AL contains 11001011 and CF = 1.    Give the new contents of AL after each of the following instructions is executed.    Assume the above initial conditions for each part of this question. a. SHL AL,1 b. SHR AL,1 c. ROL AL,2 d. ROR AL,3 e. SAR AL,2 f. RCL AL,1 g. RCR AL,3 B. Suppose EAX contain ABCDH.    Show the contents of BX and CX after...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT