Wednesday, February 7, 2018
|
|
- Rosalind Lambert
- 6 years ago
- Views:
Transcription
1 Wednesday, February 7, 2018 Topics for today The Pep/9 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate Location of variables in a program Trap instructions Symbols in Pep/9 Math operations in Pep/9 Chapter 4 The Pep/9 memory Figure 441 is a good overview of the various regions of the Pep/9 memory Shaded areas are read-only write-protected sections used by the operating system Here is a summary of the memory Application Program Area Address Range 0FB8E 16 (064398) Contents This area is the user program and the run-time stack The user program occupies bytes 0 onwards and the stack grows upwards toward the user program The stack typically grows and shrinks as the program runs It is possible for the stack to run into and overwrite the user program Operating System Area FB8FFC16 16 ( ) FC17FFFF 16 ( ) RAM - Here is the variable part of the operating system: The system stack, globals and I/O devices ROM - Here is the unchanging part of the operating system: the loader (about 64 bytes) the trap handler (about 863 bytes) pointers to (a) base of user stack, (b) base of system stack, (c) input device, (d) output device, (e) start of loader, (f) start of trap handler Comp 162 Notes Page 1 of 17 February 7, 2018
2 Four Example programs We look at four example hexadecimal programs from the book to get an idea of how the Pep/9 machine operates Once we get to Chapter 5, we will switch to assembly code programming Example 1: Fig 433 This is a very simple program that outputs Hi A character is output by being stored at memory[fc16] This program first loads character H from Memory[000D] into register A then copies it to memory[fc16] This two instruction sequence is repeated to output i The first byte of the first instruction is D1 (binary ) This is decoded as Opcode mode The opcode is Load byte from memory In general, the addressing mode tells the CPU how to use the two-byte number that follows the opcode byte When mode= 001 the number is treated as the address of the operand At this point in our look at low-level programming, the programmer is responsible for figuring out operand values (this will change when we get to Chapter 5) This program outputs Hi with the ASCII codes for H (48) and i (69) in the two bytes following the STOP instruction Example 2: Figure 435 Characters are input by being read from Memory[FC15] In this program two characters are read from the input and output in reverse order The program uses memory[0013] (the first free location after the end of program) to store the first character until it is needed for output The second character is read from input and written to output without needing to be stored in memory Example 3: Figure 436 This program adds two constants, 3 and 5, then outputs their sum The program has to convert the result of the sum (0008) into the ASCII code for 8 (which is 0038) It does the conversion by OR-ing the register with 30(hex) Clearly program is not very general and will not work if the sum > 9 Comp 162 Notes Page 2 of 17 February 7, 2018
3 Example 4: Figure 437: a self-modifying program Address Contents Remarks 0000 D1 get byte from Mem[0019] This is F1 store it at Mem[0009] overwriting the C1 get 16-bit number (5) from memory[0013] add to it the 16-bit number in memory[0015] 000A 00 (note that add is changed to sub by the 000B 15 actions of the first two instructions) 000C 91 OR with Mem[0017] = 0030 to convert to ASCII 000D E F F1 Send character to output 0010 FC Stop The first two instructions of the program get a byte (71) from location 19 (hex) and store it in location 9 Byte 9 is the opcode byte of the 4 th instruction of the program The effect of the modification is to change the 4 th instruction from an Add (opcode byte 61) to a Sub (opcode byte 71) instruction Now instead of adding data locations containing 5 and 3, it subtracts 3 from 5 Not very interesting but it does demonstrate that the program code is not "write protected" in any way (In contrast, part of the operating system is write-protected and cannot be modified by a user program) We can imagine a more interesting program that (1) is interactive - letting the user input the new opcode or (2) changes an operand rather than an opcode so that the address on which the instruction operates is changed Comp 162 Notes Page 3 of 17 February 7, 2018
4 The loader One of the built-in utilities in the Pep/9 system is a facility to load a program (written in hex) into memory Every system has a similar utility in some form The loader is a very simple program it is listed in Fig 83 if you are interested and is particular about the format of the input: (1) hexadecimal pairs separated by exactly one space or newline (2) program is terminated with zz We can write programs in hexadecimal and have the Pep/9 system run them The three steps involved are: (1) Enter your hex program in the Object Code window remembering the loader conventions above (2) If the program inputs data from the user then above the Input window, select tab to Terminal I/O (3) Under Build select Run Object This will load your program into the Pep/9 memory and if that succeeds, will execute the program You can see that writing programs in hex is tedious and error prone Hex programs are difficult to write, to edit, to read and to debug So two of the earliest developments in computing (back in the late 1940s) were symbolic languages (assembly code) translators (assemblers) from assembly code to machine code Warford s Chapter 5 looks at symbolic programming and the way in which assemblers work Chapter 5 In Chapter 5, Warford moves up a level in the multi-level machine to the assembly language level Assembly code enables programs to be written using symbols instead of numbers Some advanced assembly languages have features that allow us to write in almost high-level language form Compared with high-level language programs, assembly code programs have a relatively simple structure Possibly because early systems used punched cards for input, a typical assembly language is line-oriented, ie, not free-form like a high-level language, each line being one of three types: Comp 162 Notes Page 4 of 17 February 7, 2018
5 * a symbolic machine language instruction (maybe with commentary) * commentary only * an assembler directive or "pseudo operation" The Assembler - so called because it assembles the pieces of program - translates symbols to numbers and outputs an object program The order of items in the object program may be different from their order in the source program Source Program Assembler Object Program In some Pep/9 systems, source programs have a pep extension and object files have a pepo extension (1) Symbolic instructions The typical format of a symbolic instruction (with optional components shown in square brackets) is: [ label ] opcode [operands] [ ; commentary ] Examples LOOP: LDWA 0,i ; initialize counter BRGE END ; branch if sum > 0 STOP NEXT: ASLA ; now double it The following are typical symbolic instructions in the Pep/9 assembly language: LDWA 0,i STRO Mesg4,d LDBA '\n',i CPWA 0x3F1E,i STOP The table in Fig 52 is an expanded version of the table in Fig 46 It lists the instructions available to assembly language programmers Comp 162 Notes Page 5 of 17 February 7, 2018
6 In addition to the binary Instruction Specifier that we saw in Chapter 4, the table shows for each instruction: * the Mnemonic (symbolic opcode) that the assembler recognizes * the Addressing modes legal with the instruction (or U indicating that the instruction does not take an operand and hence does not required an addressing mode) * the Status bits (if any) that might be changed by the action of the instruction If you compare Fig 52 with Fig 46 you will see there are a few subtle changes The 6 instructions listed as unimplemented opcode in chapter 4 now appear either as high-level input/output (deco, deci, stro, hexo) or as no-operation trap instructions (nop, nopn) (2) Comments In Pep/9, any text between semi-colon and end of line is commentary, thus ; this line is just comment ; the following instruction has commentary ldwa M,d ; get count of lines to output Writing good comments in a program is an art more on this later (3) Assembler directives / "Pseudo operations" An assembler directive is just an instruction to the assembler (translation program) to perform some action at assembly (translation) time In assembly languages it is a common convention for such directives to begin with a period, ie xxx yyy This makes it easy for the assembler to distinguish them from symbolic machine instructions These directives are sometimes called "pseudo operations" (Warford uses this term) because (apart from the period) they look like symbolic machine operations but are not really There is a list of the nine Pep/9 pseudo operations on Page 238 Most of them are concerned with reserving space in the program for data locations Thus we have block N word A byte B ascii/abcdefg/ ; reserve N bytes of space ; reserve a word initialized to A ; reserve a byte initialized to B ; initialize bytes with sequence of characters Every Pep/9 program has at its last line end It marks the physical end of the source program the assembler does not read beyond this line Comp 162 Notes Page 6 of 17 February 7, 2018
7 Here are some approximate equivalencies between declarations in a high-level declarations and pseudo operations in Pep/9 int A; A: block 2 char B; B: block 1 int C = 50; C: word 50 char D = '%'; char E[] = "xyz"; D: byte '%' E: ascii xyz byte 0 OR E: ascii xyz\x00 int F [30]; F: block 60 char G [25]; G: block 25 In the case of string xyz, the extra zero byte ( \x00 ) acts as a string terminator used by the stro instruction Example Assembly code program The program in Fig 53 outputs Hi (without the quotes) to the screen LDBA 0x000D,d STBA 0xFC16,d LDBA 0x000E,d STBA 0xFC16,d STOP ASCII "Hi" END ; get H ; output it ; get i ; output it We will see later that other features of the assembly language let us improve on this program Note that END is the very last line and the STOP after the two instructions s the program and prevents it from running into the data Comp 162 Notes Page 7 of 17 February 7, 2018
8 Immediate Mode (see section 52) It is not necessary to have immediate mode Consider the following program that inputs a number then outputs the number that is 5 greater than the number input deci N,d ; get a number ldwa N,d ; load it into Register A adda five,d ; add the contents of a location containing 5 stwa N,d ; overwrite the original number deco N,d ; and output updated quantity N: block 2 ; space for the number five: word 5 ; a location containing 5 end We can choose to store all constants that the program needs in their own memory locations like this But it is shorter, faster and a little more natural if we are able to use the number 5 as part of an instruction as in the following: deci N,d ldwa N,d adda 5,i ; add 5 to register immediate mode stwa N,d deco N,d N: block 2 end The ",i" in the adda instruction indicates immediate mode It indicates that 5 is the operand itself Contrast this with ldwa 5,d ; add contents of word at memory location 5 The ",d" here indicates direct mode - the 5 is the address of the operand (which must therefore be fetched using an additional read) Immediate mode is faster because we have one fewer memory read The equate directive Consider the following program fragment ; Program A ldwa limit,d cpwx limit,d suba limit,d limit: word 19 Comp 162 Notes Page 8 of 17 February 7, 2018
9 Perhaps it is part of a registration program and the variable "limit" holds the largest number of units that a student can register for The following program (B) is similar but uses immediate mode and runs faster ; Program B ldwa 19,i cpwx 19,i suba 19,i But program B has two disadvantages: (1) if we need to change the limit from 19 to some other number we have multiple edits to make; we may miss one and make the program inconsistent (2) the constant 19 appearing in the program does not indicate what it represents A solution that combines the readability and editability of program A with the speed of program B is the following ; Program C limit: equate 19 ldwa cpwx suba limit,i limit,i limit,i The equate assembler directive lets us associate a symbolic name with a value After assembly, programs B and C are identical Comp 162 Notes Page 9 of 17 February 7, 2018
10 Location of variable declarations in a Pep/9 program Where do variables go in an assembly language program? To a certain extent it is a matter of programming style but we have to be sure that program execution cannot run into them Two possibilities are: (1) after STOP and before END <executable instructions go here> ; program will halt at this line A: word 3 B: block 4 C: word 17 end (2) at the beginning of the program in which case we need to skip over them and have something like br main ; transfer control to instruction labeled main a: block 2 b: block 2 main: <first executable instruction> The br (branch) instruction does an unconditional transfer of control to the specified location Warford prefers style (2) in his example programs Here are four translations of the following pseudocode program int a=30, b=25, c; c = a+b; output (c); Two of the translations have errors Which? Program 1 Program 2 Program 3 Program 4 ldwa a,d adda b,d stwa c,d deco c,d a: word 30 b: word 25 c: block 2 end a: word 30 b: word 25 c: block 2 ldwa a,d adda b,d stwa c,d deco c,d end br main a: word 30 b: word 25 c: block 2 main: ldwa a,d adda b,d stwa c,d deco c,d end ldwa a,d adda b,d stwa c,d deco c,d end a: word 30 b: word 25 c: block 2 Comp 162 Notes Page 10 of 17 February 7, 2018
11 Program 1: is correct Program 2: halts at byte 0 when the program tries to execute a data location Program 3: is correct Program 4: fails to assemble because the assembler does not read anything after end so does not see the definitions of symbols a, b and c Trap Instructions Instructions DECO, DECI, HEXI, STRO, NOP and NOPn are the six instructions that exist at the assembly language level but not at the machine language level So what happens when the system encounters one during the running of a program? Answer - the system springs a "trap" which takes the following form - the user program is suspended - important data areas are saved on the system stack (registers, status bits) - control is transferred to the Trap Handler in the operating system - the operating system code takes appropriate action depending on the particular instruction - the data saved is restored - control is returned to the user program using the RETTR (return from trap) instruction Thus these six instructions are slow compared with non-trap instructions but you probably won t notice the difference Here is what appropriate action" means for some of these trapped instructions: DECI: inputs input characters Checks they form a legal integer Outputs an Error message if invalid characters are input DECO: outputs an appropriate sequence of decimal digits maybe preceded by a sign character HEXO: outputs 4 hexadecimal digits STRO: outputs the characters in a null-terminated string Recall that we can set up a string in memory using the ascii directive How does STRO know the length of the string Pep/9 could use one of two ways: (a) a byte at the beginning of the string indicating length (b) an end-of-string marker It uses method (b) and the ASCII NUL byte (code 0) as the marker This is the same method that C uses to delimit strings We can set up a null-terminated string a couple of different ways Comp 162 Notes Page 11 of 17 February 7, 2018
12 msg: ascii "message" byte 0 or simply msg: ascii "message\x00" There are very few situations where a programmer needs to be aware that an instruction is a trapped instruction rather than a normal instruction In addition to the four instructions above, NOP and NOPn are also trapped These are no operation instructions; sometimes it is useful to have an instruction that doesn t do anything! Symbols in Pep/9 Identifiers: follow usual identifier rules (start with a letter, continue with letters, underscore or digits) but in Pep/9 they can be no more than 8 chars long Many assembly languages have similar length restrictions Pep/9 will give an error message rather than just using the first 8 characters longername: block 2;ERROR: Symbol longername cannot have more than eight characters Numbers: can be decimal 1234 or hex 0xFF8E (The hex notation is similar to some high-level languages) Characters: eg '*' (single quotes) '\n' '\t' '\x00' Strings: eg "Output follows\n" (double quotes) Ultimately, everything is bits We can manipulate the contents of memory in nonstandard ways Consider the following program this: stro this,d end When run, this program outputs I Why? The translation of the program is When it runs it outputs the string starting at location 0 that terminates with a null (zero) bytes The first two bytes of the program in hex are The ASCII code for I is 49 (hex) Comp 162 Notes Page 12 of 17 February 7, 2018
13 Consider also the following self-modifying program similar to one we saw earlier ldba 0x70,i stba X,d ldwa 5,i X: adda 3,i stwa N,d deco N,d N: block 2 end When it runs, the program modifies the byte at X This is the opcode byte of the 4th instruction It changes it from 60 (ADD) to 70 (SUB) so the program outputs 2 not 8 Math operations in Pep/9 Multiplication If we are multiplying by a power of 2 then we just need a sequence of left shifts Thus, to compute N * 8 ldwa N,d asla asla asla In general we can accomplish multiplication using shifting and adding The following sequence computes M * 29 [ 29 is 11101, can you see a general pattern here? ] ldwa M,d ; M asla ; M * 2 adda M,d ; M * 3 asla ; M * 6 adda M,d ; M * 7 asla ; M * 14 asla ; M * 28 adda M,d ; M * 29 Division We can easily compute X/Y (truncated) if Y is a power of 2 using right shifts For example, to compute P/16 ldwa P,d asra ; P/2 asra ; P/4 asra ; P/8 asra ; P/16 If Y is not a power of 2, the required program is more complex Comp 162 Notes Page 13 of 17 February 7, 2018
14 Modulus We can easily compute P%Q if P is positive and Q is a power of 2 For example, the result of T % 8 is the rightmost 3 bits of T thus ldwa T,d anda 7,i In general, computing a remainder is more difficult as the following table illustrates M N M%N M&(N-1) Simple arithmetic and assignment statement High-level language: M = N * 8 + T; Pep/9: ldwa N,d asla asla asla adda T,d stwa M,d Reading The binary/hex level is covered in chapter 4, you can skim step-by-step details of how particular instructions work Chapter 5 covers the basic properties of the Pep/9 assembly language Next we will look at more translations of high-level language into Pep/9 then at how the assembler works Comp 162 Notes Page 14 of 17 February 7, 2018
15 Review Questions 1 Why can t we use the same label for a variable and an instruction as in L: block 2 L: ldwa M,d Surely the assembler will know that brgt L ; refers to L on the instruction And ldwa L,d ; refers to L on the variable 2 How can you have two labels on the same variable thus enabling a programmer to use either a short identifier (eg, C) or a long one (eg, COUNTER) for the same location? 3 Can we have two labels on the same instruction? 4 Following our example of multiplication by 29, give a sequence of instructions for calculating M times 43 (101011) 5 In Pep/9, not every combination of opcode and addressing mode is valid Using Fig 52, or otherwise, identify the 16 combinations that would be flagged as invalid either at assembly time or at run-time Comp 162 Notes Page 15 of 17 February 7, 2018
16 Review Answers 1 Because, as we have seen, everything is bits If we had M: block 2 L: brgt X It is legal, though inadvisable, to have brgt M ; branch to a data location and to load the first 2 bytes of an instruction ldwa L,d 2 For example C: block 0 COUNTER: block 2 3 Two labels could be used as in L: nop0 ; dummy instruction LOOP: ldwx M,d ; real top of loop But L and LOOP will not have the same value To get two values the same you could figure out the address of the instruction (eg XYZ) then have L: equate XYZ 4 ldwa M,d ; M 1 asra ; 2M 0 asra ; 4M adda M,d ; 5M 1 asra ; 10M 0 asra ; 20M adda M,d ; 21M 1 asra ; 42M adda M,d ; 43M 1 Comp 162 Notes Page 16 of 17 February 7, 2018
17 5 Opcode Mode(s) stba stbx stwa stwx deci stro nop i i i i i i, s, sx, sfx d, n, s, x, sf, sx, sfx Comp 162 Notes Page 17 of 17 February 7, 2018
Monday, February 11, 2013
Monday, February 11, 2013 Topics for today The Pep/8 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate
More informationWednesday, February 15, 2017
Wednesday, February 15, 2017 Topics for today Before and after assembly: Macros, Linkers Overview of Chapter 6 Branching Unconditional Status bits and branching If statements While statements The V and
More informationWednesday, September 20, 2017
Wednesday, September 20, 2017 Topics for today More high-level to Pep/9 translations Compilers and Assemblers How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode
More informationWednesday, September 27, 2017
Wednesday, September 27, 2017 Topics for today Chapter 6: Mapping High-level to assembly-level The Pep/9 run-time stack (6.1) Stack-relative addressing (,s) SP manipulation Stack as scratch space Global
More informationWednesday, February 28, 2018
Wednesday, February 28, 2018 Topics for today C functions and Pep/9 subroutines Introduction Location of subprograms in a program Translating functions (a) Void functions (b) Void functions with parameters
More informationWednesday, April 19, 2017
Wednesday, April 19, 2017 Topics for today Process management (Chapter 8) Loader Traps Interrupts, Time-sharing Storage management (Chapter 9) Main memory (1) Uniprogramming (2) Fixed-partition multiprogramming
More informationWednesday, September 13, Chapter 4
Wednesday, September 13, 2017 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/9 Features of the system Operational cycle Program trace Categories of
More informationMonday, March 27, 2017
Monday, March 27, 2017 Topics for today Indexed branching Implementation of switch statement Reusable subroutines Indexed branching It turns out that arrays are useful in translating other language constructs,
More informationMonday, March 13, 2017
Monday, March 13, 2017 Topics for today Arrays and Indexed Addressing Global arrays Local arrays Buffer exploit attacks Arrays and indexed addressing (section 6.4) So far we have looked at scalars (int,
More informationWednesday, March 14, 2018
Wednesday, March 14, 2018 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Option A: Space-minimal solution Option B: Iliffe vectors Array bound
More informationWednesday, April 22, 2015
Wednesday, April 22, 2015 Topics for today Topics for Exam 3 Process management (Chapter 8) Loader Traps Interrupts, Time-sharing Storage management (Chapter 9) Main memory (1) Uniprogramming (2) Fixed-partition
More informationWednesday, September 21, 2016
Wednesday, September 21, 2016 Topics for today More high-level to translations Compilers and Assemblers How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode and
More informationMonday, February 16, 2015
Monday, February 16, 2015 Topics for today How assemblers work Symbol tables ILC Pass 1 algorithm, Error checking Pass 2 Immediate mode and equate Assembler variants: Disassembler, Cross assembler Macros
More informationMonday, March 6, We have seen how to translate void functions. What about functions that return a value such as
Monday, March 6, 2017 Topics for today C functions and Pep/9 subroutines Translating functions (c) Non-void functions (d) Recursive functions Reverse Engineering: Pep/9 to C C Functions and Pep/9 Subroutines
More informationWednesday, March 29, Implementation of sets in an efficient manner illustrates some bit-manipulation ideas.
Wednesday, March 29, 2017 Topics for today Sets: representation and manipulation using bits Dynamic memory allocation Addressing mode summary Sets Implementation of sets in an efficient manner illustrates
More informationWednesday, February 4, Chapter 4
Wednesday, February 4, 2015 Topics for today Introduction to Computer Systems Static overview Operation Cycle Introduction to Pep/8 Features of the system Operational cycle Program trace Categories of
More informationLow-level software. Components Circuits Gates Transistors
QUIZ Pipelining A computer pipeline has 4 processors, as shown above. Each processor takes 15 ms to execute, and each instruction must go sequentially through all 4 processors. A program has 10 instructions.
More informationQUIZ. Name all the 4 parts of the fetch-execute cycle.
QUIZ Name all the 4 parts of the fetch-execute cycle. 1 Solution Name all the 4 parts of the fetch-execute cycle. 2 QUIZ Name two fundamental differences between magnetic drives and optical drives: 3 QUIZ
More informationExtra-credit QUIZ Pipelining -due next time-
QUIZ Pipelining A computer pipeline has 4 processors, as shown above. Each processor takes 15 ms to execute, and each instruction must go sequentially through all 4 processors. A program has 10 instructions.
More informationQUIZ. Name all the 4 parts of the fetch-execute cycle.
QUIZ Name all the 4 parts of the fetch-execute cycle. 1 Solution Name all the 4 parts of the fetch-execute cycle. 2 QUIZ Name two fundamental differences between magnetic drives and optical drives: 3 Solution
More informationn NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i
Instruction set Instruction Mnemonic Instruction Addressing Status Specifier Mode Bits 0000 0000 STOP Stop execution U 0000 0001 RET Return from CALL U 0000 0010 RETTR Return from trap U 0000 0011 MOVSPA
More informationUNIT-II. Part-2: CENTRAL PROCESSING UNIT
Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:
More informationMonday, October 17, 2016
Monday, October 17, 2016 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals Reverse Engineering II Representation of Booleans C Functions and Pep/8 Subroutines
More informationWednesday, September 6, 2017
Wednesday, September 6, 2017 Topics for today Arithmetic operations and status bits Logical operators Introduction to bigger bases Encoding characters Coding in general Status bits We saw last time that
More informationMonday, March 9, 2015
Monday, March 9, 2015 Topics for today C functions and Pep/8 subroutines Passing parameters by reference Globals Locals More reverse engineering: Pep/8 to C Representation of Booleans C Functions and Pep/8
More informationWednesday, March 12, 2014
Wednesday, March 12, 2014 Topics for today Solutions to HW #3 Arrays and Indexed Addressing Global arrays Local arrays Buffer exploit attacks Solutions to Homework #3 1. deci N,d < (a) N not defined lda
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationWednesday, October 4, Optimizing compilers source modification Optimizing compilers code generation Your program - miscellaneous
Wednesday, October 4, 2017 Topics for today Code improvement Optimizing compilers source modification Optimizing compilers code generation Your program - miscellaneous Optimization Michael Jackson Donald
More informationCSC 221: Computer Organization, Spring 2009
1 of 7 4/17/2009 10:52 AM Overview Schedule Resources Assignments Home CSC 221: Computer Organization, Spring 2009 Practice Exam 2 Solutions The exam will be open-book, so that you don't have to memorize
More informationCOMPUTER ORGANIZATION & ARCHITECTURE
COMPUTER ORGANIZATION & ARCHITECTURE Instructions Sets Architecture Lesson 5a 1 What are Instruction Sets The complete collection of instructions that are understood by a CPU Can be considered as a functional
More informationMicroprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)
Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition
More informationChapter. Computer Architecture
Chapter 4 Computer Architecture Figure 4.1 Input device Central processing unit Main memory Output device Bus Data flow Control Figure 4.2 Central processing unit () Status bits ( ) Accumulator ( ) Index
More informationC Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
C Programming Language 1 C C is better to use than assembly for embedded systems programming. You can program at a higher level of logic than in assembly, so programs are shorter and easier to understand.
More informationBits, Words, and Integers
Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are
More informationWednesday, April
Wednesday, April 9. 2014 Topics for today Addressing mode summary Structures Structures and dynamic memory Grammars and Languages (Chapter 7) String generation Parsing Regular languages Summary of addressing
More informationChapter. Assembly Language
Chapter 5 Assembly Language Mappings The mapping from Asmb5 to ISA3 is one-toone The mapping from HOL6 to Asmb5 is oneto-many Symbols Defined by an identifier followed by a colon at the start of a statement
More informationsarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label
sarm User Guide The sarm is program that implements an experimental CPU simulator. It is called experimental because it is not yet complete, and it also incorporates facilities that are not conventionally
More informationCC411: Introduction To Microprocessors
CC411: Introduction To Microprocessors OBJECTIVES this chapter enables the student to: Use number { base 2, base 10, or base 16 }. Add and subtract binary/hex numbers. Represent any binary number in 2
More informationMemory Addressing, Binary, and Hexadecimal Review
C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend
More informationDigital System Design Using Verilog. - Processing Unit Design
Digital System Design Using Verilog - Processing Unit Design 1.1 CPU BASICS A typical CPU has three major components: (1) Register set, (2) Arithmetic logic unit (ALU), and (3) Control unit (CU) The register
More informationWednesday, November 15, 2017
Wednesday, November 15, 2017 Topics for today Code generation Synthesis Algorithm 5: tree to code Optimizations Code generation Algorithm 5: generating assembly code Visiting all the nodes in a linked
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationMonday, October 24, 2016
Monday, October 24, 2016 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Option A: Space-minimal solution Option B: Iliffe vectors Array bound
More informationCHAPTER ASSEMBLY LANGUAGE PROGRAMMING
CHAPTER 2 8051 ASSEMBLY LANGUAGE PROGRAMMING Registers Register are used to store information temporarily: A byte of data to be processed An address pointing to the data to be fetched The vast majority
More informationChapter 6 Programming the LC-3
Chapter 6 Programming the LC-3 Based on slides McGraw-Hill Additional material 4/5 Lewis/Martin Aside: Booting the Computer How does it all begin? We have LC-3 hardware and a program, but what next? Initial
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationDec Hex Bin ORG ; ZERO. Introduction To Computing
Dec Hex Bin 0 0 00000000 ORG ; ZERO Introduction To Computing OBJECTIVES this chapter enables the student to: Convert any number from base 2, base 10, or base 16 to any of the other two bases. Add and
More informationMonday, October 26, 2015
Monday, October 26, 2015 Topics for today Indexed branching Implementation of switch statement Reusable subroutines Indexed branching It turns out that arrays are useful in translating other language constructs,
More informationreply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000
Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationCS102: Variables and Expressions
CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationCPS122 Lecture: From Python to Java last revised January 4, Objectives:
Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More information2.2 THE MARIE Instruction Set Architecture
2.2 THE MARIE Instruction Set Architecture MARIE has a very simple, yet powerful, instruction set. The instruction set architecture (ISA) of a machine specifies the instructions that the computer can perform
More informationWednesday, February 19, 2014
Wednesda, Februar 19, 2014 Topics for toda Solutions to HW #2 Topics for Eam #1 Chapter 6: Mapping High-level to assembl-level The Pep/8 run-time stack Stack-relative addressing (,s) SP manipulation Stack
More informationThe CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:
The CPU and Memory How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: 1 Registers A register is a permanent storage location within
More informationLecture 5 Assembly Programming: Arithmetic
CPE 390: Microprocessor Systems Spring 2018 Lecture 5 Assembly Programming: Arithmetic Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030
More informationComputer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2
Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up
More informationthe SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.
I. Intro the SAP-2 cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, 9.8 1. We ll do this in bits and pieces, doing the beginning of each section first. 1. The SAP-2 adds a lot of functionality to the SAP-1
More informationEDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION
EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6
More information19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd
19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading
More informationIntroduction to Computers - Chapter 4
Introduction to Computers - Chapter 4 Since the invention of the transistor and the first digital computer of the 1940s, computers have been increasing in complexity and performance; however, their overall
More informationTOPIC: NUMBER SYSTEMS
Ministry of Secondary Education Progressive Comprehensive High School PCHS Mankon Bamenda Department of Computer Studies Republic of Cameroon Peace Work - Fatherland TOPIC: NUMBER SYSTEMS Class: Comp.
More informationWednesday, October 17, 2012
Wednesday, October 17, 2012 Topics for today Arrays and Indexed Addressing Arrays as parameters of functions Multi-dimensional arrays Indexed branching Implementation of switch statement Arrays as parameters
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationSpecial Section: Building Your Own Compiler
cshtp6_19_datastructures_compiler.fm Page 1 Tuesday, February 14, 2017 10:31 AM 1 Chapter 19 Special Section: Building Your Own Compiler In Exercises8.31 8.33, we introduced Simpletron Machine Language
More informationC How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.
C How to Program, 6/e 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. This chapter serves as an introduction to the important topic of data
More information17. Instruction Sets: Characteristics and Functions
17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set
More informationReserved Words and Identifiers
1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationData Representation 1
1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation
More informationCS311 Lecture: The Architecture of a Simple Computer
CS311 Lecture: The Architecture of a Simple Computer Objectives: July 30, 2003 1. To introduce the MARIE architecture developed in Null ch. 4 2. To introduce writing programs in assembly language Materials:
More informationInstruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts
Lecture 4 Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts One part is the task to be performed, called operation code or opcode in
More informationORG ; TWO. Assembly Language Programming
Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify
More informationSigned umbers. Sign/Magnitude otation
Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,
More informationCOMP2121: Microprocessors and Interfacing. Number Systems
COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting
More informationCourse Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation
Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep
More informationMonday, April 9, 2018
Monday, April 9, 208 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation Overview Finite State Machines (see 7.2) If a language is regular (Type 3)
More informationPhysics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That
Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the
More informationWilliam Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationChapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics
Chapter 4 Objectives Learn the components common to every modern computer system. Chapter 4 MARIE: An Introduction to a Simple Computer Be able to explain how each component contributes to program execution.
More informationAssembly Language programming (1)
EEE3410 Microcontroller Applications LABORATORY Experiment 1 Assembly Language programming (1) Name Class Date Class No. Marks Familiarisation and use of 8051 Simulation software Objectives To learn how
More informationContents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides
Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section
More informationMonday, November 7, Structures and dynamic memory
Monday, November 7, 2016 Topics for today Structures Structures and dynamic memory Grammars and Languages (Chapter 7) String generation Parsing Regular languages Structures We have seen one composite data
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More information9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C
Overview The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationLOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE. Introduction to Computer Engineering 2015 Spring by Euiseong Seo
LOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE Introduction to Computer Engineering 2015 Spring by Euiseong Seo Where are we? Chapter 1: The Big Picture Chapter 2: Binary Values and Number Systems Chapter
More information2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).
2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationThe C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)
The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) 1 Overview Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationCS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output
CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables
More informationDLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR
UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error
More informationCSCI 2212: Intermediate Programming / C Chapter 15
... /34 CSCI 222: Intermediate Programming / C Chapter 5 Alice E. Fischer October 9 and 2, 25 ... 2/34 Outline Integer Representations Binary Integers Integer Types Bit Operations Applying Bit Operations
More informationFunctional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute
Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Module # 02 Lecture - 03 Characters and Strings So, let us turn our attention to a data type we have
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationCS112 Lecture: Primitive Types, Operators, Strings
CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive
More information