Question: org 1 0 0 h ; Set origin to 1 0 0 h ; Data section primeMsg db 'Prime numbers: ' , 0 x 0

org 100h ; Set origin to 100h
; Data section
primeMsg db 'Prime numbers:',0x0D,0x0A,'$'
nameMsg db 'Your name:',0x0D,0x0A,'$'
idMsg db 'Your university ID:',0x0D,0x0A,'$'
comma db ',','$'
primes db 2,3,5,7,11,13,17,19
name db 'Teja', '$'
id db '12345','$'
hexArray db 0x54,0x65,0x6A,0x61,'$'
; Code section
_start:
mov ah,09h ; DOS function to print string
lea dx, primeMsg ; Load address of the string to print
int 21h ; Call DOS interrupt
mov si, offset primes ; Load address of primes array
mov cx,8 ; Number of primes to print
printPrimesLoop:
mov al,[si] ; 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 ah,09h ; DOS function to print string
lea dx, nameMsg ; Load address of the string to print
int 21h ; Call DOS interrupt
lea dx, name ; Load address of name
call printString ; Print the name
mov ah,09h ; DOS function to print string
lea dx, idMsg ; Load address of the string to print
int 21h ; 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 ah,4Ch ; DOS function to terminate program
int 21h ; Call DOS interrupt
printChar:
mov ah,02h ; DOS function to print character
int 21h ; Call DOS interrupt
ret
printString:
printStringLoop:
mov al,[dx] ; 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 al,[si] ; 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,4 ; Shift right to get the high nibble
call printNibble ; Print high nibble
mov bl, al ; Copy byte to bl again
and bl,0Fh ; Clear high nibble to get the low nibble
call printNibble ; Print low nibble
ret
printNibble:
cmp bl,9 ; Check if the nibble is less than 10
jae printHexLetter ; If greater or equal, print as letter
add bl,'0' ; Convert nibble to ASCII digit
jmp printChar ; Print ASCII digit
printHexLetter:
add bl,'A'-10 ; Convert nibble to ASCII letter (A-F)
jmp printChar ; Print ASCII letter
you give me this code for this question
Write a full assembly program that finds the prime numbers from 0-20.
1. Store the results in array
2. Print the prime numbers separated by comma(,)
3. Print your name and your university ID as two arrays each one on separate line.
4. 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 X8086

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 Programming Questions!