Last Updated: 2022-03-22 Tue 17:18

CSCI 2021 Lab07: Bonus Assembly Coding

CODE DISTRIBUTION: lab07-bonus-code.zip

DEMO VIDEO: Week 9 Lecture Videos: Mon 3/21/2022

CHANGELOG: None

1 Rationale

This lab revisits the functions of Lab07 for additional practice. The functions have changed prototypes which requires different techniques for handling the structs involved.

// Lab07 Original 
int set_coins(int cents, coins_t *coins); // set fields in a struct, return an int
int total_coins(coins_t coins);           // accept packed struct argument

// LAB07 Bonus
coins_t set_coinsb(int cents);            // return a packed struct in eax
int total_coinsb(coins_t *coins);         // accept a struct pointer

Solving this lab will earn an additional Engagement Point for those want and provide a useful review of assembly coding techniques in preparation for Exam 2.

Associated Reading / Preparation

  • Bryant and O'Hallaron: Ch 3.1-3.7 on assembly code instructions in x86-64.
  • Any overview guide to x86-64 assembly instructions such as Brown University's x64 Cheat Sheet
  • To more easily debug assembly, it is useful to be able to run a debugger like gdb on the assembly code. Examine the CSCI 2021 Quick Guide to gdb: The GNU Debugger which contains information specific to assembly as such as how to display the register contents.

Grading Policy

Credit for this Lab is earned by completing the exercises here and submitting a Zip of the work to Gradescope. Students are responsible to check that the results produced locally via make test are reflected on Gradescope after submitting their completed Zip. Successful completion earns 1 Engagement Point.

Lab Exercises are open resource/open collaboration and students are encouraged to coopearte on labs. Students may submit work as groups of up to 5 to Gradescope: one person submits then adds the names of their group members to the submission.

See the full policies in the course syllabus.

2 Codepack

The codepack for the HW contains the following files:

File   Description
QUESTIONS.txt EDIT Questions to answer: fill in the multiple choice selections in this file.
coins_funcs_asmb.s EDIT Incomplete Assembly functions, fill in remaining code
coins_mainb.c Provided main() function
coinsb.h Provided C header
coins_funcsb.c Provided C functions to be implemented in assembly, code here can be used to test incrementally
Makefile Build Enables make test and make zip

3 set_coinsb and total_coinsb Assembly Functions

These two functions have a C version provided for them and a template assembly file. Complete them and pass the provided automated tests to finish the lab.

NOTE: There are no Questions or QUESTIONS.txt file associated with this bonus lab.

4 Submission

Follow the instructions at the end of Lab01 if you need a refresher on how to upload your completed lab zip to Gradescope.


Author: Chris Kauffman (kauffman@umn.edu)
Date: 2022-03-22 Tue 17:18