Computer Systems Org I - Prof. Grishman

Lecture 24 - Nov. 29, 2004

Notes on assignment #6 (interpreter project)

1. Warning messages regarding type conversions can be avoided by having explicit cast operators, of the form (type), just as in Java.  In particular, you can cast the result of malloc to the appropriate type of pointer:
    char* p;
    p = (char*) malloc(10);

2. Dereferencing invalid pointers can lead to segmentation errors, which can be hard to track down.  The Gnu debugger, gdb, can help.  Download it as part of Cygwin (in the development section of programs).  Then to run gdb,
    gcc -g myprogram.c  (compiles program with debug information for gdb)
    gdb a.exe
    (gdb) run  (runs the program until it crashes or ends)
    (gdb) where  (gives a traceback)
    (gdb) print var   (prints any local variable)
    (gdb) quit
More information on gdb is available on-line... is an excellent introduction to gdb is more comprehensive.

Computer logic (P&P chapter 3)

The basic building block for all computer logic is the electrically-controlled switch.  A switch (such as a light switch) can open or close an electrical circuit (P&P Figure 3.1).  An electically-controlled switch can be opened or closed by an electrical input.  Different technologies have been used to build such switches:
relays (mechanical switches) -- simple but slow (switch in milliseconds)
vacuum tubes (1945-1960) -- much faster (microseconds) but take a lot of power
transistors (1960 - ) -- faster and lower power (P&P section 3.1)
integrated circuits (1970 - ) -- put more and more transistors on a single silicon chip (now, millions)

Switches can be used to build gates which implement the basic logic functions (P&P section 3.2)