Wednesday, September 21, 2016
|
|
- Doreen Ramsey
- 6 years ago
- Views:
Transcription
1 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 equate Assembler variants: Disassembler, Cross assembler High-level language and To further reinforce ideas about mapping high-level constructs into, here are nine more examples of programs and their possible translations 1 int a,b,c; input(a,b) c=a+b; output (c); deci a,d deci b,d lda a,d adda b,d ; a + b sta c,d deco c,d a: block 2 b: block 2 c: block 2 2 int a,c; input(a); c=a+5; output(c); deci a,d lda a,d adda five,i ; a + 5 sta c,d deco c,d a: block 2 c: block 2 five:equate 5 Comp 162 Notes Page 1 of 17 September 21, 2016
2 3 int a,b,c; input (a,b); c=(a+b)/2; output (c); deci b,d lda a,d adda b,d asra sta c,d deco c,d a: block 2 b: block 2 c: block 2 ; (a+b)/2 4 int a; input(a); output (3*a+27); deci a,d lda a,d asla ; 2a adda a,d ; 3a adda constant,i ; 3a+27 sta a,d ; used for result deco a,d a: block 2 constant:equate 27 5 int a,b; input(a,b); output("the sum is "); output(a+b); deci a,d deci b,d lda a,d adda b,d sta 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 21, 2016
3 6 int a,b; input (a,b); output(a); output(" + " ); output(b); output(" = " ); output(a+b); deci a,d deci b,d lda a,d adda b,d sta 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 int a; input(a); a = a + a%4; output(a); deci a,d lda a,d anda 3,i ; a%4 adda a,d ; a+a%4 sta a,d deco a,d a: block 2 Comp 162 Notes Page 3 of 17 September 21, 2016
4 8 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); } br main score: block 2 exam1: block 2 exam2: block 2 bonus: equate 10 main: stro prompt,d deci exam1,d deci exam2,d lda exam1,d adda exam2,d asra adda bonus,i sta 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 21, 2016
5 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 lda a,d asra asra sta result,d ; a/4 lda b,d anda 31,i adda result,d sta result,d ; a/4 + b%32 lda c,d asla adda c,d adda result,d suba 24,i sta 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 21, 2016
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 So a typical assembler reads the source program twice (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 21, 2016
7 Entries in the opcode table would 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 STr 1110raaa Yes 3 d,s,x,n,sf,sx,sxf STOP No 1 BR a Yes 3 i,x 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 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 Comp 162 Notes Page 7 of 17 September 21, 2016
8 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 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 being 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 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 is: ( rank(1 st character) + rank(last character) ) % table-size The following shows the value of this function for some typical identifiers assuming table addresses ranging from 0 to 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 Comp 162 Notes Page 8 of 17 September 21, 2016
9 Index Contents Value COUNT 4 LAB 5 6 TOP 7 8 N 9 LOOP Assembler operation: Pass 1 Typically, Pass 1 does the majority of the error checking of the source program In the case of, 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 If we are translating the following program by hand charo A,d charo B,d A: byte H B: byte I We can figure the translation of the first line is 3 bytes (and will occupy bytes 0,1,2 in memory), the translation of the second line is also three bytes (bytes 3, 4 and 5) the translation of the third line occupies one byte (byte 6) So the symbol A is a label on byte 7 and therefore the value of the symbol A is 7 Similarly the value of B is 8 We could replace the first line of the program by charo 7,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 Comp 162 Notes Page 9 of 17 September 21, 2016
10 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 lda 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 limitations? Large block declarations work The following program assembles lda 1,i x: block y: block 2 Comp 162 Notes Page 10 of 17 September 21, 2016
11 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 it is relatively straightforward Here are some examples of lines and the number of bytes its translation takes up in the object program Line Bytes byte 4 1 ascii "*" 1 asra 1 word 0 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 N N Comp 162 Notes Page 11 of 17 September 21, 2016
12 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 * 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 assembler will detect an error in a line, the error message it gives may not be the best indicator of what the error is For example, when erroneous operand is present main: asra 2;ERROR: Comment expected 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 LDA M,d Translates to = C0 00 0F LDr A d <value of symbol M> Comp 162 Notes Page 12 of 17 September 21, 2016
13 We assume that in order to do the error checking of Pass 1 and the translation of Pass 2, the table of opcodes contains information such as the following (see Figure 52) Symbol Template Operand Bytes Modes Allowed ROLr r Yes 1 STr 1110raaa Yes 3 d,s,x,n,sf,sx,sxf STOP No 1 Error detection in Pass 2 In 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 can address all memory Comp 162 Notes Page 13 of 17 September 21, 2016
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 207) We cannot in general perform a reverse translation of an object program because data and instructions are indistinguishable in memory For example, in and subsp 2,i translates to byte h word 2 translates to Comp 162 Notes Page 14 of 17 September 21, 2016
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 used in assembly, it may be able to make the translation a little more readable In, a memory dump shows the (printable) ASCII characters For example, a memory dump of ; test program lda 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 À0A A&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 21, 2016
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 hash table, which entry does it occupy? 3 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? 4 Suppose we want to have synonyms for opcodes so that, if we wish we could write LA instead of LDBYTEA Which symbol table would have to change and what could that change be? 5 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? Comp 162 Notes Page 16 of 17 September 21, 2016
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 Stays the same the object programs are identical 4 We would add a line to the opcode table The new entry for LA would be the same as the entry for LDBYTEA in all fields except the mnemonic 5 Only E A has value 0, B has value 1, C has value 5 and D has value 6 Comp 162 Notes Page 17 of 17 September 21, 2016
Wednesday, 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 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 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 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, 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, 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 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 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 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 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 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 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, 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 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 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 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 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 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 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 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 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, 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, 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 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, 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 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, 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 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 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, 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationLecture 7: Examples, MARS, Arithmetic
Lecture 7: Examples, MARS, Arithmetic Today s topics: More examples MARS intro Numerical representations 1 Dealing with Characters Instructions are also provided to deal with byte-sized and half-word quantities:
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 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 informationECE 206, Fall 2001: Lab 3
ECE 206, : Lab 3 Data Movement Instructions Learning Objectives This lab will give you practice with a number of LC-2 programming constructs. In particular you will cover the following topics: - Load/store
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 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 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 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 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 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 informationLogistics. IIT CS 350 S '17 - Hale
Logistics Remember: Lab 5 due next week not this week. Finish it early though so you can move on to Lab 6! Lab 2 grades in BB Required reading posted (Patt & Patel Ch. 5) First exam during class next Wednesday
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 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 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 informationOverview COMP Microprocessors and Embedded Systems. Lecture 11: Memory Access - I. August, 2003
Overview COMP 3221 Microprocessors and Embedded Systems Memory Access in Assembly Data Structures in Assembly Lecture 11: Memory Access - I http://www.cse.unsw.edu.au/~cs3221 August, 2003 Saeid@unsw.edu.au
More informationMicrocontroller Systems
µcontroller systems 1 / 43 Microcontroller Systems Engineering Science 2nd year A2 Lectures Prof David Murray david.murray@eng.ox.ac.uk www.robots.ox.ac.uk/ dwm/courses/2co Michaelmas 2014 µcontroller
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 informationMonday, April 14, 2014
Monday, April 14, 2014 Topics for today Grammars and Languages (Chapter 7) Finite State Machines Semantic actions Code generation - Overview Analysis Algorithm 1: evaluation of postfix Algorithm 2: infix
More informationCSC 220: Computer Organization Unit 12 CPU programming
College of Computer and Information Sciences Department of Computer Science CSC 220: Computer Organization Unit 12 CPU programming 1 Instruction set architectures Last time we built a simple, but complete,
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 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 informationBrought to you by CalLUG (UC Berkeley GNU/Linux User Group). Tuesday, September 20, 6-8 PM in 100 GPB.
Hate EMACS? Love EMACS? Richard M. Stallman, a famous proponent of opensource software, the founder of the GNU Project, and the author of emacs and gcc, will be giving a speech. We're working on securing
More informationLecture #6 Intro MIPS; Load & Store Assembly Variables: Registers (1/4) Review. Unlike HLL like C or Java, assembly cannot use variables
CS61C L6 Intro MIPS ; Load & Store (1) Hate EMACS? Love EMACS? Richard M. Stallman, a famous proponent of opensource software, the founder of the GNU Project, and the author of emacs and gcc, will be giving
More information3.0 Instruction Set. 3.1 Overview
3.0 Instruction Set 3.1 Overview There are 16 different P8 instructions. Research on instruction set usage was the basis for instruction selection. Each instruction has at least two addressing modes, with
More informationWriting ARM Assembly. Steven R. Bagley
Writing ARM Assembly Steven R. Bagley Introduction Previously, looked at how the system is built out of simple logic gates Last week, started to look at the CPU Writing code in ARM assembly language Assembly
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 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 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 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 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 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 informationSparse Notes on an MIPS Processor s Architecture and its Assembly Language
Sparse Notes on an MIPS Processor s Architecture and its Assembly Language February 6, 2004 1 Introduction In this notes we are not going in details with the architecture of an MIPS processor, but only
More informationThe Little Man Computer - Interface
The Little Man Computer - Interface 1. Assembly Language goes here 2. Click ʻCompileʼ 3. Instructions appear as 3-digit opcodes here 4. You can RUN the program, watch it run SLOWly or STEP through the
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 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 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 informationCPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)
Name Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Relational Expression Iteration Counter Count-controlled loop Loop Flow
More informationInstruction Sets: Characteristics and Functions Addressing Modes
Instruction Sets: Characteristics and Functions Addressing Modes Chapters 10 and 11, William Stallings Computer Organization and Architecture 7 th Edition What is an Instruction Set? The complete collection
More informationProvided by - Microsoft Placement Paper Technical 2012
Provided by www.yuvajobs.com - Microsoft Placement Paper Technical 2012 1. Analytical 25 questions ( 30 minutes) 2. Reasoning 25 questions (25 minutes) 3. Verbal 20 questions (20 minutes) Analytical (some
More informationSyntax of LC-3 assembly: Language elements. Instructions
LC-3 Assembly Language (Textbook Chapter 7) Assembly and assembler Machine language - binary 0001110010000110 Assembly language - symbolic ADD R6, R2, R6 ; increment index reg. Assembler is a program that
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationComputer Software: Introduction
Software: A collection of programs Computer Software: Introduction Program: Sequence of instructions for the computer to carry out Programs written using a programming language Types of languages: Machine
More informationSchool of Computer Science & Software Engineering The University of Western Australia. Mid-Semester Test September 2017
School of Computer Science & Software Engineering The University of Western Australia Mid-Semester Test September 2017 () This paper contains 1 section This paper contains: 8 pages (including this title
More informationCOSC 243. Assembly Language Techniques. Lecture 9. COSC 243 (Computer Architecture)
COSC 243 Assembly Language Techniques 1 Overview This Lecture Source Handouts Next Lectures Memory and Storage Systems 2 Parameter Passing In a high level language we don t worry about the number of parameters
More information