Question

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
       mov ds,ax
       lea dx,msg1

       mov ah,9
       int 21h
       mov ah,1
       int 21h
       mov num1,al
       lea dx,msg2
       mov ah,9
       int 21h
       mov num2,al
       lea dx,msg3
       mov ah,9
       int 21h

       mov al,num1
       mov al,num2
       mov al,num3
      
       mov ah,0
       mov dl,3
   `   div dl

       mov avg,al
       mov ah,4ch
       int 21h
   main endp
end main

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The main objective of the program is

reading the three data from the command line by using three messages

after reading the data addition is performed then divide by 3 is done to find an average

finally display the average of three numbers

model small
.stack 100h
.data ; data definitions
   num1 db ? - num1 is temproray variable of type byte. db-means define byte
   num2 db ?    - num1 is temproray variable of type byte.  
   num3 db ?    - num1 is temproray variable of type byte.

   MSG1 DB 10,13,"ENTER FIRST NUMBER : $" -MSG1, MSG2,MSG3,MSG4 are messages or string of characters.
   MSG2 DB 10,13,"ENTER SECOND NUMBER: $"  
   MSG3 DB 10,13,"ENTER SECOND NUMBER: $"  
   MSG4 DB 10,13,"SMALLER NUMBER IS : $"
   avg db ? - avg is temproray variable of type byte.
ends
.code
.start
   main proc - procedure declaration
       mov ax,data -  set up data segment
       mov ds,ax - setup data segment
       lea dx,msg1 - msg1 will be loaded to dx register

mov ah,9 - to display the messgae 1
       int 21h
       mov ah,1
       int 21h
       mov num1,al data read externally or in commandline is moved to num1 -8 bit register   
       lea dx,msg2 msg2 will be loaded to dx register
       mov ah,9 - to display the messgae 2
       int 21h
       mov num2,al - data read externally or in commandline is moved to num2 -8 bit register
       lea dx,msg3   msg3 will be loaded to dx register

       mov ah,9 -to display the message

       int 21h   

       mov al,num1 - Data available in num1 transfered into al register
       mov al,num2 -Data available in num2 transfered into al register
       mov al,num3 -Data available in num3 transfered into al register
      
       mov ah,0 - zero value transferred to ah register to set ah register as zero
       mov dl,3 - to average data 3 is transferred to dl register
   `   div dl - divide AX register by dl register- this instruction used to take an average of three number

       mov avg,al - al register contain an average of three number is transferred to avg variable
       mov ah,4ch - terminate program
       int 21h
   main endp -terminate the procedure
end main

Note: some of the instructions in the program is missing

Reading of third message is missing

mov al, num1

mov al, num2

mov al, num3

the above instruction overwrites the al register

instead, add instruction should be used to add the three numbers and further div instruction performs average of three number

Display of message 4 is missing

Add a comment
Know the answer?
Add Answer to:
Analyze this assembly program (emu 8086) line by line! and explain the purpose of the program!...
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
  • I need help with a code in assembly language MASM (x86)

    write an assembly language (x86) program to input in a string 10 multi-digit integers and displays them in ascending order. Modify the code below to comply with the requirement..model small.stack 100h.datastrg1 DB 'Insert numbers: $'strg2 DB 'Sorted numbers: $'Arr Db 10 dup(?)v dw ?.codemain procmov ax,@datamov ds,axmov ah,9lea dx,strg1int 21hmov dl,0ahmov ah,2int 21h;inputsmov di,0mov cx,10Input_loop:mov ah,1int 21hmov arr[di],almov dl,0ahmov ah,2int 21hinc diloop Input_loopmov v,0sort:mov di,0mov cx,10sub cx,vB:mov al,Arr[di]cmp al,Arr[di+1]jng Cmov al,Arr[di]xchg al,Arr[di+1]mov Arr[di],alc:inc diloop Binc vcmp v,10jne sort;Outputmov ah,9lea dx,strg2int...

  • Sketch the flowchart for CASE structure below. name "question_6" model small org 100h main proc start: mov...

    Sketch the flowchart for CASE structure below. name "question_6" model small org 100h main proc start: mov dx, offset msg mov ah, 9 int 21h mov ah, 1 int 21h cmp al, '0' jb stop cmp al, '9' ja stop cmp al, '5' jb test2 ja test3 mov dx, offset msgl jmp print test2: mov dx, offset msg2 test2: mov dx, offset msg2 jmp print test3: mov dx, offset msg3 print: mov ah, 9 int 21h jmp start stop: msg...

  • You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086...

    You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086 please, Same as this code, add that input that I'm asking. Which user of the size and the area where the figure will be located on the screen. .MODEL SMALL   .STACK 100h .DATA    mensaje db 'Seleccione una opcion del siguiente Menu',13, 10        db '1. Dibujar un Circulo', 13, 10        db '2. Dibujar una Linea', 13, 10        db '3. Dibujar un...

  • Explain each line of code. What does the routine do. model small .stack 100h .code main...

    Explain each line of code. What does the routine do. model small .stack 100h .code main proc mov BL, 36 yor BL, 40h mov CL, 16h m: mov ah,6 mov dl, bl. add DL, CL int 21h dec CL jnz m mov ax,4C00h int 21h main endp end main Good luck!

  • So the assignment is to write a program that have the user entered 3 numbers and...

    So the assignment is to write a program that have the user entered 3 numbers and than it will sort it by ascending order. Here are the code I wrote, but it won't compiled and I kept on getting an error message "Using uninitiazed memory" for all the variables. Can someone please help take a look and see whats going on? #include <iostream> using namespace std; int main() { //variables int num1, num2, num3; int lowest, middle, highest; //user inputs...

  • 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,...

  • Answer based on microprocessor 8086 (10) LEA BX, CX 7. Suppose that (AX)-4AOBH, the content of...

    Answer based on microprocessor 8086 (10) LEA BX, CX 7. Suppose that (AX)-4AOBH, the content of [1020H] storage unit is 260FH. Try to determine the results of the following instructions. (1) MOV AX, 1020H (AX) (2) XCHG AX, [1020H) ; (AX) (3) MOV AX, [1020H) ;(AX)=- (4) LEA AX, [1020H) ; (AX) 10. Suppose the size of the stack segment is 256 bytes. The starting address of the stack is 1250: 0000H, assuming there are 5 word-sized data in the...

  • 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,......

  • Assembly language 64 bit please ! An example file for set up ==========+ ;| Data Segment...

    Assembly language 64 bit please ! An example file for set up ==========+ ;| Data Segment BEGINS Here | ;+======================================================================+ segment .data ;Code this expression: sum = num1+num2 num1 dq 0 ;left operand of the addition operation num2 dq 0 ;right operand of the addition operation sum dq 0 ;will hold the computed Sum value RetVal dq 0 ;Integer value RETURNED by function calls ;can be ignored or used as determined by the programmer ;Message string prompting for the keyboard...

  • 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...

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