Objective To learnhow touse loops ifstatement to representva

Objective: To learnhow touse loops, if-statement, to representvariables and array in the stack, to load and store data from and into the stack and to use gdb.
Requirements:
1.Translate the following C code into assembly language program. All variables dare to be allocated space on the stack without using macros. In the program you aretouse only registers %o0 and %o1. All variables are to be accessed from the stacksuch that at any time during program execution the latest values of the variables are located on the stack. You are to execute the statements in the order given. Do not try to optimize your code(i.e. do not remove nops).
char ca;
short sb;
int ic;
char cd;
short se;
int ig;
ca = 17;
cd = ca + 23
ic = -63 + ca
ig = ic + cd
sb = ic / ca
se = cd *sb + ic
Note:
-Run your programs using gdb to verify value of updated variables after each calculation
-Use correct versions of load and store commands for data of different sizes.
-Use correct versions of examine command of gdb to verify results: (ex: x/db for printing a byte memory variable in signed decimal form)
2.Write a program to initialize an array int ary[6] = {2, 5, -3, -4, 0, 6}and then to find the largest element by searching the array(i.e. use a loop).
Note:-Run your program using gdb to verify array values at each array subscript.
-Do not optimize your code (i.e. do not remove nops)
Note:-Use nano or vim to create your file: nano lastname1.s
-To create your executablefile type:gcc lastname1.s –o lastname1; to run GDB type: gdb lastname1
-DO NOT use macros (begin_main, end_main, var, local_var) given in text book. You should calculate offsets for stack variables manually.
-DO NOT try to optimize your code (i.e. do not remove nops

Solution

The code itself is wrong in c-language. Please check the code once and upload again for correct answer.

Objective: To learnhow touse loops, if-statement, to representvariables and array in the stack, to load and store data from and into the stack and to use gdb. R

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site