Question

Step 1. Write a program in assembly language (using macros) to print out the following messages...

Step 1. Write a program in assembly language (using macros) to print out the following messages on the screen [20 marks]:

Hello, programmers! Welcome to the world of, Linux assembly programming!

Step 2. Write a C function to passed two numbers to the function and calculate the sum of all the numbers between them (both inclusive). [50 marks]

a. Make a version with for loop
b. Make a version with while loop

c. Make a version with do.. while loop d. Make a version with goto loop

Tip : Try to use the same number of variables and almost the same logic in all the four loops

To do:
Using the command

$gcc -O1 -S filename.c

Will generate the assembly version of the loop. Now you need to analyze and compare them. Are these codes same or different? If different, identify the differences

Step 3. Optimize the code for summing an array of 50 elements using loop unrolling. Run and generate the graph of performance improvement. [30 marks]

Submission:

A. Make a word document with only the assembly code generated from the programs

B. Compare and contrast different versions of loops written in assembly for Step 2 Comparison should be done based on:
a. Number of registers used
b. Number of jumps (iterations)

c. Total number of operations
C. Submit the word document to the Open Learning Faculty Member for grading.

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

1)

; A macro with two parameters
; Implements the write system call
%macro write_string 2
mov eax, 4
mov ebx, 1
mov ecx, %1
mov edx, %2
int 80h
%endmacro

section   .text
global _start ;must be declared for using gcc
  
_start: ;tell linker entry point
write_string msg1, len1   
write_string msg2, len2
write_string msg3, len3
  
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel

section   .data
msg1 db   'Hello, programmers!',0xA,0xD   
len1 equ $ - msg1          

msg2 db 'Welcome to the world of,', 0xA,0xD
len2 equ $- msg2

msg3 db 'Linux assembly programming! '
len3 equ $- msg3

Note: Brother According to HomeworkLib's policy we are only allowed to answer first part if there are many. So, I request you to post other part as separate posts

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Step 1. Write a program in assembly language (using macros) to print out the following messages...
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
  • Step 2. Write a C function to passed two numbers to the function and calculate the...

    Step 2. Write a C function to passed two numbers to the function and calculate the sum of all the numbers between them (both inclusive). [50 marks] a. Make a version with for loop b. Make a version with while loop c. Make a version with do.. while loop d. Make a version with goto loop Tip : Try to use the same number of variables and almost the same logic in all the four loops To do: Using the...

  • Write a program that prints the following console output using the while-loop and for-loop D not...

    Write a program that prints the following console output using the while-loop and for-loop D not use if-else, setw) and ciomanip> for this problem. .Before you open a Word file to copy the screen shots, tell Dr. Jo. Save the Word file as your name in your flash drive. .Take a screen-shot the code and paste to the Word file. (5 points). Take a screen-shots of the console output and paste to the Word file. (5 points) Save the Word...

  • Using Python Version 1. Write a program that uses a "while" loop to print the first...

    Using Python Version 1. Write a program that uses a "while" loop to print the first 10 positive integers and to compute their sum. Print the sum after it is computed. Do the same with a "for" loop. Version 2. Write a program to approximate the square root of a number. Recall that the square root of a number x is a number r such that r*r = x. Newton discovered that if one initial estimate of r is z...

  • Write a PIC18Fxx2 assembly program that takes the variable A and save into B in inverted the 110010102, then the program finishes with B 010100112-The 1. bit order. For example, if A variable A s...

    Write a PIC18Fxx2 assembly program that takes the variable A and save into B in inverted the 110010102, then the program finishes with B 010100112-The 1. bit order. For example, if A variable A shall preserve the original value at the end of the program execution. The program shall be implemented using any of the loop and shift techniques discussed in class. 2. Write a PIC18Fxx2 assembly program that makes the calculus of the first eigth (8) terms of the...

  • Fill in the blank using the word from below 1   A common way to detect whether...

    Fill in the blank using the word from below 1   A common way to detect whether a value is even or odd is to use the ___________ operation to test if the least significant bit is set. 2    In order to implement branching in an Assembly program, you must use ___________ to identify blocks of code. 3    The ___________ instruction will move execution to a different section of code regardless of any conditions. 4    Before any conditional tests can be...

  • What to do Write a C program that computes Pi with the approximation algorithm that I...

    What to do Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways: The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get_pi_for(void); The second version will break out of a while loop depending on whether a pair of...

  • Please write the code in assembly language which can run in HLA. Thank you very much!!...

    Please write the code in assembly language which can run in HLA. Thank you very much!! -So we need to write the code in assembly language in Notepad++, end with .hla and run it in CMD. - This project is about writing a program to read numbers, counts the items read, calculates the total, the maximum and minimum of the numbers. -The program stops when a 0 is entered. Zero will not be part of the data. -work with integers,...

  • Write an assembly language program to do the following, and run it and test it on...

    Write an assembly language program to do the following, and run it and test it on the lab simulator: Read in integers until a zero is read in. Keep a total of both the quantity and the sum of the negative integers and the positive integers. Once a zero is read in (signifying the end of the input) then: • If there were more positive than negative integers, or an equal number, print out a 0 and the sum of...

  • WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data...

    WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data prompt: .asciiz "\nMaximum number is : " prompt1: .asciiz "\nMinimum number is : " prompt2: .asciiz "\nRange of the array is : " size: .word 10 #load array array: .word 23, -12, 45, -32, 52, -72, 8, 13,22,876 .text #load address of array and size la $s4,array #load address of A lw $t0,size #load i to t0 jal getArrayRange li $v0, 4    la...

  • Write a Java program with a single-dimension array that holds 11 integer numbers and sort the...

    Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish. algorithm (either flowchart or pseudocode) that you will use to write the program Step 1. Create an Place the algorithm in a Word document. 6. Ste the Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1....

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