
Introduction to Computing Systems : from bits and gates to C and beyond
Yale N_ Patt and Sanjay J_ Patel
Source Code Examples from the Text
Figure 5_4: A program that adds twelve integers
Figure 5_6: A program that uses a sentinel-controlled loop
Figure 5_8: A program that counts the occurrences of a character in a file
Figure 6_4: A program to multiply (without a multiply instruction)
Figure 6_5: A program to add 10 integers
Figure 6_7: A program to detect the presence of a 5 in a sequence of 10 memory locations
Figure 6_8: A program to find the first 1 in an LC-2 word
Chapter 7, page 141: An LC-2 assembly language program to multiply by 6
Figure 7_1: An LC-2 assembly language program to count occurrences of a character
Chapter 8, page 161: The basic input service routine
Chapter 8, page 163: The basic output service routine
Chapter 8, page 163: Keyboard echo program
Figure 8_3: The input routine for the LC-2 keyboard
Chapter 9, page 176: Program to amuse the average 4-year old
Figure 9_4: Character input service routine
Figure 9_5: Character output service routine
Chapter 9, page 180: An example illustrating why save/restore of registers is necessary
Figure 9_6: LC-2 TRAP service routine for halting the machine
Figure 9_7: LC-2 TRAP service routine for character input
Figure 9_8: LC-2 TRAP service routine for PUTS
Chapter 10, page 199: Code for POP that handles stack underflow
Chapter 10, page 200: Code for POP that returns a 1 on underflow
Chapter 10, page 200: Code for PUSH that handles overflow
Chapter 10, page 200: Code for PUSH that returns a 1 on overflow
Figure 10_5: The stack protocol
Figure 10_8: The OpAdd algorithm
Figure 10_10: The RangeCheck algorithm
Figure 10_12: The OpMult Algorithm
Figure 10_13: The OpNeg Algorithm
Figure 10_14: ADDITION without paying attention to data types
Figure 10_17: ASCII to binary conversion routine
Figure 10_18: Binary to ASCII conversion routine
Figure 10_20: The calculator's main algorithm
Figure 10_21: The calculator's PushValue routine
Figure 10_22: The calculator's display routine
Figure 10_23: The calculator's POP routine
Figure 10_24: The calculator's PUSH routine
Figure 10_25: The OpClear routine
Figure 11_2: Countdown program in C
Figure 12_1: A C program that echos keyboard input back to output
Figure 12_2: A tedious way to display a message to the output
Figure 12_3: Variable scope in C
Figure 12_6: Computing the area and circumference of a circle
Figure 12_7: The LC-2 translation of C code that performs multiplication
Chapter 12, page 256: The LC-2 translation of C code that performs an assignment
Figure 12_8: Network rate calculation
Figure 12_10: A C program that uses a conditional expression
Figure 12_11: C program that performs simple operations
Figure 12_13: LC-2 translation of program that performs simple operations
Figure 13_2: LC-2 code generated for an if-else statement
Figure 13_4: A program that determines the number of days in a given month
Figure 13_5: A program with error-checking code
Figure 13_6: The calculator program in C
Figure 13_7: A program with a simple while loop
Figure 13_9: LC-2 code generated for a while loop
Figure 13_10: Another program with a simple while loop
Chapter 13, page 288: A program with an infinite loop
Chapter 13, page 290: Examples of programs with for loops
Figure 13_12: LC-2 code generated for a for loop
Figure 13_13: A program that generates a multiplication table
Figure 13_14: A program with a nested for loop
Chapter 13, page 293: A program with a do-while loop
Figure 13_16: The echo program revisited
Chapter 13, page 295: A code segment that uses a break statement
Chapter 13, page 295: A code segment that uses a continue statement
Figure 13_20: A program to calculate pi
Figure 13_24: A program to find primes between 2 and 100
Figure 13_25: A program to that counts the occurences of the word the
Figure 14_1: A program that uses a function to print a banner message
Figure 14_2: A program that calculates factorial
Figure 14_3: A program that converts francs and yen into dollars
Figure 14_7: LC-2 translation of a C function call and return
Figure 14_9: A program with a function to convert lower case letters to uppercase
Figure 14_10: LC-2 translation of the C uppercase program
Figure 15_1: A program with a syntactic error
Figure 15_2: A program with a semantic error
Figure 15_3: A program with a bug involving local variables
Chapter 15, page 340: Example program that uses an error check
Chapter 16, page 348: Recursive routine RunningSum
Chapter 16, page 351: Recursive routine for solving the Towers of Hanoi puzzle
Figure 16_11: Recursive C function to calculate the nth Fibonacci number
Figure 16_13: LC-2 translation of Fibonacci routine
Figure 16_14: Recursive routine that converts integers to ASCII
Figure 17_1: Function swap attempts to swap its two parameters
Figure 17_4: Function new_swap succeeds at swapping its paramters
Figure 17_6: Function idiv returns the integer quotient and remainder
Figure 17_7: Function mod_swap returns a pointer
Chapter 17, page 376: LC-2 translation of an array access
Chapter 17, page 376: LC-2 translation of an array access where the index is a variable
Figure 17_9: A program that calculates the sum of two 10 element vectors
Figure 17_10: A program that determines the number of repeated values in an input sequence
Figure 17_11: Passing an array as a parameter to a function
Figure 17_13: A program that reverses the characters of a string
Figure 17_14: The character counting program in C
Figure 17_15: Insertion sort
Figure 17_16: Common pitfall when using arrays
Figure 18_1: Example of buffered input
Figure 18_2: Example of buffered output
Chapter 18, page 403: File I/O
Chapter 19, page 411: LC-2 translation of a structure access
Figure 19_2: Weather program
Figure 19_4: Function main for the used car database
Figure 19_5: Function to scan through the used car database
Figure 19_6: Function AddEntry for the used car database
Figure 19_8: Function DeleteEntry for the used car database
Figure 19_10: Function to query the database
Figure B_8: C program to convert from lower to uppercase
Figure B_9: LC-2 program to convert from lower to uppercase
Figure B_10: IA-32 program to convert from lower to uppercase
feedback form |
permissions |
international |
locate your campus rep |
request a review copy
Copyright ©2001 The McGraw-Hill Companies.
digital solutions |
publish with us |
customer service |
mhhe home
Any use is subject to the
Terms of Use and Privacy Policy.
McGraw-Hill Higher Education is one of the many fine businesses of the
The McGraw-Hill Companies.