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.
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.
Write a MIPS Assembly language program to request a file name from the user, open the...
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write out the contents to the console. This is what I have so far: .data    fileName:   .space 100    prompt1:   .asciiz "Enter the file name: "    prompt2:    .asciiz ""    prompt3:   .asciiz "\n"    buffer:    .space 4096 .text    main:        #        li $v0, 4        la $a0, prompt1       ...
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",...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a program in PERL with NO SUBROUTINES to allow the user to pick a type of arithmetic problem to study. An option of 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only and 5 means random mixture of all these types. (Computer- Assisted Instruction) The use of computers in education is referred to as...
Programming assignment (75 pts): The Lab 1 development assignment was largely an exercise in completing an...
Programming assignment (75 pts): The Lab 1 development assignment was largely an exercise in completing an already started implementation. The Lab 2 development assignment will call on you to implement a program from scratch. It’s an exercise in learning more about Java basics, core Java Classes and Class/ method-level modularity. Implement a ‘runnable’ Class called “NumericAnalyzer”. Here’s the functional behavior that must be implemented. NumericAnalyzer will accept a list of 1 or more numbers as command line arguments. These numeric...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT