Unit One Objectives CSCI 223 Computer Organization & Assembly Language Tobin Maginnis Updated: 28-Aug-08 Computer Systems: A Programmer's Perspective - Bryant & O'Hallaron 1)Contrast "architecture," "implementation," and "realization" and give an example. a)Architecture is the general specification of an object or process that identifies a few salient qualities. The architecture of a sports car is two passenger, light weight, big engine, roll bar, and the color red; while the architecture of a SUV is 5-8 passengers, fold down seating, high ground clearance, and the colors white or black. b)Implementation is usually thought to be the realization, but it is a more detailed blueprint of the architecture such as exact vehicle weight-to-power ratio, number of drive wheels, exact ground clearance, and so on. c)Realizations are the physical instances of an implementation such as a Corvette, Ferrari, Explorer, or Yukon. 2)Explain the difference between a binary "0" and an ASCII "0". a)Binary refers to the arithmetic value contained in a memory location; however, these values must be interpreted to have meaning. b)ASCII refers to the interpretation of the arithmetic value as an output "code" to represent an alpha-numeric character on a display. These codes are interpreted by hardware. 3)Contrast, and give examples of, open source software, free software, and Free open source software (FOSS). a)Many times these terms are used interchangeably, but proprietary software vendors use these terms to given the impression their software is FOSS-like. b)Just because the source code can be viewed does not mean that it can be redistributed. Microsoft lets some customers see the source code to Windows and they call it "open source," but the customer must also sign a non-disclosure agreement (NDA) stating that they will not share their new knowledge with others. HP provides "Open VMS" with license agreement that also restricts the software use. c)Just because the software is free does not mean other restrictions on its use do not exist. Internet Explorer and Netscape are free, but you are not allowed to see the source code. d)Thus, the term FOSS specifies the complete software requirement with a capital F for Freedom plus the idea of open source. http://opensource.org/ http://www.microsoft.com/opensource/default.mspx http://h71000.www7.hp.com/ http://en.wikipedia.org/wiki/OpenVMS http://en.wikipedia.org/wiki/Netscape_(web_browser) 4)Define GNU, GPL, and FSF and explain their roles in FOSS. http://www.gnu.org/ http://www.fsf.org/ 5)Contrast cooking versus computer organization. a)Move things from storage (kitchen cabinet) to a working space (kitchen counter top). b)Move items between long-term storage (pantry) and short-term storage (kitchen cabinet). c)Use specialized ALUs (cutting board as opposed to counter top) to perform methods or subroutines (chop onions, celery, mushrooms, etc.) d)Execute a series of command in sequential fashion (recipe) e)Have specific inputs and outputs (groceries, meal) 6)Contrast the commands "gcc file.c," "gcc file.s," "gcc -c -o file.o file.s," "gcc -S file.c -o file.s," and "as -a file.s > file.lst" 7)Define "PATH," explain its significance, and give an example. 8)Contrast the following phases: preprocessing, compilation, assembly, and linking. a)Preprocessing - Build a new source file using the original, but without spacing or comments; process all #include directives, evaluate conditionals and remove "false" code, expand other "#" macros. b)Compilation - Translate source expression-by-expression "()" and statement-by-statement ";" and block-by-block "{}" and function-by- function "xxx(){}". Replace each of these with the equivalent assembly language instructions. c)Assembly - Translate each instruction into an operation code and zero or more operands. Must make at least two passes since some instructions refer to forward labels yet to be resolved. d)Linking - Combine the newly assembled object file with specified library files and the OS run-time object file thereby creating the executable module. 9)Give examples and contrast compile-time, assembly-time, link-time, and run-time errors. a)Compile-time are pre-processor and syntax errors such as "Cannot find /usr/sys/include/math.h" or "Missing block termination" b)Assembly-time errors are syntax such as "Memory reference 'doit' not found" or "Illegal register size." If the compiler generates the assembly, there is only a remote possibility of an assembler-time error. c)Link-time - A specified module cannot be located. One of the most common class of errors. Programmer specifies a library and includes the ".h" file to define the application program interface (API), but the library executable image cannot be found. d)Run-time - The program fails as it executes. Examples include "Segmentation error core dumped" or "Divide by zero, program terminated." 10)Using PMS notation, draw a computer system and explain how the switch is managed. 11)Describe a bus and concept of "word size." a)Bus acts as a switch directing parallel bits among system components. b)The number of bits per bus transfer is one-way and fixed in size called the word size. However, the bus word size changes from realization to realization even for the same implementation. c)In recent Intel Architecture (IA) implementation/realizations, the bus interface unit automatically performs a burst of transfers to fill its cach line. Moreover the BIU calculates a "look-ahead" read of the adjacent cache-line when a a memory read (fill) is requested. This means that the size of the cache-line appears larger than its physical size. In a Core 2 duo processor family, the cache-line "appears" to be about 256-512 bytes in size. 12)Contrast controller, adapter, & motherboard. 13)Contrast memory, DRAM, short, int, float, long, and double. Explain the design tradeoff of a von Neumann computer architecture. 14)Describe CPU, register, PC, register file, and ALU. 15)Define load, store, three operand add (update), I/O read, I/O write, & jump. 16)Describe the "one-way" nature of data flow among system components. 17)Describe the memory hierarchy in terms of latency, cost, and components. 18)Contrast a program versus a process. a)A program is the code created by the application programmer and the program performs a sequence of actions directed by its instructions. b)A process is the behavior of a program augmented by the linker- loader added run-time environment, dynamic shared libraries routines called by the user program, the behavior of invoked kernel service calls, and interaction with the environment through the assistance of device drivers. c)The program describes the high-level operation of the application while the process describes how the application gets the job done. In operating systems, we are more concerned with the how rather than the why, thus we focus on processes rather than programs. 19)Define "context switch" and voluntary versus involuntary context switches. a)As a process migrates between user and kernel space, it changes from a user process to a kernel process with privileges. This multi-step process begins with a call to a user library which executes a software interrupt or trap instruction into the kernel. The kernel entry routine performs "state saving" by storing the CPU and MMU registers in the user's process descriptor and loading the saved kernel CPU and MMU registers. b)A process voluntarily performs a context switch when requesting a kernel service. c)A context switch is involuntary (preemptive) when a peripheral asserts a hardware interrupt or a fixed interval timing source interrupts the currently running process. =================== 5)Describe five elements of a CPU. 6)Explain why one must be aware of "time" as one reads assembly language source programs. Describe examples of source code which "switch time." (link resolution, assembler directive, instruction execution) 7)Be able to give a table of binary, octal, decimal, and hexadecimal to 16(decimal) and explain why 07h is an unnecessary notation. 8)Explain how BCD differs from other encoding schemes and give its design tradeoff. 10)Explain how to generate a listing file. 11)Define "listing" and describe the "fields" of a listing file. 12)Explain the role of a "debug" program and describe five of its commands. 13)Describe the steps required to load a program, set a breakpoint, view the CPU registers, continue the program, and view the changed registers. 14)Define "effective address." 15)Define "stack frame" and its five components. 16)Describe the operation of: pushl %ebp movl %esp, %ebp subl $4, %esp 17)Describe the operation of: movl 12(%ebp),%eax # Get the pointer to the start of argv movl 4(%eax),%edx # Skip the ptr to program name and get ptr to second argument movzbl (%edx), %edx # Get the ASCII number movb %dl, buff # Put the ASCII number in the buffer 18)Define "endian," give two types, and explain the problem with little endian debuggers. 19)Describe a Intel 80x86 program fragment that will add two numbers and store the result in memory. 20)Describe a PDP-8 program fragment that will add two numbers and store the result in memory. 21)Define the Intel "Flags" register and describe the four key bits used in programming. 22)Describe the five basic PDP-8 registers and explain their role. 23)Describe how an instruction is fetched. 24)Describe how the "TAD" memory reference instruction is executed. 25)Describe how the "DCA" memory reference instruction is executed. Linux 1)Define free, open source software OSS. 2)What does GNU mean, what are its goals, and what is its role in OSS. 3)What is GPL and why does it stand out among other OSS licenses. 4)Describe the use of Linux utilities to create a "Hello World" program. 6)Contrast vi's "insert" versus "command" modes. 7)Describe how to use the gcc to create an assembly language versus object versus executable program. 9)Contrast the role of "ld" versus "collect2" (or static versus shared libraries) in terms of foot print and image contents. 10)Explain the role of the objdump utility. Syntax 1)Contrast the assembler directives .ascii, asciz, and .string 2)Explain the difference between "movb $'1', %al" and "movb $59, %al" 3)Contrast "movl buff, %eax," "movl $buff, %eax," and "leal buff, %eax." Assignments 1)Find a Linux box and compile a "hello world" program 2)Generate assembly language version of the hello world program 3)Read the gcc HOWTO on the Linux documentation project site