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.
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 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
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       ...
JAVA PROGRAMMING LANGUAGE Suppose a library is processing an input file containing the titles of books...
JAVA PROGRAMMING LANGUAGE Suppose a library is processing an input file containing the titles of books in order to identify duplicates. Write a program that reads all of the titles from an input file called bookTitles.inp and writes them to an output file called duplicateTitles.out. When complete, the output file should contain all titles that are duplicated in the input file. Note that the duplicate titles should be written once, even though the input file may contain same titles multiple...
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...
Using a programming language of your choice: 1) generate a range of wavelengths, 2) compute corresponding...
Using a programming language of your choice: 1) generate a range of wavelengths, 2) compute corresponding monochromatic blackbody intensity using a) Planck function, b) Rayleigh-Jeans simplification, and c) Wien simplification, and 3) plot the three resulting spectra (i.e., a diagram that shows how B(λ) changes with λ). Using this figure explain the phenomenon of “ultraviolet catastrophe”. Please include the code (not only figure) in your answer.
Translate the following pseudocode to MIPS assembly programming language cout << “\n Please input a number...
Translate the following pseudocode to MIPS assembly programming language cout << “\n Please input a number for $s0”; cin >> $s0; cout << “\n Please input a number for $s1”; cin >> $s1; cout << “\n Please input a number for $s2”; cin >> $s2; $t0 = $s0 / 8 - 2 * $s1 + $s2; cout << “\n the Value of the expression “$s0 / 8 - 2 * $s1 + $s2” is ”; cout >> $t0; return;
How would I code the following in assembly language? Use the Keil programming environment to code...
How would I code the following in assembly language? Use the Keil programming environment to code the C8051F330 SiLabs 8051 micro controller. All the documentation is available on efundi. The program shall be done in assembler and you shall use the DJNZ instruction to generate a delay time to flash the LED. The LED shall flash in the following sequence: 1. On for 50mS, 2. Off for 400mS, 3. On for 50mS, 4. Off for 1.5S, 5. Repeat the sequence...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT