Program Translation Process
Advanced I/O
Abstract Data Types
Binary Operations
Email from Teddy Davies
100

What ROM stands for in this class

What is Relocatable Object Module?

100

The name of the process that your code calls so that it can interact with files

What is the Operating System Kernel?

100

The definition of abstraction

What is a high level view, ignoring the gritty low level details?

100

0101 & 1001

What is 0001?

100

The file size in bytes of a text file that has 300 characters in it

What is 300?

200

The input and output of the assembler

What is assembly code, and ROM?

200

A non-negative integer that is associated with a file that is currently opened

What is a File Descriptor?

200

The things defined in the header file of an ADT

The purpose the header file serves in the program translation process

What are public functions? 

What is to allow the driver code to compile but not link?

200

0110 in decimal,

and (0110 << 1) in decimal

What are 6, and 12?

200

The definition of system calls

What is the interface between your process and the OS?

300

The purpose of the semantic analyzer, its inputs, and its outputs

What is type checking and implicit casting?

What is a syntax tree, and symbol table?

What is a semantically correct syntax tree?

300

The reason why calling write() in your program doesn't always immediately write to hardware

What is buffering of output by the Operating System Kernel?

300

The interface of a hypothetical Car Abstract Data Type

What is start(), accelerate(), brake(), steer(), getSpeed(), and getFuelLevel()?

300

Show an example of how to flip a number to negative in two's complement.

Flip all of the bits and add 1. 

e.x., 0110 becomes 1010

300

Write C code that has a memory leak

Anything that loses a pointer to an allocated heap block

400

The output of running the preprocessor on this file:

#define name

#ifdef name

some good text here

#else

some bad text here

#endif

What is "some good text here"?

400

The three basic modes for opening a file and what they do, and what adding "b" does

  • r: opens the file for reading, and the file must exist
  • w: opens the file for writing, creates file if it doesn't exit, overwrites it if it already exists, deleting the old contents
  • a: open the file for appending, write text wherever the file ended, creates a file if it doesn't exist
  • b: does binary and can be added to any of the options, rb, wb, ab
400

How is the structure of the data in the ADT hidden from the driver code?

The header file does not contain the definition of the structure of the data.

400

Show the c code to turn on the 4th bit of an integer, x. Assume that x is already defined.

x |= 1 << 3;

400

What this code prints:

int f() { return 12; }

int g() { return 42; }

int main() {

    int x = f(), g();

    printf("x is %d\n", x);

}

What is "x is 12"?

500

The overall process of program translation, starting from C program, and ending with Code running in Memory

What is

  • C Program -> Compiler -> Assembly Language
  • Assembly Language -> Assembler -> Object Program (.o file) (ML)
  • Object Program(s) + [Libraries] -> Linker -> Executable Load Module (ML)
  • Executable Load Module -> Loader -> Code Running in Memory
500

Come up with a real world analogy that illustrates why buffering speeds up I/O

Anything that illustrates filling up a buffer that can hold many things, and a long travel time between the process and the file.

500

Draw a picture showing the files (driver.c, ADT.h, ADT.c), showing what happens at the preprocessor step, compiler step, and linker step. Show inputs and outputs of each step in terms of the files.

  • Preprocessor combines driver.c and adt.h into one file, file1.c.
  • Preprocessor combines ADT.h and ADT.c into one file, file2.c.
  • file1.c gets compiled into file1.o.
  • file2.c gets compiled into file2.o.
  • file1.o and file2.o get linked into the executable
500

Draw the truth table for AND, OR, and XOR

AND is 1 when both inputs are 1, otherwise 0.

OR is 0 when both inputs are 0, otherwise 1.

XOR is 1 when the inputs are different, otherwise 0.

500

Write a struct called packed_data that stores the following values as compactly as possible:

- 3 boolean flags f1, f2, f3 (3 bits)

- an unsigned integer "type", in the range 0 - 255 (8 bits)

- and an unsigned integer "index", in the range 0 - 10,000 (17 bits)

struct packed_data {

    unsigned int : 4; // unnamed variable indicates unused bits

    unsigned int f1 : 1;

    unsigned int f2 : 1;

    unsigned int f3 : 1;

    unsigned int type : 8;

    unsigned int index : 17;

};