Question

In: Computer Science

Assembly Language Programming Exercise 5. Listing File for AddTwoSum ( 5 pts ) Generate a listing...

Assembly Language Programming Exercise

5. Listing File for AddTwoSum ( 5 pts )
Generate a listing file for the AddTwoSum program and write a description of the machine code
bytes generated for each instruction. You might have to guess at some of the meanings of the
byte values. Hint: Watch my tutorial and read a little bit of Ch 4.

Solutions

Expert Solution

The Answer is Assembly Language Programming Exercise

Listing File for AddTwoSum

This program calculates the sum of two integers

INCLUDE Irvine32.inc

ExitProcess PROTO

.data

sum DWORD 0

.code main PROC

mov eax,5 ; EAX=5

add eax,6 ; EAX=11

mov sum,eax ; sum=11

mov ecx,0

call ExitProcess

exit

main ENDP

END main

The listing file for the above source code is as follows:

INCLUDE Irvine32.inc

C.NOLIST

C.LIST

00000000 .code

00000000 main PROC

00000000 B8 00000005 mov eax.5 EAX=5

00000005 05 00000006 add eax,6 ; EAX=11

0000000A A3 00000000 mov sum,eax sum=11

0000000F B8 00000000 mov ecx,0 : ECX=0

00000014 E8 00000000 E call ExitProcess

00000019 main ENDP

END main

The .NOLIST directive disables listing this source code unless a .LIST directive is encounter'

The machine code generated by the assembler contains the line numbers against each instruction;

the instructions offset addresses, translated machine code etc.

The second-third leftmost columns tell the machine code bytes (in hexadecimal format) generated for the corresponding instruction.

For example,

B8 00000005 is the first instructions' bytes where 88 is the opcode and 00000005 is the value of the operand.

The above used opcodes are explained below:

1. 68: It is known as operation code as it represents a simple machine instruction to move a 32-bit integer say to EAX register

2. 05: It is used when a 32-bit value is added to a 32-bit register

3. A3: It is used when the value of a 32-bit register is moved to a 32-bit integer variable.

4. E8: It is used when a call is made to a procedure.


Related Solutions

Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the...
Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers.
Explain the differences between an assembly language source code file, the listing file produced by 'nasm',...
Explain the differences between an assembly language source code file, the listing file produced by 'nasm', the object file (.o) and the final executable program.
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
Assembly Language Programming: a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction                            
Assembly Language Programming: a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction                              imul edx will leave the value ______________________________ in the edx register. b)If eax = 0D000000DH, and edx = 50000005H, then the instruction                              idiv dl will leave the value ______________________________ in the eax register. c)If ax = 3BC4H, then the following instructions                              cmp ah, al jg   Label will / will not cause a jump to Label. d)If ax = 3BC4H, then...
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose...
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2 – n + 6.
One of the very practical uses of assembly language programming is its ability to optimize the...
One of the very practical uses of assembly language programming is its ability to optimize the speed and size of computer programs. While programmers do not typically write large-scale applications in assembly language, it is not uncommon to solve a performance bottle neck by replacing code written in a high level language with an assembly language procedure. In this programming project you will be given a C++ program that generates an array of pseudorandom integers and sorts the array using...
Write the code in assembly language to generate two square waves of frequency 1KHZ with 50%...
Write the code in assembly language to generate two square waves of frequency 1KHZ with 50% duty cycle and 10KHZ with 50% duty cycle using P1.0 and P1.1 using timer0 and timer1 simultaneously. Don't use instruction overhead. use timer interrupts to implement the functionality use Xtal=12MHZ
Answer the following in Java programming language Create a Java Program that will import a file...
Answer the following in Java programming language Create a Java Program that will import a file of contacts (contacts.txt) into a database (Just their first name and 10-digit phone number). The database should use the following class to represent each entry: public class contact {    String firstName;    String phoneNum; } Furthermore, your program should have two classes. (1) DatabaseDirectory.java:    This class should declare ArrayList as a private datafield to store objects into the database (theDatabase) with the...
In C Programming Language Write a program to output to a text log file a new...
In C Programming Language Write a program to output to a text log file a new line starting with day time date followed by the message "SUCCESSFUL". Please screenshot the results.
Modified from Chapter 07 Programming Exercise 5 Original Exercise: Rock, Paper, Scissors Modification Programming Exercise 11...
Modified from Chapter 07 Programming Exercise 5 Original Exercise: Rock, Paper, Scissors Modification Programming Exercise 11 in Chapter 6 asked you to design a program that plays the Rock, Paper, Scissors game. In the program, the user enters one of the three strings—"rock", "paper", or "scissors"—at the keyboard. Add input validation (with a case-insensitive comparison) to make sure the user enters one of those strings only. Modifications: Allow the user to input "r", "p", "s" or the full strings "Rock",...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT