Question: org 1 0 0 h ; Set origin to 1 0 0 h ; Data section primeMsg db 'Prime numbers: ' , 0 x 0
org h ; Set origin to h
; Data section
primeMsg db 'Prime numbers:xDxA$
nameMsg db 'Your name:xDxA$
idMsg db 'Your university ID:xDxA$
comma db $
primes db
name db 'Teja', $
id db $
hexArray db xxxAx$
; Code section
start:
mov ahh ; DOS function to print string
lea dx primeMsg ; Load address of the string to print
int h ; Call DOS interrupt
mov si offset primes ; Load address of primes array
mov cx ; Number of primes to print
printPrimesLoop:
mov alsi ; Load the current prime number
call printChar ; Print the prime number
inc si ; Move to the next prime
loop printPrimesLoop ; Loop until all primes are printed
mov ahh ; DOS function to print string
lea dx nameMsg ; Load address of the string to print
int h ; Call DOS interrupt
lea dx name ; Load address of name
call printString ; Print the name
mov ahh ; DOS function to print string
lea dx idMsg ; Load address of the string to print
int h ; Call DOS interrupt
lea dx id ; Load address of ID
call printString ; Print the ID
lea dx hexArray ; Load address of hexArray
call printHexArray ; Print the hexArray
mov ahCh ; DOS function to terminate program
int h ; Call DOS interrupt
printChar:
mov ahh ; DOS function to print character
int h ; Call DOS interrupt
ret
printString:
printStringLoop:
mov aldx ; Load current character
cmp al$ ; Check if it's the end of the string
je printStringDone ; If yes, end the loop
call printChar ; Print the character
inc dx ; Move to the next character
jmp printStringLoop ; Loop until end of string
printStringDone:
ret
printHexArray:
mov si offset hexArray ; Load address of hexArray
printHexArrayLoop:
mov alsi ; Load current byte from array
call printHexByte ; Print the byte
inc si ; Move to the next byte
cmp al$ ; Check if it's the end of the array
jne printHexArrayLoop ; Loop until end of array
ret
printHexByte:
mov bl al ; Copy byte to bl
shr bl ; Shift right to get the high nibble
call printNibble ; Print high nibble
mov bl al ; Copy byte to bl again
and blFh ; Clear high nibble to get the low nibble
call printNibble ; Print low nibble
ret
printNibble:
cmp bl ; Check if the nibble is less than
jae printHexLetter ; If greater or equal, print as letter
add bl ; Convert nibble to ASCII digit
jmp printChar ; Print ASCII digit
printHexLetter:
add blA ; Convert nibble to ASCII letter AF
jmp printChar ; Print ASCII letter
you give me this code for this question
Write a full assembly program that finds the prime numbers from
Store the results in array
Print the prime numbers separated by comma
Print your name and your university ID as two arrays each one on separate line.
Convert your first name letters to equivalent hex values store them in array then print the elements separated by :: sign.
dont use loop,procedure,push,pop,load
but dont work on X
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
