[go: up one dir, main page]

0% found this document useful (0 votes)
10 views3 pages

Midterm - Assembly

The document outlines the rules and tasks for the Midterm exam in CSC 521-001: Advanced Computer Architecture for Spring 2025. Students are prohibited from using outside resources, discussing with peers, or utilizing social media and AI tools. The exam consists of converting Python code to x86-64 Assembly and writing assembly programs to perform specific tasks.

Uploaded by

Braincain007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Midterm - Assembly

The document outlines the rules and tasks for the Midterm exam in CSC 521-001: Advanced Computer Architecture for Spring 2025. Students are prohibited from using outside resources, discussing with peers, or utilizing social media and AI tools. The exam consists of converting Python code to x86-64 Assembly and writing assembly programs to perform specific tasks.

Uploaded by

Braincain007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSC 521-001: Advanced Computer Architecture Spring 2025

Midterm - Assembly Grade: /50

For this part of the exam YOU MAY NOT:

• use any outside resources besides notes/programs generated within the class.

• discuss with a peer within or outside the class in any way.

• use any social media apps or messaging platforms (WhatsApp, Discord, etc...).

• use any LLMS or AI to write your code (or in any other way).

• use a device other than your computer.

• share your code with a peer in any way.

If for any reason you break any of these rules you will fail both parts of the exam.

For the following make sure to use techniques taught in class. Also, make sure to
submit all only your .asm files only.

1. (15 pts) Convert the provided Python code to x86-64 Assembly using NASM
(called one.asm):
from sys import argv

def calculateLetter ( grade ) :


if ( grade >= 90) :
return " A "
elif ( grade >= 80) :
return " B "
elif ( grade >= 70) :
return " C "
elif ( grade >= 60) :
return " D "
else :
return " F "

print ( calculateLetter ( int ( argv [1]) ) ) # prints -> D


print ( calculateLetter ( int ( argv [2]) ) ) # prints -> A
print ( calculateLetter ( int ( argv [3]) ) ) # prints -> C

# bash run . sh one 60 92 72

1
2. (15 pts) Convert the provided Python code to x86-64 Assembly using NASM
(called two.asm):
# make sure to not hardcode the offsets
# handle the values in the array dynamically
numbers = [50 , 65 , 2555 , -588 , 0 , 950]

def update ( array ) :


for i in range ( len ( array ) ) :
array [ i ] += array [ i ]
return array

numbers = update ( numbers )

for number in numbers :


print ( number ) # 100 , 130 , 5110 , -1176 , 0 , 1900

3. (10 pts) Write an assembly program (called three.asm) that swaps the values
of two 32-bit integers stored in memory, using only the stack and registers. Do
not use a direct MOV such as MOV [a], [b].

• Use only the RAX register.


– Hint: You may need to use the push/pop idea when trying to print.
• Make sure to “print ret” after every step.

; Example Output
1234
5678
5678
1234

2
4. (10 pts) Write an assembly program (called four.asm) that counts down from
15 to 0, printing all values multiplied by 4.

• Use only the RAX register.


– Hint: You may need to use the push/pop idea when trying to print.
• Do not use MUL/IMUL instructions
• Make sure to “print ret” after every iteration.

; Example Output
60
56
52
48
44
40
36
32
28
24
20
16
12
8
4
0

You might also like