Wednesday, September 20, 2017
|
|
- David Strickland
- 5 years ago
- Views:
Transcription
1 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 and equate Assembler variants: Disassembler, Cross assembler High-level language and Pep/9 To further reinforce ideas about mapping high-level constructs into Pep/9, here are nine more examples of programs and their possible translations 1 High level language int a,b,c; input(a,b) c=a+b; output (c); Pep/9 deci a,d deci b,d ldwa a,d adda b,d ; a + b stwa c,d deco c,d a: block 2 b: block 2 c: block 2 2 High level language Pep/9 int a,c; input(a); c=a+5; output(c); deci a,d ldwa a,d adda five,i ; a + 5 stwa c,d deco c,d a: block 2 c: block 2 five:equate 5 Comp 162 Notes Page 1 of 17 September 20, 2017
2 3 High level language Pep/9 int a,b,c; input (a,b); c=(a+b)/2; output (c); deci b,d ldwa a,d adda b,d asra stwa c,d deco c,d a: block 2 b: block 2 c: block 2 ; (a+b)/2 4 High level language int a; input(a); output (3*a+27); Pep/9 deci a,d ldwa a,d asla ; 2a adda a,d ; 3a adda constant,i ; 3a+27 stwa a,d ; used for result deco a,d a: block 2 constant:equate 27 5 High level language Pep/9 int a,b; input(a,b); output("the sum is "); output(a+b); deci a,d deci b,d ldwa a,d adda b,d stwa a,d ; a now a+b stro label,d deco a,d a: block 2 b: block 2 label:ascii "The sum is \x00" Comp 162 Notes Page 2 of 17 September 20, 2017
3 6 High level language Pep/9 int a,b; input (a,b); output(a); output(" + " ); output(b); output(" = " ); output(a+b); deci a,d deci b,d ldwa a,d adda b,d stwa temp,d deco a,d stro plus,d deco b,d stro equals,d deco temp,d a: block 2 b: block 2 temp: block 2 plus: ascii " + \x00" equals:ascii " = \x00" ; for a+b 7 High level language int a; input(a); a = a + a%4; output(a); Pep/9 deci a,d ldwa a,d anda 3,i ; a%4 adda a,d ; a+a%4 stwa a,d deco a,d a: block 2 Comp 162 Notes Page 3 of 17 September 20, 2017
4 8 High level language int score, exam1, exam2; const int bonus = 10; int main() { output ( Enter exam scores: ) input (exam1); input (exam2); score = (exam1+exam2)/2 + bonus; output( Your semester score is: ); output(score); } Pep/9 br main score: block 2 exam1: block 2 exam2: block 2 bonus: equate 10 main: stro prompt,d deci exam1,d deci exam2,d ldwa exam1,d adda exam2,d asra adda bonus,i stwa score,d stro label,d deco score,d prompt:ascii Enter exam scores: \x00 label:ascii Your semester score is: \x00 Comp 162 Notes Page 4 of 17 September 20, 2017
5 9 High level language Pep/9 int A, B, C, result; int main() { output( Enter three integers: ); ; } input(a); input(b); input(c); result = (A/4) + (B%32) + (C*3) 24 output( Result is: ); output(result); stro prompt,d deci a,d deci b,d deci c,d ldwa a,d asra asra stwa result,d ; a/4 ldwa b,d anda 31,i adda result,d stwa result,d ; a/4 + b%32 ldwa c,d asla adda c,d adda result,d suba 24,i stwa result,d ; a/4 + b%32 + 3*c - 24 stro label,d deco result,d a: block 2 b: block 2 c: block 2 result:block 2 prompt:ascii Enter three integers:\x00 label: ascii Result is: \x00 Compilers and Assemblers Both compilers and assemblers are translation programs Both use symbol tables that contain information about identifiers in the source program but the compiler symbol table has to record information such as type and scope of the identifiers A compiler does type checking that an assembler does not do (in assembly code everything is bits ) Comp 162 Notes Page 5 of 17 September 20, 2017
6 How assemblers work In a sentence: An assembler translates symbols to numbers There are various symbols in an assembly language program but they fall into two groups: (1) those that are part of the assembly language itself eg deco stro block (2) those that a user is free to make up (within length limits) - the labels on instructions or data locations The forward reference problem In general, an assembler cannot read a program just once and output a translation as it goes along This is because a symbol can be used before it is defined Consider the following deci N,d ; input count of lines N : block 2 ; variable for line count When the assembler reads the first line, it does not (yet) know the value that N represents (the address of the line it labels) Even if the language requires users to declare all data at the top of the program we may still have forward references in branch instructions as in the first line of the following br main A: block 2 B: block 2 main: deci A,d Thus, a typical assembler reads the source program twice; it makes two passes over the text: Pass 1: get values of symbols Pass 2: do the actual translation 1 An assembler makes use of tables in translating the program and there will be two types of tables corresponding to the two types of symbol Fixed Tables - contain those symbols that are part of the language such as the opcodes and directives The structure of these tables can be optimized for fast access, eg entries ordered alphabetically 1 It is possible to write an assembler that only requires one pass but it is tricky Reading a source program twice is rarely a problem so two passes are preferred Comp 162 Notes Page 6 of 17 September 20, 2017
7 Entries in the opcode table associate, with each symbolic opcode, information such as its numeric translation, number of operands, valid addressing modes and so on For example, Symbol Template Operand Bytes Modes Allowed ROLr r No 1 STWr 1110raaa Yes 3 d,s,x,n,sf,sx,sxf STOP No 1 BR a Yes 3 i,x Pep/9 also has a table showing the value of built-in symbols Symbol Value charin 0xFC15 charout 0xFC16 The fixed tables are initialized before the user program is read and do not change Variable Table - contains those symbols that the user is free to choose such as labels on instructions and data locations (think about the identifiers in a high-level language program) This table is empty before the user program is read and entries are made during Pass 1 We can depict the operation of a two-pass assembler thus: Source Program Pass 1 Pass 2 Object Program Fixed Tables Variable Table Comp 162 Notes Page 7 of 17 September 20, 2017
8 Organization of tables In theory, it does not matter how fast the assembler performs the translation as long as it is correct But in practice we would like it to run as fast as possible Much of what an assembler does is look up symbols in tables so if we can make look-ups fast, the assembly operation as a whole will be quick Fixed tables In a fixed table we know what the entries are Some possibilities for organizing such a table for fast access are (a) order by expected frequency then search linearly Common symbols will be found quicker (b) order by actual frequency Start with some ordering then when an entry is used move it closer to the beginning of the table (c) order alphabetically and do a binary/logarithmic search (d) use a hash function to map each symbol to a different address in a table To look up a symbol from the program, apply the hash function and look at the contents of the corresponding address (more on hashing below) Variable tables The problem with the user-defined symbols is that when we do pass one we don t know how many symbols there will be or what they will be Thus options (a), (b) and (c) above are not good It is common to use (d) - a hash-table approach In doing so, we need to make provision for dealing with two symbols that hash to the same address Hashing: a small example Hashing involves devising a function that maps the objects to be stored (in our case user-defined identifiers) onto addresses (probably indexes of a table) If the function is simple, hashing can be very fast A simple function of spring parameter S is: ( rank(first character of S) + rank(last character of S) ) % table-size The following shows the value of this function for some typical identifiers assuming table addresses ranging from 0 to 9 Comp 162 Notes Page 8 of 17 September 20, 2017
9 Symbol Rank(1 st ) Rank(Last) Rank(1st)+rank(last) Rank(1 st )+Rank(last))%10 TOP N COUNT LAB LOOP When a symbol hashes to an address that is already full we can just use the next free one After entering the examples above, our 10-entry table looks like Index Contents Value COUNT 4 LAB 5 6 TOP 7 8 N 9 LOOP Assembler operation: Pass 1 Typically, Pass 1 does almost all the error checking of the source program In the case of Pep/9, Pass 1 does all the checking Pass 1 is responsible for determining the value of each user-defined symbol It constructs a table of symbols and corresponding values It uses a variable called the Instruction Location Counter (ILC) to keep track of the amount of space required in memory by a translation of the program read so far To see how this works, consider translating the following program by hand ldba A,d stba charout,d ldba B,d stba charout,d A: byte H B: byte I Comp 162 Notes Page 9 of 17 September 20, 2017
10 We can figure the translation of the each of the first 4 lines is 3 bytes Thus they occupy bytes 0 through 11 in the memory The translation of the fifth line occupies one byte (byte 12) so the symbol A is a label on byte 13 and therefore the value of the symbol A is 13 Similarly the value of B is 14 We could replace the first line of the program by ldba 13,d and it would translate the same Next we will see how Pass 1 of the assembler uses and updates the value of the ILC Pass 1: ILC The Instruction Location Counter (ILC) is a variable used by the assembler to assign appropriate values to labels it is initialized to zero it is incremented by number of bytes required by translation of the current line When a label is encountered, its value is (usually) the current value of the ILC (See later for an exception) Example Label Program Line Bytes occupied ILC before ILC after deci N,d ldwa N,d asra next: deci M,d adda N,d brv end br next end: M: block N: block n/a 24 The final value of the ILC is the size of the program in bytes After Pass 1 we have the following values (see highlighted entries in the trace above) Symbol Value N 22 next 7 M 20 end 19 Comp 162 Notes Page 10 of 17 September 20, 2017
11 Pep/9 limitations? Large block declarations work The following program assembles ldwa 1,i x: block y: block 2 A program with 10,000 different labels also appears to assemble correctly Pass 1: Algorithm Here is a pseudocode algorithm for Pass 1 ILC = 0 read line while ( line!= END) { if errors(line) output errormessage } else if ( notallcomment(line)) { extractsymbols (line,symbollist) updatetable (symbollist,ilc) ILC = ILC + spaceneeds(line) // see below } if (end-of-file) { output ("missing "); exit } else read line Computing the space needs of a source line Pass 1 has to figure out how many bytes will be generated by the translation of a line (symbolic instruction or pseudo operation) so it can update the ILC correctly This can be more or less complicated In Pep/9 it is relatively straightforward Here are some examples of lines and the number of bytes its translation takes up in the object program Comp 162 Notes Page 11 of 17 September 20, 2017
12 Line Bytes byte 4 1 ascii "*" 1 asra 1 word 0 2 word 0xFFFF 2 ascii "Hi" 2 loada 10,i 3 ascii "ABCDE" 5 (in general, the number of chars) ascii X=\t \n Result\x00 14 (might be tricky to count them!) block 2 2 block Here is another example of processing by Pass 1 (verify the ILC values for yourself) Program ILC before ILC after a: block b: byte c: word d: word 0x e: ascii f: ascii 0x g: block 0x h: byte '\x12' Error checking Here is a list of typical errors that might be detected by an assembler during Pass 1 2 * symbol defined more than once * instruction has incorrect number of operands * misspelled directive/opcode * invalid addressing mode * missing * invalid constant (eg, a non-digit character in a decimal number) * missing symbol definition (detected at the end of Pass 1) * invalid string delimiter Note that while the Pep/9 assembler will detect an error in a line, the error message it gives may not be an exact indicator of what the error is For example, when erroneous operand is present main: asra 2;ERROR: Comment expected following instruction 2 The Pep/9 assembler only reports the first error it finds Comp 162 Notes Page 12 of 17 September 20, 2017
13 Assembly operation: Pass 2 If Pass 1 does not find any errors in the source program then Pass 2 uses the symbol table constructed in Pass 1 and the table of opcode information to translate the program For example if M has a value of 15 after Pass 1 then LDWA M,d Translates to = C1 00 0F LDWr A d <value of symbol M> Error detection in Pass 2 In Pep/9 there are no errors that are detectable only in Pass 2 Here is an example of an error in another assembly languages that can be detected only in Pass 2 The fragment includes a branch instruction to a label further down the program X: brgt X ; jump to X if result greater than 0 Suppose that the format of the two-byte brgt instruction is as follows opcode Relative address of destination The (signed) relative address (one byte) will be added to the PC if the branch is to be taken We can thus jump to locations approximately ± 127 bytes away from the branch instruction During Pass 1 we do not know where X is so no error can be signaled If during Pass 2 we find that X is too far away for us to put the distance in the single byte available then we indicate an error The programmer will have to find a different way to implement this branch, for example brle skip jump X skip: X: ; jump, like instructions in Pep/9 can address all memory Comp 162 Notes Page 13 of 17 September 20, 2017
14 The equate directive The equate directive lets us associate a symbolic name with a value It is processed in Pass 1 and ignored in Pass 2 (it doesn t generate any executable code) so it does not matter where it appears in the program We have seen how to figure out the values that Pass 1 will give to symbols If equate is used, just remember that it does not occupy any space in the object program Consider the following a: block 25 maxu: equate 19 count: word 0 total: word 0 tab : equate 0x09 n: block 8 t: ascii "END" w: byte 'x' Verify for yourself that after Pass 1 the symbol table with contain the following symbols and values Symbol Value a 0 maxu 19 count 25 total 27 tab 9 n 29 t 37 w 40 Assembler variant 1: Disassembler (see p 255) We cannot in general perform a reverse translation of an object program because data and instructions are indistinguishable in memory For example, in Pep/9 and subsp 2,i translates to byte X word 2 translates to Comp 162 Notes Page 14 of 17 September 20, 2017
15 A disassembler can offer two or more translations of a memory block and let the user sort out which is correct If it has access to the symbol table that was used in assembly, it may be able to make the translation a little more readable In Pep/9, a memory dump shows the (printable) ASCII characters For example, a memory dump of ; test program ldwa 48,i stro mess1,d deco 51,i stro mess2,d mess1: ascii "Adding 34 and 17 gives: \x00" mess2: ascii " Correct! \n\x00" gives the following 0000 C D À0I I&Add E ing 34 a E nd 17 gi A ves: C F orrect! A Assembler variant 2: Cross assembler A cross assembler is just an assembler that produces an object program for a system different from the one on which it itself runs An example would be using an assembler on an Intel-based Windows system to produce code for an appliance (eg, microwave or BMW or cellphone) that uses a non-intel CPU Often used when the target machine does not have a memory large enough to hold an assembler or perhaps where the target machine only exists on paper Reading Unfortunately, Warford does not have much on how the assembler works Section 51 has what little there is Comp 162 Notes Page 15 of 17 September 20, 2017
16 Review questions 1 How many bytes does the following directive occupy in the object program ascii \t\tthis is the result\n\n\x00 2 If we now hash ERROR into our example hash table, which entry does it occupy? 3 Consider example program 3 that outputs the average of a and b What modification to the Pep/9 guards against the possibility of a+b overflowing? 4 Consider example program 4 If we replace adda constant,i by adda 27,i and remove the line constant: equate 27 Does the object program get bigger, get smaller or stay the same? 5 Suppose we want to have synonyms for opcodes so that, if we wish we could write AS instead of ADDSP Which symbol table would have to change and what would that change be? 6 Consider the following program A: byte 4 B: block 4 C: ascii 4 D: byte 4 E: equate 4 Do any of the symbols have value 4? If so, which? 7 We have seen the STOP instruction; is there any use for a START instruction? 8 Some assembly languages let the user specify the place where the program is to start by having a label after thus Start How might such a feature in Pep/9 affect the object code and the way in which the Load and Execute commands work? Comp 162 Notes Page 16 of 17 September 20, 2017
17 Review answers 1 23 bytes 2 Hash (ERROR) is (5+18)%10 = 3 Entry 3 is full, entry 4 is full so it is inserted into entry 5 3 Have it compute a/2 + b/2 then add an additional 1 if both and b are odd Ie, a/2 + b/2 + (a and b and 1) 4 Stays the same the object programs are identical 5 We would add a line to the opcode table The new entry for AS would be the same as the entry for ADDSP in all fields except the mnemonic 6 Only E A has value 0, B has value 1, C has value 5 and D has value 6 7 Only to identify where the user would like the program to start Like NOP it would have no effect on memory or register 8 The object file would need to include the start address; perhaps changing the end of the file to something like nn nn nn xx nnnn zz The Load command would need to store the start address (nnnn) somewhere for the Execute command to pick up and use as the initial value of the Program Counter Comp 162 Notes Page 17 of 17 September 20, 2017
Wednesday, 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, 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 7, 2018
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
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 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 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 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, 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 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 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 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 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 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 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 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, 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 informationA rubric for programming assignments
Fall 2012 Comp 162 Peter Smith A rubric for programming assignments Generally, half the points for a program assignment are for the Correctness of the program with respect to the specification. The other
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 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, 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 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 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 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 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 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, September 28, 2015
Monda, September 28, 2015 Topics for toda Chapter 6: Mapping High-level to assembl-level The Pep/8 run-time stack (6.1) Stack-relative addressing (,s) SP manipulation Stack as scratch space Global variables
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, 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 informationMonday, August 28, 2017
Monday, August 28, 2017 Topics for today Course in context. Course outline, requirements, grading. Administrivia: Tutoring: Department, PLTL, LRC Knowledge Survey The concept of a multi-level machine Motivations
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 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 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 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 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 informationWednesday, November 8, 2017
Wednesday, November 8, 207 Topics for today Grammars and Languages (hapter 7) Finite State Machines Semantic actions ode generation - Overview Finite State Machines (see 7.2) If a language is regular (Type
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 informationWednesday, April 16, 2014
Wednesday, pril 16, 2014 Topics for today Homework #5 solutions Code generation nalysis lgorithm 4: infix to tree Synthesis lgorithm 5: tree to code Optimization HW #5 solutions 1. lda 0,i ; for sum of
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 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, 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 informationIntroduction. C provides two styles of flow control:
Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array
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 information(Refer Slide Time: 1:40)
Computer Architecture Prof. Anshul Kumar Department of Computer Science and Engineering, Indian Institute of Technology, Delhi Lecture - 3 Instruction Set Architecture - 1 Today I will start discussion
More informationCS , Fall 2004 Exam 1
Andrew login ID: Full Name: CS 15-213, Fall 2004 Exam 1 Tuesday October 12, 2004 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front.
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 information5. Control Statements
5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements
More informationWrite "Nell" Write "N" Write "e" Write "l" Write "l" Write "N" Write 4E (hex) Write "e" W rite 65 (hex) Write "l" W rite 6C (hex)
Chapter 7 Exercises 1. What does it mean when we say that a computer is a programmable device? Programmable means that data and instructions are logically the same and are stored in the same place. The
More informationReview of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates
CS 61C: Great Ideas in Computer Architecture MIPS Instruction Representation II Guest Lecturer: Justin Hsia 2/11/2013 Spring 2013 Lecture #9 1 Review of Last Lecture Simplifying MIPS: Define instructions
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
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 informationCh. 11: References & the Copy-Constructor. - continued -
Ch. 11: References & the Copy-Constructor - continued - const references When a reference is made const, it means that the object it refers cannot be changed through that reference - it may be changed
More informationCS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats
CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats Instructor: Justin Hsia 6/27/2012 Summer 2012 Lecture #7 1 Review of Last Lecture New registers: $a0-$a3, $v0-$v1, $ra, $sp Also: $at,
More informationECE 3120 Lab 1 Code Entry, Assembly, and Execution
ASSEMBLY PROGRAMMING WITH CODE WARRIOR The purpose of this lab is to introduce you to the layout and structure of assembly language programs and their format, as well as to the use of the Code Warrior
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 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 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 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 informationThe RAM Computation Model
Department of Computer Science and Engineering Chinese University of Hong Kong This is not a programming course. Take-away message 1 from this course Programming is the last step in software development,
More informationDuring the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.
Description of CPSC 301: This is a 2-unit credit/no credit course. It is a course taught entirely in lab, and has two required 2-hour 50-minute lab sessions per week. It will review, reinforce, and expand
More informationWhen an instruction is initially read from memory it goes to the Instruction register.
CS 320 Ch. 12 Instruction Sets Computer instructions are written in mnemonics. Mnemonics typically have a 1 to 1 correspondence between a mnemonic and the machine code. Mnemonics are the assembly language
More informationCS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and RISC-V Instruction Set Architecture
CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and RISC-V Instruction Set Architecture Instructors: Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c 9/7/17
More informationDiscussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:
Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;
More informationLecture #6 Intro MIPS; Load & Store
CS61C L6 Intro MIPS ; Load & Store (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #6 Intro MIPS; Load & Store 2007-7-3 Scott Beamer, Instructor Interesting Research on Social Sites
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 informationLecture #2 January 30, 2004 The 6502 Architecture
Lecture #2 January 30, 2004 The 6502 Architecture In order to understand the more modern computer architectures, it is helpful to examine an older but quite successful processor architecture, the MOS-6502.
More information1 Little Man Computer
1 Little Man Computer Session 5 Reference Notes CPU Architecture and Assembly 1.1 Versions Little Man Computer is a widely used simulator of a (very simple) computer. There are a number of implementations.
More informationLaboratory. Low-Level. Languages. Objective. References. Study simple machine language and assembly language programs.
Laboratory Low-Level 7 Languages Objective Study simple machine language and assembly language programs. References Software needed: 1) A web browser (Internet Explorer or Netscape) 2) Applet from the
More informationI ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place?
I ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place? here s the monitor, here goes the CPU, Do you need a class
More informationCS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference
More informationMonday, November 9, 2015
Monday, November 9, 2015 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview nalysis lgorithm 1: evaluation of postfix lgorithm 2: infix
More informationTopic Notes: MIPS Instruction Set Architecture
Computer Science 220 Assembly Language & Comp. Architecture Siena College Fall 2011 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture.
More informationCSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch
CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed
More informationLow-Level Programming Languages and Pseudocode
Chapter 6 Low-Level Programming Languages and Pseudocode Chapter Goals List the operations that a computer can perform Describe the important features of the Pep/8 virtual machine Distinguish between immediate
More informationDHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++
DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language
More informationELEG3924 Microprocessor
Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.2 Assembly Language Programming Dr. Jing Yang jingyang@uark.edu 1 OUTLINE Inside 8051 Introduction to assembly programming
More informationInteger primitive data types
ECE 150 Fundamentals of Programming Outline 2 Integer primitive data types In this lesson, we will: Learn the representation of unsigned integers Describe how integer addition and subtraction is performed
More informationELEG3923 Microprocessor Ch.2 Assembly Language Programming
Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.2 Assembly Language Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Inside 8051 Introduction to assembly programming
More informationHash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell
Hash Tables CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 22, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005
More informationswitch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++
Comp Sci 1570 Introduction to C++ Outline 1 Outline 1 Outline 1 switch ( e x p r e s s i o n ) { case c o n s t a n t 1 : group of statements 1; break ; case c o n s t a n t 2 : group of statements 2;
More informationThe Assembly Language Level. Chapter 7
The Assembly Language Level Chapter 7 Definitions Translator Converts user program to another language Source language Language of original program Target language Language into which source code is converted
More informationComputer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:
Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators
More informationAssembly Language Programming
Experiment 3 Assembly Language Programming Every computer, no matter how simple or complex, has a microprocessor that manages the computer s arithmetical, logical and control activities. A computer program
More informationWhere does the insert method place the new entry in the array? Assume array indexing starts from 0(zero).
Suppose we have a circular array implementation of the queue,with ten items in the queue stored at data[2] through data[11]. The current capacity of an array is 12. Where does the insert method place the
More informationassembler Machine Code Object Files linker Executable File
CSCE A211 Programming Intro What is a Programming Language Assemblers, Compilers, Interpreters A compiler translates programs in high level languages into machine language that can be executed by the computer.
More informationCS 430 Computer Architecture. C/Assembler Arithmetic and Memory Access William J. Taffe. David Patterson
CS 430 Computer Architecture C/Assembler Arithmetic and Memory Access William J. Taffe using notes of David Patterson 1 Overview C operators, operands Variables in Assembly: Registers Comments in Assembly
More informationUnified Engineering Fall 2004
Massachusetts Institute of Technology Department of Aeronautics and Astronautics Cambridge, MA 02139 Unified Engineering Fall 2004 Problem Set #3 Solutions C&P PSET 3 Solutions 1. 12
More informationRepetition CSC 121 Fall 2014 Howard Rosenthal
Repetition CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while
More informationMidterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 11, 2015
Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2015 November 11, 2015 Instructions This exam contains 8 pages, including this one. Make sure you have all the pages. Write your name on the top
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationEast Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005 Section
More information2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.
1) [ 9 marks] Write a sequence of directives for an HCS12 assembly language program that performs all of these tasks, in this order: a) Define an array called Measurements starting from memory location
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 informationCopyright 2000 N. AYDIN. All rights reserved. 1
Computer Architecture Prof. Dr. Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin A virtual processor for understanding instruction cycle The Visible Virtual Machine (VVM) 1 2 The
More informationCSE 378 Final Exam 3/14/11 Sample Solution
Name There are 8 questions worth a total of 100 points. Please budget your time so you get to all of the questions don t miss the short questions at the end. Keep your answers brief and to the point. Copies
More informationCSE 140L Spring 2010 Bonus Final
CSE 140L Spring 2010 Bonus Final Logistics for Bonus Final: This final should be done in individually. Use Xilinx tools version 10.1. What is due: - Report: o Submit a single report in.pdf form via email
More information... Executing conditional instructions
1 2 Executing conditional instructions Our design to this point has been the SISD (single instruction single data) architecture This is fine if we wish to execute in a purely sequential mode We now wish
More informationCS 101, Mock Computer Architecture
CS 101, Mock Computer Architecture Computer organization and architecture refers to the actual hardware used to construct the computer, and the way that the hardware operates both physically and logically
More informationLecture Transcript While and Do While Statements in C++
Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some
More information