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

  • Assembly Language Using CodeWarrior to create a new project that uses assembly language. Write an assembly...

    Assembly Language Using CodeWarrior to create a new project that uses assembly language. Write an assembly program that turns on the red LED at the beginning. It switches to off 2 seconds later and switches back to on after three more seconds. (That is, it stays on for 2 seconds and off for 3 seconds.) This switching process lasts forever. Use a loop (or nested loops) for each of the 2/3-second delay where the loop body of the inner-most loop...

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

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

  • In C language The project should create a code maker. The computer version of this game...

    In C language The project should create a code maker. The computer version of this game uses digits 0-9 for the code. The feedback may be an array of characters using ‘b’ for black and ‘w’ for white. 1. The program should generate a code i. First, generate random number from 0 to 9. Actually, generate 4 random numbers ii. If any random number is repeated, replace the repeated number iii. Loop step ii until there is no repetition 2....

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

  • Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C co...

    please code using risc-v language and make it as simple as possible Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C code. Assume that n and k are passed in x3 and x4 respectively. Values n and k are initialized to 14 and 14. Assume that result returned in register fl and that double precision numbers are used. After you are done store the result in address: 12(x3). Are you allowed to?...

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