辅导CSE 2421程序语言、讲解c/c++程序、c++编程讲解

- 首页 >> Matlab编程
SU 2021 CSE 2421 LAB 6: Lab 2 Revisited

Assigned: Tuesday, July 13th
Early Due Date: Sunday, July 18th by noon
Due: Monday, July 19th, by 11:30 p.m.

IMPORTANT: READ THESE INSTRUCTIONS AND FOLLOW THEM CAREFULLY.
Objectives:
- combining C language with assembler language programs
- debugging and extending existing C language code
- first x86-64 coding experience
- correctly using different size registers

REMINDERS and GRADING CRITERIA:
This is an individual lab. No partners are permitted.

This is your first attempt as programming in x86-64. Start now! There will be no deadline
extensions for this lab. Plan accordingly.

Every lab requires a Readme file (for this lab, it should be called lab6Readme – use only this
name.). This file must be a simple text file created on stdlinux that includes the following:

Disclaimer:
BY SUBMITTING THIS FILE TO CARMEN, I CERTIFY THAT I STRICTLY ADHERED TO THE
TENURES OF THE OHIO STATE UNIVERSITY’S ACADEMIC INTEGRITY POLICY.
THIS IS THE README FILE FOR LAB 6.
Your name
Total amount of time (effort) it took for you to complete the lab
Short description of any concerns, interesting problems or discoveries encountered, or
comments in general about the contents of the lab
Describe how you used gdb to find work with your C language program if there were
any. Include how you set breakpoints, variables you printed out, what values they had,
what you found.
Describe how you used gdb to find a bug in your x86-64 programs. Include details
with respect to what breakpoints you set what registers you looked at and how you
determined what the bug was.
Did you have to jump between your C language/x86-64 language programs to fix any
bugs?

You should aim to always hand an assignment in on time or early. If you are late, you will receive
75% of your earned points for the designated grade if the assignment is submitted by 11:30 pm the
following day, based on the due date given above. If you are more than 24 hours late, you will
receive a zero for the assignment and your assignment will not be graded at all.

Any lab submitted that does not compile/make – without errors or warnings - and run without seg
faults or exhibit any other major OS errors/faults WILL RECEIVE AN AUTOMATIC GRADE OF
ZERO. No exceptions will be made for this rule - to achieve even a single point on a lab, your code
must minimally build (compile to an executable) on stdlinux and execute on stdlinux without hanging or
crashing, using the following command: make. A seg fault is considered crashing.
LAB DESCRIPTION

1. You will be rewriting lab2 from earlier in the semester. Required file names: bit_encode.c (this file
will be supplied on Piazza no later than 7/14/21 @4PM), create_key.s, rotate_right.s, rotate_left.s,
C2_SMag.s, Makefile. The file create_key.s will contain only a function called create_key(); the file
rotate_right.s will contain only a function called rotate_right(); and the file rotate_left.s will contain
only a function called rotate_left().
2. There is on difference between this lab and lab2: the output will be printing two hex digits
representing values in Sign Magnitude rather than in 2’s complement. Remember binary
representations for positive values are the same no matter the representation. Only negative values
change the binary representation.
3. The function unsigned int create_key() is an x86-64 function that must:
a. prompt for (using the printf() function) and
b. read in each of the 4 digits of the key (using the getchar() function) and
c. return the 8-bit key to the calling function.
d. You must create the 8-bit key from those 4 digits using ONLY the bitwise OR
instruction or ONLY the bitwise OR instruction and a shift instruction. For
example, if the user specifies 0110, then your internal key must be 0110 0110.
Using any other operations to create the key will result in a 50-point reduction in
your score for this lab.
4. The function unsigned_char rotate_right(unsigned char x) and the function
unsigned char rotate_left(unsigned char x) are also x86-64 functions that must be
passed a single hexadecimal value and return to the calling function that value
rotated 1 position right or left, respectively.
5. C2_SMag.s should contain a function unsigned char C2_SMag(unsigned char c)
that converts a two’s complement binary value to Signed Magnitude.
6. I will supply a bit_encode.c file from with main() from which the other functions will be called.
7. The output of your program should be exactly as described in lab 2 for bit_encode1.
8. You must create a Makefile where all will have 2 targets: bit_encode and lab6.zip.


REQUIREMENTS
1. You may only use x86-64 constructs that we have discussed in class, you can find in the slides,
or you can find in the sample x86-64 programs posted on Piazza. Any other x86-64 constructs
will invalidate your lab submission.
2. You must use correct stack frame procedures and conventions.
3. No values in the x86-64 functions of your program may store values on the stack other than with
push/pop.
4. You may declare variables in the main() function of your program that are stored on the stack.
5. You must use all (needful) x86-64 directives.
6. You must use the correct suffix for all data types (instructions and register sizes).
7. You must use 4-byte registers for the return value from getchar(), all create_key() computations
and the value create_key returns to main()
8. You must use 1-byte registers for all rotate_left(), rotate_right(), and C2_SMag() computations
and parameter passing.
9. You must use correct caller/callee saved register conventions.
10. You must call printf() once to prompt for the 4-bit key and getchar() for each bit of the key (i.e.,
4 times) within your assembler program. You can do this with 4 separate calls to getchar() or
you can get some practice at creating a loop. These C-library function calls MUST be made
within your create_key() x86-64 function.
11. You must include the certification header in your .s files
12. You must comment your code!

站长地图