辅导案例-CSC 342

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.

Please post directly to me on SLACK completed TEST report, Video, project file 12:00
PM, ready to screen your video.

You should allocate no more than total 12 hours for this TEST.
Please write:
Start Time and date:
End TIME and date:

You can use any resources.
You are not allowed to communicate with fellow students
or other professionals.


THIS IS NOT A TEAM PROJECT!!

You must submit:
1. Report must have OBJECTIVE section, and Table of
Content with links to corresponding sections.
2. Video presentation.
3. Source code and project files you have used. You
must include README file with instructions on how
to run your examples.













Objective of the TEST
The objective of this TEST is to demonstrate your understanding and ability to compare
MIPS instruction set architecture, Intel x86 ISA using Windows MS 32-bit compiler and
LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.
debugger, and a Intel X86_64 bit ISA processor running Linux, 64 bit gcc and gdb, Cortex v7
instruction set architecture on Raspberry Pi platform.
In order to compare the instruction set architectures, You will be testing
and analyzing programs described in Sections 2.1, 2.2, 2.3,2.4, 2.5, 2.6,
2.7, 2.8 of the textbook on all 4 platforms.

1. MIPS, YOU will be running the programs on the MARS MIPS
simulator.
2. Intel X32 ISA, Windows 32-bit compiler, You will be running
programs on Visual Studio and using its debugger.
3. X86_64 ISA, Linux 64-bit platform, you will be running programs
using 64 bit GCC and GDB debugger.
4. Recursive function call on all three platforms. You have to show
stack grows with each recursive call.
YOU must explain how LOCAL, STATIC variables are handled in each case. Pointer
versus arrays, Explain little endian, and big endian where appropriate, demonstrate while
loops , for loops, if-then-else statements on each platform, describe differences and
similarities in each case.
For each example, you have to display disassembly, registers, memory and explain.
You may use examples shown below, or you can create your own examples.

YOU MUST COVER SECTIONS 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8 from the textbook.















LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.

PART I
MIPS examples you may use
In order to run these programs on the MARS simulator, you have to write the programs all
in MIPS assembly and then run the programs.

The first example is in Section 2.2 and is a simple program that is equivalent to running a = b+c
and d = a-e in C.


2-2_1.asm
.data
a: .word 1
b: .word 2
c: .word 3
d: .word 4
e: .word 5
.text
lw $s0, a
lw $s1, b
lw $s2, c
lw $s3, d
lw $s4, e
# a = b + c
add $s0, $s1, $s2
sw $s0, a
# d = a - e
sub $s3, $s0, $s4
sw $s3, d

2-2_2.asm
.data
f: .word 0
g: .word 50
h: .word 40
i: .word 30
j: .word 20
.text
lw $s0, f
lw $s1, g
lw $s2, h
lw $s3, i
lw $s4, j
LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.
# t0 = g+h

add $t0, $s1, $s2
# t1 = i+j
add $t1, $s3, $s4
# f = t0 - t1
sub $s0, $t0, $t1
sw $s0, f


2-3_1.asm
.data
g: .word 0
h: .word 22
A: .word 0-100
size: .word 100
.text
#just to set A[8] to 55
li $t1, 55
la $s3, A
sw $t1, 32($s3)
lw $s1, g
lw $s2, h
#loading the value of A[8] into t0
lw $t0, 32($s3)
add $s1, $s2, $t0
sw $s1, g

2-3_2.asm
.data
h: .word 25
A: .word 0-100
size: .word 100
.text
lw $s2, h
#initializing A[8] to 200
li $t1, 200
la $s3, A
sw $t1, 32($s3)
#A[12] = h + A[8]
lw $t0, 32($s3)
add $t0, $s2, $t0
sw $t0, 48($s3)

LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.
2-5_2.asm
.data
h: .word 20
A: .word 0-400
size: .word 400
.text
la $t1, A
lw $s2, h
#initialzing A[300] to 13
li $t2, 13
sw $t2, 1200($t1)
lw $t0, 1200($t1) add
$t0, $s2, $t0
sw $t0, 1200($t1)

This code essentially performs the C equivalent of A[300] = h + A[300].


2.6
The next example is in section 2.6 and covers several logical operations that can be done in
MIPS. You can use the code
2-6_1.asm
# left shift
li $s0, 9
sll $t2, $s0, 4
# AND
li $t2, 0xdc0
li $t1, 0x3c00
and $t0, $t1, $t2
# OR
or $t0, $t1, $t2
# NOR li
$t3, 0
nor $t0, $t1, $t3
LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.

This code performs the logical operations sll, AND, OR, and NOR. You have to explain
each while executing the program.

For section 2.8
Please write a simple “MAIN” in MIPS assembly that calls “myadd” function and analyze.




PART II.

