Description
Welcome to CDA 4205L Lab #4! This is the second portion of the ISA lab. The goal of this lab is for you to
understand how to use the pre-processed assembly code created in part 1 and convert it to machine code.
This step will finalize the conversion of the initial .asm file into machine code.
Prelab
An assembler is a program that converts low-level assembly code into machine code which can be
understood by the target processor. It is one step in a larger toolchain that begins with a compiler and
ends with a linker and object file generation. Now, as the assembly code has been preprocessed, the next
step is to output the machine code.
The formatted assembly code will be provided to you as a .txt file. You will need to create a function that
correctly converts this code into machine code based for each instruction type (Use ‘rv32im_isa.csv’ as a
reference for better understanding).
Lab
1. Use the online version of JupyterLab: https://jupyter.org/try-jupyter/lab/
2. Download ‘Lab4_assembler_design.ipynb’ file from Canvas (Files > Labs > Lab 4) and open it in
JupyterLab.
3. Download the ‘example1_out1.txt’, ‘example2_out1.txt’, and ‘rv32im_isa.csv’ files from Canvas
(Files > Labs > Lab 4) and upload them in the same directory as your
‘Lab4_assembler_design.ipynb’ in JupyterLab.
4. Complete Tasks 1 and 2 as described in the ‘Lab4_assembler_design.ipynb’ file.
For your reference, here are example outputs from the two tasks using ‘example1_out1.txt’:
Task 1 Output: Task 2 Output:
T1-2: Take screenshots of outputs from Tasks 1 and 2 using “example2_out1.txt” and include
those in your report.
Assembly Instructions:
00000000000001001000001110000011
00000000101000000000010100010011
00000001010000000000010110010011
00000000101101010101001101100011
00000000000001011000011000110011
00000000000000000110000011101111
00000000000001010000011000110011
00000000000000000010000011101111
00000000101001001010000000100011
Saved machine code to: example1_out1_bin.bin
5. Answer the following questions:
In-class work – Complete T1, show it to the TA for review and submit it on Canvas before the lab session
ends. Submit your in-class work as a Word document (.docx) format.
Final Report – Submit your report pdf with answers to all questions and screenshots. Also, submit the
final ‘.ipynb’ file and the output ‘.bin’ file for example2 only. Submit .zip file, one per group.
T3: In your own words, explain how the ‘rv32im_isa.csv’ file is used to determine how each
instruction is converted to binary.
T4: In your own words, explain the purpose of the ‘get_2c_binary function.
T6: How many different instruction formats did you need to account for in your code? What
did the different formats have in common? How did this impact your code?
T5: What was the purpose of preprocessing the assembly code in the last lab?

