CSE 378 Winter 2004
Examples from Class 1/12/2004

  1. test.c
    A small program written in C--, the language compiled by the Cebollita compiler. The variables declared at the top, outside of all methods, are called "global variables" in C (and C--). The scope of the variable names is what is global -- it's possible to refer to those variables from C-- code in other files. The thing that's important to us is the lifetime of the memory allocated to hold the values for those variables. These (global) variables have lifetime equivalent to that of the process (an instance of the program in execution) -- they're created when the program is loaded in memory (process creation time), and destroyed only when the process terminates.

  2. test.s
    This is the assembly language code that the Cebollita compiler produced for the test.c file. (I've added a couple of comments by hand.) This file can be assembled (turned into machine language instructions, plus a bit more) using the Cebollita assembler.

  3. executable-dump.txt
    I assembled test.s, then "linked" it. (We'll talk about linking later this week.) The result is an "executable image" - file test.exe. test.exe is a file full of machine instructions, meaning its a file full of 32-bit numbers. It (a) is not characters, so can't be printed, and (b) doesn't contain any information about the original test.c program, meaning the convenient variable names that program used are not any part of the final executable (since the hardware doesn't deal in names, just addresses).

    This "dump" was produced by a program that reads the binary instructions in a .exe and "disassembles" them back into assembly instructions. Because there are no variable names in the .exe file, don't expect to find them here. But, what you can find, by comparing with test.s, is what the offsets are in the static data area for the variables defined in the original (.c) program and filtered through the assmebly language (.s) version.