Lab 3 - Assembly Implementation of C

Name ID
Mo'men Ahmed 2200768
John Sameh 2200414

1. Introduction & Overview

This laboratory exercise involves compiling a C application to analyze the resulting compiler-generated assembly code and the linker-generated map file.

2. Learning Outcomes

3. Requirements

This lab utilizes the following environment:

4. Procedure

  1. Open the CinAsmLab project workspace.

  2. Ensure that the compiler is configured to generate assembly listings (Options -> Listing -> C Compiler Listing) and is set to maximum optimization (Options -> C/C++ -> Optimization Level 3 (-O3)).

  3. Compile the source code, then review the output listing and map files to answer the questions below.


4.1 Assembly Code Listing

4.1.1 Evaluating the INIT_LIST Function

4.1.2 Evaluating the FIND_IN_LIST Function


4.2 Map File

4.2.1 Default Program

Symbol Starting Address Size
$Super$$main 0x0000_0851 26
list_init 0x0000_0809 46
list_find 0x0000_0837 26
list 0x2000_0100 40
offset 0x2000_00d8 40
Configuration Code data RO Data RW Data ZI Data Debug
non-const offset 108 10 0 40 40 1535

4.2.2 Specifying C Data as Read-Only to Save RAM

Change the C source code to declare the offset array as const, then rebuild.

Symbol Starting Address Size
$Super$$main 0x0000_0851 26
list_init 0x0000_0809 46
list_find 0x0000_0837 26
list 0x2000_00d8 40
offset 0x0000_0a84 40
Configuration Code data RO Data RW Data ZI Data Debug
const offset 108 10 40 0 40 1539