Question

Problem 2. Write a program that contains two segments: A data segment called SEG DATA that contains two variables NUM1 and NUM2 where the size of each is one byte. A code segment SEG CODE that will compute the sum of even and odd values of a memory block of size 10 bytes that is saved at DS:0200H. The sum of even values should be saved in NUM1 and the sum of odd values in NUM2.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following is the ASM code for the above question:

.model tiny
.486
.data
num1 db 0
num2 db 0
.code
.startup
mov cl,11
mov di,0200h
x5: mov dl,[di]
mov dh,dl
and dl,0fh
and dh,0f0h
ror dh,4
mov al,dl
mov ah,00h
mov bl,2
div bl
cmp ah,0
jnz x1
add num1,dl
jmp x2
x1: add num2,dl
x2: mov al,dh
mov ah,0
div bl
cmp ah,0
jnz x3
add num1,dh
jmp x4
x3: add num2,dh
x4: inc di
dec cl
jnz x5
.exit
end

Add a comment
Know the answer?
Add Answer to:
Problem 2. Write a program that contains two segments: A data segment called SEG DATA that...
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
  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • Write a program that compares two blocks of memory, each of size 200 bytes. One block...

    Write a program that compares two blocks of memory, each of size 200 bytes. One block resides in DS at 13501 and another in ES t 750 If any of the wo in DS matches with a corresponding word in ES then that word is stored in memory at DS:T050], and corresponding addresses of DS and ES are stored at DS:[052] and at Ds:(054) respectively. a. C35. JE L) JA L 2

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

  • In c++ Write a program that contains a class called Player. This class should contain two...

    In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...

  • Write a MIPS program with two variables in the .data segment - x and y. The...

    Write a MIPS program with two variables in the .data segment - x and y. The program should load x into a register. It should then isolate the last twelve bits of x (the twelve bits furthest to the right). It should finally store the resulting value in the variable y. So, for example, if x contains 1111 0000 1111 0000 1111 0011 1100 1010, your program should store the value 0000 0000 0000 0000 0000 0011 1100 1010 in...

  • 1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that...

    1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that does the following: eax = (ecx + edx ) - (eax + ebx) 2. Write a piece of code that copies the number inside al to ch. Example: Assume that Initially eax = 0x15DBCB19. At the end of your code ecx = 0x00001900. Your code must be as efficient as possible. 3. You are given eax = 0x5. Write one line of code in...

  • Problem: Create a program that contains two functions: main and a void function to read data...

    Problem: Create a program that contains two functions: main and a void function to read data from a file and process it. Your main function should prompt the user to enter the name of the file (Lab7.txt), store this name, and then call the function sending the name of the file to the function. After the function has completed, the main function should output the total number of values in the file, how many of the values were odd, how...

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

  • Write a complete Java program, including comments in both the main program and in each method,...

    Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once.      This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...

  • Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called...

    Write a simple Java program with the following naming structure: Open Eclipse Create a workspace called hw1 Create a project called hw1 (make sure you select the “Use project folder as root for sources and class files”) Create a class called Hw1 in the hw1 package (make sure you check the box that auto creates the main method). Add a comment to the main that includes your name Write code that demonstrates the use of each of the following basic...

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