Examples in x86 Intel on Windows 32-bit
In order to properly run these examples on a Windows 32-bit OS and debug them with
Visual Studio's Debugger, You can write all these examples covered in MIPS in C. The
first example is once again the first example in Section 2.2. Recall that this just does a = b+c
and d = a-e. Here is the code You can write and use

2-2_1.c 1
void main(){
static int a = 1;
static int b = 2;
static int c = 3;
static int d = 4;
static int e = 5;
a = b + c;
d = a - e;
}

2-2_2.c 1
void main(){
static int f = 0;
static int g = 50;
static int h = 40;
static int i = 30;
static int j = 20; 7
f = (g + h) - (i
+ j);
}
LAST NAME: FIRST NAME :
Take home FINAL TEST CSC 342
Due date: July 21, 2020
What to submit: Report, 2min video, and all source code files you have used.




2-3_1.c 1
void main(){
static int g = 0;
static int h = 22;
static int A[100];
A[8] = 55;
g = h + A[8];
}

2-3_2.c 1
void main(){
static int h = 25;
static int A[100];
A[8] = 200;
A[12] = h + A[8];
}

2-5_1.c 1
void main(){
static int a = 0;
static int b = 0;
static int c = 0;
a = b + c;
}


2-6_1.c 1
void main(){
static int s0 = 9;
static int t1 = 0x3c00;
static int t2 = 0xdc0;
static int t3 = 0;
t3 = s0 << 4;
static int t0 = 0;
t0 = t1 & t2;
t0 = t1 | t2;
t0 = ~t1;
}

LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020

2-6_1.asm
# left shift
li $s0, 9
sll $t2, $s0, 4
# AND
li $t2, 0xdc0
li $t1, 0x3c00
and $t0, $t1, $t2
# OR
or $t0, $t1, $t2
# NOR li
$t3, 0
nor $t0, $t1, $t3

This code performs the logical operations sll, AND, OR, and NOR. I will explain each
while executing the program.

2.8 Write and analyze in Debug mode example for “MAIN” calls simple “myadd” function.


PART III.
Repeat all the above for LINUX, gcc, gdb 64 bit. On Intel X86-64 ISA.


PART IV.

Report on recursive computation of greatest common divider algorithm GCD
PLEASE DO NOT INCLUDE TUTORIAL on FACTORIAL IN YOUR REPORT!

Objective:

The objective is to
Demonstrated understanding how recursive function calls allocate memory, how recursive
functions are executed, how control is transferred from one level to the next, how parameters are
transferred form one level to the next.
1. Run and debug a recursive function call on three different platforms: x86 Intel on
Microsoft's Visual Studio, MIPS on MARS Simulator, and on a 64-bit Intel processor
running Linux. Display and explain all frames on stack.
2. Measure and plot the time it takes to compute GCD(a,b) for several values of a,b.
LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020

3. Required part to submit: Repeat tutorial example 1 and 2 to compute GCD(a,b) using
recursive version of EUCLEDEAN algorithm for two integers a>0, b>0. To refresh
GCD(a,b) computation please refer to last 3 pages of this assignment.
4. What to Submit: report, working project files and how to use, 2 min video presentation.

TUTORIAL EXAMPLE of a recursive procedure that calculates the factorial of a number
and its code in both C and MIPS can be found in the textbook and is shown below.

Create and explain Stack Frames for the recursive function call factorial(5)

int factorial (int N)
{
if (N==1)
return 1;
return (N*factorial(N-1));
}
void main()
{
int N_fact=factorial(5);
}


1. Compile and run this program in Debug mode in .NET environment.
For each call level display Frame on stack and write down the address on stack
and value of
• Argument at current level
• local variable ( if any) at current level
• return address at current level
• EIP
• EBP
• ESP
You may use arrow to point a specific location on stack frame.

At the end of calls you should display 5 frames on the stack as shown in FIGURE 1.
LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020




FIGURE 1. All arrows have to show labels to addresses on stack and corresponding
values.

Please explain the return process – specify instructions and arguments used at each nested
level when returning.

2. (Optional) Create a lean version of the factorial() function. Instead of using CALL
instruction ( generated by compiler), create function call using similar to JAL
instruction in MIPS - save the return address and then jump to function. Do not
push and pop unnecessary information on stack ( such as registers ebx, ecx, etc.) on
stack.




LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020

3. Please repeat Section 1 using MIPS instructions and run the program on a
simulator MARS. You can use example described in the section on nested procedure
calls in the textbook.

4. Please repeat Section 1 using GCC, GDB in LINUX environment, and run the
program in command mode using GDB. You can use example described in the
section on nested procedure calls in the textbook.

Sample screenshots for X86, MS Visual Studio in Debug
mode


LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020






Sample screenshots for MIPS, Simulator MARS
environment

LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020





























LAST NAME: FIRST NAME :
Take home TEST CSC 342
Due date: July 21, 2020


Sample screenshots for 64 bit Intel processor, GDB





END TUTORIAL EXAMPLE.






51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468