Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Size: px
Start display at page:

Download "Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides"

Transcription

1 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 01 Slide Set 1 slide 2/79 Contents About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language MIPS Assembly Language Programming: Getting Started ENCM 369 W14 Section 01 Slide Set 1 slide 3/79 Outline of Slide Set 1 ENCM 369 W14 Section 01 Slide Set 1 slide 4/79 About these slides About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language MIPS Assembly Language Programming: Getting Started This is the first of around ten large sets of slides that will be used for lectures in Section 01 of ENCM 369 in Winter 2014 It will usually take several lectures to get through a single set of slides For example, I expect that it will take about 5 1 lectures to get through this first set 2 Reading these slides online is not a good subsitute for attending lectures in most lectures I will do some important hand-written work using the document camera Please come to lectures prepared to take some notes ENCM 369 W14 Section 01 Slide Set 1 slide 5/79 Typographical conventions Either bold text or bright red text will be used for emphasis The typewriter font will usually be used for code in assembly language, C, or C++ (I might not use the typewriter font for code if it makes the code too wide to fit in a slide) Text in a box is a general description of what could appear within a piece of code Example: A C do statement has this syntax do statement while ( expression ); (Usually statement is a compound statement that starts with { and ends with } ) ENCM 369 W14 Section 01 Slide Set 1 slide 6/79 Typographical conventions: Italics Italics will be used two different ways One word or a few words in italics will be used to formally or informally define a term Example: A bit is the basic unit of information in a digital system; the value of a bit is either 0 or 1 An entire sentence in italics indicates a pause to elaborate a concept or solve a problem under the document camera Example: Let s translate the C statement into a sequence of assembly language instructions

2 ENCM 369 W14 Section 01 Slide Set 1 slide 7/79 Outline of Slide Set 1 ENCM 369 W14 Section 01 Slide Set 1 slide 8/79 Organization of a Simple Computer About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language Processor Bus Main Memory Device What is a bus? What is the role of the processor? MIPS Assembly Language Programming: Getting Started Device ENCM 369 W14 Section 01 Slide Set 1 slide 9/79 Organization of a Simple Computer: ENCM 369 W14 Section 01 Slide Set 1 slide 10/79 Main memory Bus Main Memory What does stand for? Main memory is a collection of electronic circuits that hold instructions and data of running programs (Hey, what s an instruction?) Processor Device Device What are examples of devices in laptop or desktop computers? What are examples of devices in embedded computers? Main memory in a desktop or laptop is RAM ( random access memory ), not the hard drive (Typically, the hard drive contains mostly files not currently in use by any running program) RAM is volatile storage information in RAM is lost when a computer is powered down ENCM 369 W14 Section 01 Slide Set 1 slide 11/79 Bytes ENCM 369 W14 Section 01 Slide Set 1 slide 12/79 Models of Engineering Systems A bit is the smallest possible item of digital data A bit has a value of 0 or 1 A byte is a collection of eight bits Example byte values, written in base two: and Unfortunately, bit and byte are very similar words be careful not to mix up their meanings! How many different bit patterns are possible for the value of a byte? Definition: A model is a simplified description of a system that allows people to understand and predict the behaviour of the system Often, models are collections of equations (especially differential equations) For computer systems, models are likely to be informal but detailed pictures and stories explaining how systems work

3 ENCM 369 W14 Section 01 Slide Set 1 slide 13/79 Models: Deeper Understanding and Better Prediction ENCM 369 W14 Section 01 Slide Set 1 slide 14/79 Simple model of main memory: A giant array of bytes Sometimes, an existing model can be enhanced made more accurate by adding details, such as extra terms in equations, or more complex stories about components Other times, an existing model is inaccurate about something important and the model has to be replaced with a new, better model There may be thousands or millions or billions of bytes in the array Each byte in the array has a unique address, which is just a number To advance from one byte to the next byte in memory, add 1 to the address A variable of type char* (pointer-to-char) in a C or C++ program is a container for the address of a byte ENCM 369 W14 Section 01 Slide Set 1 slide 15/79 Registers: Storage of bytes inside the processor A register is a storage location for one or more bytes (typically a group of two, four, or eight bytes) inside the processor So registers are NOT part of main memory, because main memory is external to the processor processor registers bus main memory device device ENCM 369 W14 Section 01 Slide Set 1 slide 16/79 Avoid using the word memory when describing a register! This can be confusing A register is definitely a kind of memory system, in the sense that a pattern of 1 s and 0 s can be written into a register and later read back from that register However, in discussion of computer organization, memory usually means main memory, which is outside the processor, and does not include the registers inside the processor ENCM 369 W14 Section 01 Slide Set 1 slide 17/79 Processors have relatively SMALL numbers of registers ENCM 369 W14 Section 01 Slide Set 1 slide 18/79 Replacing a model from ENCM 339 Example: In the x86-64 architecture, used by processors in current Macs, and PCs running 64-bit Windows or Linux, there are 16 eight-byte general-purpose registers (GPRs) (So, how many bits are there in an x86-64 GPR?) Another example: In the MIPS32 architecture there are 32 four-byte GPRs Total capacity of registers is TINY compared to main memory capacity! Model: All variables and function arguments in a running C or C++ programs are in main memory, in regions called the stack, static storage, and the free store (or heap) This model is very helpful in understanding C and C++ code, but in ENCM 369 you must stop believing it! Why won t this model work in ENCM 369?

4 ENCM 369 W14 Section 01 Slide Set 1 slide 19/79 Key terms: Memory Read and Memory Write ENCM 369 W14 Section 01 Slide Set 1 slide 20/79 Memory Reads and Memory Writes, continued Memory read operation: The processor puts a memory address on the bus A group of bytes (usually one, two, four or eight) in memory gets copied from memory to a register, via the bus Memory write operation: The processor puts a memory address on the bus A group of bytes (usually one, two, four or eight) in memory gets copied from a register to memory, via the bus What component is choosing the address in a read operation? What component is choosing the address in a write operation? Why is only one address needed when there is a read or write of two or more bytes? ENCM 369 W14 Section 01 Slide Set 1 slide 21/79 The Simplest Useful Model for How a Computer Works ENCM 369 W14 Section 01 Slide Set 1 slide 22/79 The Simplest Useful Model for How a Computer Works: Key Questions There are two steps Let s write descriptions for these steps The processor performs Step 1, Step 2, Step 1, Step 2, Step 1, Step 2, forever (or until the computer is turned off) In Step 1, how does the processor decide what address to use to get an instruction? In Step 2, what kinds of action can be performed by the processor in executing an instruction? ENCM 369 W14 Section 01 Slide Set 1 slide 23/79 Flow of instructions (What memory address is used in Step 1?) ENCM 369 W14 Section 01 Slide Set 1 slide 24/79 Flow of instructions: if statements, loops, and function calls The picture shows 9 bytes within the giant array of bytes that is main memory Suppose that the processor is about to read Instruction A What happens next? lower addresses higher addresses Instruction A (3 bytes) Instruction B (2 bytes) Instruction C (4 bytes) It would be impossible to create useful programs if processors always read and executed instructions in the order in which the instructions appeared in main memory What kinds of special instructions allow program pieces like if statements, loops, and function calls to work?

5 ENCM 369 W14 Section 01 Slide Set 1 slide 25/79 Registers (Review) ENCM 369 W14 Section 01 Slide Set 1 slide 26/79 Uses for GPRs and memory A register is a storage location for one or more bytes (typically a group of two, four, or eight bytes) inside the processor So registers are NOT part of main memory, because main memory is external to the processor processor registers bus main memory device device Reminder: GPR stands for general-purpose register A GPR can hold either an integer (a C int or unsigned int) or a memory address (a C pointer) GPRs hold a small amount of a running program s data (Here data means variables and function arguments) Memory holds the rest of the program s data usually much more than what is in the GPRs and all of the program s instructions ENCM 369 W14 Section 01 Slide Set 1 slide 27/79 Examples of tasks performed in executing an instruction (or What happens in Step 2? ) Suppose we have the C statement foo = x + y + z; where all the variables are ints What sequence of instructions could be used to make this statement work? ENCM 369 W14 Section 01 Slide Set 1 slide 28/79 Outline of Slide Set 1 About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language MIPS Assembly Language Programming: Getting Started ENCM 369 W14 Section 01 Slide Set 1 slide 29/79 MIPS processors ENCM 369 W14 Section 01 Slide Set 1 slide 30/79 Why study the MIPS architecture in ENCM 369? Designed by a company called MIPS (wwwmipscom) Manufactured under license by many different companies Today, used mostly in embedded systems, such as digital cameras, network hardware, automotive applications, GPS receivers, In 1980 s and 1990 s, used for desktop workstations produced by DEC and SGI It s easier to learn and understand than the x86 and x86-64 architectures (used in PCs and Macs) or ARM architectures (used in smartphones, tablets, lots of other products) It has many properties in common with x86, x86-64, ARM, and other major architectures Our textbook is MIPS-based!

6 ENCM 369 W14 Section 01 Slide Set 1 slide 31/79 Variations of MIPS ENCM 369 W14 Section 01 Slide Set 1 slide 32/79 Memory is really organized in words, not bytes In this course, we ll study the MIPS-32 version We ll just say MIPS in this course, but we really mean MIPS-32 In MIPS-32 GPRs are 32 bits wide Memory addresses are 32 bits wide Instructions are 32 bits wide Memory words are 32 bits wide There are related MIPS-16 and MIPS-64 architectures, but we won t study those in detail A simple model presented about 18 slides back says: main memory is a giant array of bytes A more complex and accurate model that we ll start using now says: Bytes in main memory are grouped together in multi-byte pieces called words, and memory should be thought of as a giant array of words Much later in the course, we will study more complex models of main memory, involving concepts of caches and virtual memory ENCM 369 W14 Section 01 Slide Set 1 slide 33/79 Different architectures have different word sizes Word size Word size Example (bytes) (bits) systems 2 16 PCs and Macs of 1980 s low-power embedded systems 4 32 MIPS-32 PCs, Macs, until a few years ago many embedded systems 8 64 servers current game consoles current PCs and Macs ENCM 369 W14 Section 01 Slide Set 1 slide 34/79 MIPS-32 memory organization: An array of 32-bit words Each word is four bytes the address of a word is the lowest of the addresses of its bytes What are the addresses of word X, byte Y, and byte Z? word address byte offset byte Z byte Y word X ENCM 369 W14 Section 01 Slide Set 1 slide 35/79 Address spaces and regions within address spaces ENCM 369 W14 Section 01 Slide Set 1 slide 36/79 A model for MIPS memory access The address space of a computer system is the set of all possible memory addresses The previous slide showed the MIPS-32 address space Why is the largest word address in the MIPS-32 address space? A typical program ignores most of the address space The program uses only a few regions within the address space typically one region for instructions, and two or three regions for data MIPS processor registers logical address 32 address translation Bus control signals? physical address 32 data or instruction 32 Main Memory (big array of words)

7 ENCM 369 W14 Section 01 Slide Set 1 slide 37/79 A model for MIPS memory access (continued) ENCM 369 W14 Section 01 Slide Set 1 slide 38/79 Alignment restrictions in MIPS: word addresses must be multiples of 4 What are some examples of control signals, and how might they be used? What does address translation mean? Example 1: How is the bus used to bring an instruction into the processor? Example 2: How is the bus used when the processor updates a byte in a character string in memory? byte offset word address ,194, consecutive 4,194, bytes, but NOT 4,194,312 a word ,194, a word 4,194,304 ENCM 369 W14 Section 01 Slide Set 1 slide 39/79 More about alignment ENCM 369 W14 Section 01 Slide Set 1 slide 40/79 Outline of Slide Set 1 Addresses of 16-bit MIPS halfwords must be multiples of 2 Most processor families have alignment rules, such as: 16-bit chunks must have addresses that are multiples of 2 32-bit chunks must have addresses that are multiples of 4 64-bit chunks (such as C doubles) must have addresses that are multiples of 8 Alignment rules simplify the design of memory hardware About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language MIPS Assembly Language Programming: Getting Started ENCM 369 W14 Section 01 Slide Set 1 slide 41/79 Introduction to MIPS registers, machine language and assembly language ENCM 369 W14 Section 01 Slide Set 1 slide 42/79 MIPS registers that are NOT GPRs Let s start with the GPRs (general-purpose registers) (Remember, registers are inside the processor, not part of main memory!) MIPS has 32 general-purpose registers (GPRs) Each GPR is 32 bits wide, and can hold either a C int or a memory address (C pointer) The GPRs are numbered from 0 to 31 They also have names we ll learn the names soon There are 16 floating-point point registers (FPRs), each 64 bits wide Each can hold a C double (We ll learn more about floating-point numbers and FPRs near the end of the course) There are also several special-purpose registers, including a very important one called the PC (program counter)

8 ENCM 369 W14 Section 01 Slide Set 1 slide 43/79 MIPS instruction size ENCM 369 W14 Section 01 Slide Set 1 slide 44/79 The Program Counter (PC) Each instruction is exactly one word in size (How many bits is that? How many bytes?) (In the ARM instruction set, instructions are, as in MIPS, all 4 bytes in size In contrast, instructions in the x86 instruction set vary in size from one byte to 17 bytes) A fixed instruction size simplifies hardware design, but having varying sizes sometimes results in smaller program size In this course you will have to determine from context whether PC means personal computer or program counter! The MIPS PC is a 32-bit special-purpose register that holds the address of the next instruction to be read from memory Instruction pointer would be a better name than program counter! But program counter is the standard name in MIPS and many other architectures ENCM 369 W14 Section 01 Slide Set 1 slide 45/79 The PC and the Simplest Useful Model for How a Computer Works Step 1: Processor reads instruction from memory Step 2: Processor executes the instruction (The instruction is a very simple command) The processor performs Step 1, Step 2, Step 1, Step 2, Step 1, Step 2, forever (or until the computer is turned off) What are Steps 1 and 2 in terms of the PC and the MIPS memory model? ENCM 369 W14 Section 01 Slide Set 1 slide 46/79 Review of hexadecimal numbers, notation for hexadecimal numbers As you learned in ENEL 353, hexadecimal means base sixteen Using the notation of ENEL 353, here s an example: 50CD 16 = = = In ENCM 369 we ll use 0x (digit 0, not letter O) to indicate hexadecimal constants, because that notation is used in C, C++, many assembly languages, and many other programming languages Example: In C, this expression is true 0x50cd == ENCM 369 W14 Section 01 Slide Set 1 slide 47/79 Notation in ENCM 369 for numbers with lots of digits ENCM 369 W14 Section 01 Slide Set 1 slide 48/79 A typical MIPS instruction Underscores separate groups of digits Groups of digits are whatever size is convenient Examples one billion: , in hexadecimal: 0x7fff_ffff Let s call this example (1): Add values of GPR 8 and GPR 9, copy result into GPR 17 The bits for example (1) _01000_01001_10001_00000_ What do the groups of bits within the instruction mean?

9 ENCM 369 W14 Section 01 Slide Set 1 slide 49/79 More example instructions ENCM 369 W14 Section 01 Slide Set 1 slide 50/79 Processor-memory interaction for 3 kinds of MIPS instructions Example (2): Add constant 1025 and value of GPR 18, copy result into GPR 10 Example (3): Copy word of memory pointed to by GPR 4 into GPR 8 (This is a load word instruction) Example (4): Copy byte of memory pointed to by GPR 4 into GPR 8 (This is a load byte instruction) MIPS processor logical address 32 registers address translation main memory control signals? data/instruction physical address Let s use 6 copies of this diagram to trace Steps 1 and 2 for three instructions ENCM 369 W14 Section 01 Slide Set 1 slide 51/79 Processor-memory interaction for 3 kinds of MIPS instructions, continued The instructions will be example (1), an add instruction; example (3), an lw instruction; an sw (store word) instruction, which copies a word from a GPR to memory, using another GPR value as an address Very important! Know this as soon as possible: lw (load word) copies data from memory to a GPR sw (store word) copies data from a GPR to memory ENCM 369 W14 Section 01 Slide Set 1 slide 52/79 Programming in Machine Language A program is a sequence of instructions, and each instruction is a bit pattern With a manual describing the bit patterns for all of the instructions available on a computer, you could write a program by composing bit patterns, one instruction at a time This method of building a program is called programming in machine language The earliest computers had to be programmed in machine language there was no software available for any other method of programming! ENCM 369 W14 Section 01 Slide Set 1 slide 53/79 Assembly Language ENCM 369 W14 Section 01 Slide Set 1 slide 54/79 Things you will see in an A L (assembly language) file Composing machine language is tedious and slow It s easier from humans to write instructions with a text editor and let a translator program determine the bit patterns This kind of translator program is called an assembler the input to the assembler is called assembly language Descriptions of instructions, one instruction per line Directives for allocation and initialization of static data Other important kinds of information

10 ENCM 369 W14 Section 01 Slide Set 1 slide 55/79 Syntax for instructions in A L, examples of MIPS A L instructions ENCM 369 W14 Section 01 Slide Set 1 slide 56/79 Historic uses of Assembly Language What is the general form of an A L instruction? What would the MIPS A L be for the machine language examples we saw previously? (1) add GPRs 8 and 9, put result in GPR 17 (2) add GPR 8 and constant 1025, put result in GPR 10 (3) copy memory word pointed to by GPR 4 into GPR 8 (4) copy memory byte pointed to by GPR 4 into GPR 8 For decades, entire programs were written in AL Examples: Operating systems for industry-dominating IBM mainframes (1960 s) Microsoft MS-DOS and many important applications for MS-DOS Many, many pieces of embedded system software ENCM 369 W14 Section 01 Slide Set 1 slide 57/79 Why write an entire program in AL? ENCM 369 W14 Section 01 Slide Set 1 slide 58/79 Modern reasons to know AL It used to be true that human-written A L programs could be smaller and faster than equivalent high-level language (HLL) programs This reason is now obsolete good modern compilers can usually generate smaller, more efficient instruction sequences than most humans can write in AL 1 Certain small pieces of programs are better written in AL than in a HLL 2 Old AL programs may need to be debugged or enhanced 3 Students programming in AL develop precise models for what a processor does and what a compiler does Reason 3 is why you will read and write a lot of AL in ENCM 369 ENCM 369 W14 Section 01 Slide Set 1 slide 59/79 Reasons to avoid programming in AL ENCM 369 W14 Section 01 Slide Set 1 slide 60/79 Outline of Slide Set 1 Cost: Compared to C and other HLLs, AL takes more time to write and is much harder to read and debug Lack of portability: Good C code is portable: It can be compiled to run on many different processor families AL code is processor-specific for example, a program written in MIPS AL can not be made to run efficiently on an x86 computer About these slides Organization of a Simple Computer Introduction to the MIPS-32 Computer Architecture Introduction to MIPS registers, machine language and assembly language MIPS Assembly Language Programming: Getting Started

11 ENCM 369 W14 Section 01 Slide Set 1 slide 61/79 MIPS Assembly Language Programming: Getting Started Let s start with some names and uses for MIPS GPRs $0 is also known as $zero It has unique, possibly surprising behaviour: It always contains the number 0, regardless of what is done with it Suppose $16 and $17 contain values 20 and 30 What happens as a result of these instructions? add $18, $16, $17 add $0, $16, $17 ENCM 369 W14 Section 01 Slide Set 1 slide 62/79 Names and uses for some MIPS GPRs, continued $16 $23 are known as $s0 $s7 and are often (but not always) used for local variables of procedures (Procedure is a general name for things like C functions) (Remember, contrary to models given in ENCM 339, some variables and functions are in GPRs, not main memory) $8 $15, $24, and $25 are known as $t0 $t9 and are often (but not always) used as temporaries storage for intermediate results More complete rules for use of $s0 $s7 and $t0 $t9 will be presented later in the course ENCM 369 W14 Section 01 Slide Set 1 slide 63/79 Example uses of s-registers and t-registers variable register a $s0 b $s1 c $s2 d $s3 e $s4 f $s5 Suppose GPRS are allocated for 6 int variables as shown in the table What are AL translations for the statements below? // statement one a = 0; // statement two b = (c - d) + (e - f); ENCM 369 W14 Section 01 Slide Set 1 slide 64/79 MIPS AL syntax for lw (load word) and sw (store word) Review: load means copy data from memory to a register, store means copy data from a register to memory Syntaxes for the instructions are lw destination, address sw source, address destination in lw must be a GPR source in sw must be a GPR Let s make some notes about the syntax for address ENCM 369 W14 Section 01 Slide Set 1 slide 65/79 Array elements, registers, and memory ENCM 369 W14 Section 01 Slide Set 1 slide 66/79 Example AL code for array element access Memory words all have addresses Registers DO NOT HAVE ADDRESSES! (Registers can contain addresses, but that s not the same thing!) How does array element access work? What does that imply about whether arrays can be in registers or in memory? Suppose $s0 is used for p, of type int* (pointer-to-int) Suppose $s1 is used for k, of type int What would be a correct AL translation for the C code below? p[10] = p[20] + k; (This requires that p points to the start of an array of at least 21 int elements You re expected to know about using pointers to access array elements from ENCM 339!)

12 ENCM 369 W14 Section 01 Slide Set 1 slide 67/79 Decision-making and branch instructions ENCM 369 W14 Section 01 Slide Set 1 slide 68/79 Labels in AL To write AL that works like a C if statement, we need an instruction that causes a skip forward if some condition is true Example C code, where x, y, z are all ints: if (x == y) z = 0; z = z + x; Suppose x is in $s0, y is in $s1, and z is in $s2 What would be a correct MIPS AL translation? L1 in the previous AL code is an example of a label A label is used to give a name to an instruction or an item of static data (See Lab 2 for examples of labels for static data) A label names the next instruction or data item listed in the AL code, regardless of comments or blank lines ENCM 369 W14 Section 01 Slide Set 1 slide 69/79 In each example below, L1 is a label for the add instruction ENCM 369 W14 Section 01 Slide Set 1 slide 70/79 Branch and jump instructions Example 1 Example 2 Example 3 L1: L1: add $s2, $s2, $s0 L1: # Here are add $s2, $s2, $s0 # some comments # and blank lines add $s2, $s2, $s0 The style of Example 1 saves vertical space The style of Example 2 may be more readable (The style of Example 3 is silly but allowed by the assembler) We made you write lots of goto statements in C in Lab 1 because that should help you quickly understand branches and jumps! Branch (general concept): goto an instruction, but only if some condition is true Jump (general concept): goto an instruction, without checking any condition ENCM 369 W14 Section 01 Slide Set 1 slide 71/79 beq, bne, and j: three of the many branch and jump instructions available in MIPS ENCM 369 W14 Section 01 Slide Set 1 slide 72/79 A few terms: jump target, taken, branch target beq GPR 1, GPR 2, label meaning: if ( GPR 1 == GPR 2 ) goto label bne GPR 1, GPR 2, label meaning: if ( GPR 1!= GPR 2 ) goto label The target of a jump instruction is defined as the instruction to be executed after the jump instruction (So the AL label in a MIPS j instruction is the label of the jump target) A branch instruction is said to be taken if the condition tested by the branch is true The target of a branch is the instruction that will be executed next if the branch is taken j label meaning: goto label

13 ENCM 369 W14 Section 01 Slide Set 1 slide 73/79 How do jumps and branches fit into The Simplest Useful Model? ENCM 369 W14 Section 01 Slide Set 1 slide 74/79 One way to code a C while loop in AL: branch at the top, jump at the bottom The model, for MIPS Step 1: Using PC contents as an address, read instruction word from memory, add 4 to PC Step 2: Execute the instruction Repeat Step 1, Step 2, Step 1, Step 2, and so on, forever Using the terms target and taken, what are more precise descriptions of Step 2 for MIPS j, beq, and bne instructions? Let s translate this example into MIPS AL sum = 0; i = 0; while (i!= n) { sum += a[i]; i++; } // more code variable type GPR a int * $s0 n int $s1 sum int $s2 i int $s3 ENCM 369 W14 Section 01 Slide Set 1 slide 75/79 Branches and comparisons: the MIPS slt instruction ENCM 369 W14 Section 01 Slide Set 1 slide 76/79 Using the sll (shift left logical) instruction to multiply by a power of 2 What if we want to branch to some label, say, L42, if $s0 < $s1? Neither bne nor beq will work! A two-instruction sequence is needed: slt $t0, $s0, $s1 # $t0 = ($s0 < $s1) bne $t0, $zero, L42 # if ($t0) goto L42 slt means set on less than In the example, if $s0 < $s1, $t0 gets a value of 1, otherwise $t0 gets 0 slt is a kind of comparison instruction From the while loop example: sll $t0, $s3, 2 # $t0 = 4 * $s3 Why does this work? To start, let s find out what sll does The syntax is sll dest GPR, source GPR, constant The instruction takes the bit pattern from the source, shifts it left by constant bit positions, and puts the result in the destination ENCM 369 W14 Section 01 Slide Set 1 slide 77/79 Why does left shift do multiplication? ENCM 369 W14 Section 01 Slide Set 1 slide 78/79 Pseudoinstructions in MIPS AL In base ten, think about computing , then computing How is this related to multiplication in base two? Let s write some MIPS examples of multiplication using the sll instruction Later in the course we ll find that MIPS has multiply instructions However, sll is more convenient for the special case of multiplying by a power of two These are convenient for AL programmers, but a little confusing for beginners A pseudoinstruction is a line of AL that looks like a MIPS instruction but does not correspond exactly to a MIPS machine instruction The assembler handles a pseudoinstruction by generating real instructions that have the appropriate effect

14 ENCM 369 W14 Section 01 Slide Set 1 slide 79/79 Pseudoinstructions in MIPS AL, continued Example: blt $s0, $s1, L1 MIPS does not have a single instruction that can do both a less than comparison and a branch decision What does the assembler do with this blt pseudoinstruction? In ENCM 369 we want to learn real instructions, so we ll avoid pseudoinstructions whenever possible However, certain pseudoinstructions for example, la, used in Lab 2 are impossible to avoid

Slide Set 1 (corrected)

Slide Set 1 (corrected) Slide Set 1 (corrected) for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018

More information

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs

Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs Slide Set 2 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 information

Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 1 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 1 slide 2/43

More information

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 5 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 information

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary February 2018 ENCM 369 Winter 2018 Section

More information

Slides for Lecture 6

Slides for Lecture 6 Slides for Lecture 6 ENCM 501: Principles of Computer Architecture Winter 2014 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 28 January,

More information

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 9 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9 slide 2/41 Contents Slide Set 9 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

More information

Slide Set 8. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 8. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 8 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

ENCM 369 Winter 2017 Lab 3 for the Week of January 30 page 1 of 11 ENCM 369 Winter 2017 Lab 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Lab instructions and other documents for

More information

Integer Multiplication and Division

Integer Multiplication and Division Integer Multiplication and Division for ENCM 369: Computer Organization Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 208 Integer

More information

Slide Set 7. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng

Slide Set 7. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng Slide Set 7 for ENCM 501 in Winter Term, 2017 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2017 ENCM 501 W17 Lectures: Slide

More information

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 11 for ENCM 369 Winter 2015 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2015 ENCM 369 W15 Section

More information

#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.

#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page. page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2018 MIDTERM TEST #1 #2 with

More information

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro 1 Levels of Representation/Interpretation Machine Interpretation High Level Language Program (e.g., C) Compiler Assembly

More information

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng Slide Set 1 for ENEL 339 Fall 2014 Lecture Section 02 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2014 ENEL 353 F14 Section

More information

(Refer Slide Time: 1:40)

(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 information

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

ENCM 369 Winter 2019 Lab 6 for the Week of February 25 page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM

More information

Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Chapter 3. Instructions:

Chapter 3. Instructions: Chapter 3 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Topic Notes: MIPS Instruction Set Architecture

Topic 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 information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

More information

Slides for Lecture 15

Slides for Lecture 15 Slides for Lecture 15 ENCM 501: Principles of Computer Architecture Winter 2014 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 6 March,

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

More information

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Machine Interpretation

More information

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from: Instructions: Chapter 3 : MIPS Downloaded from: http://www.cs.umr.edu/~bsiever/cs234/ Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

More information

CS 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 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 information

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department

More information

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1 Chapter 3 MIPS Assembly Language Ó1998 Morgan Kaufmann Publishers 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

More information

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures $2M 3D camera Lecture 8 MIPS Instruction Representation I Instructor: Miki Lustig 2014-09-17 August 25: The final ISA showdown: Is ARM, x86, or

More information

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop.

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop. CSC258 Week 10 Logistics Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop. Quiz review A word-addressable RAM

More information

Introduction to Scientific Computing

Introduction to Scientific Computing Introduction to Scientific Computing Dr Hanno Rein Last updated: October 12, 2018 1 Computers A computer is a machine which can perform a set of calculations. The purpose of this course is to give you

More information

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 1 for ENEL 353 Fall 2017 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2017 SN s ENEL 353 Fall 2017 Slide Set 1 slide

More information

Assembly Programming

Assembly Programming Designing Computer Systems Assembly Programming 08:34:48 PM 23 August 2016 AP-1 Scott & Linda Wills Designing Computer Systems Assembly Programming In the early days of computers, assembly programming

More information

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01

More information

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 B CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 DUE : March 3, 2014 READ : - Related sections of Chapter 2 - Related sections of Chapter 3 - Related sections of Appendix A - Related sections

More information

We will study the MIPS assembly language as an exemplar of the concept.

We will study the MIPS assembly language as an exemplar of the concept. MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and

More information

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson. CS61C - Machine Structures Lecture 6 - Instruction Representation September 15, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ 1 Review Instructions: add, addi, sub, lw, sw beq, bne, j

More information

Winter 2017 MIDTERM TEST #1 Wednesday, February 8 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.

Winter 2017 MIDTERM TEST #1 Wednesday, February 8 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page. page 1 of 5 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2017 MIDTERM TEST #1 Wednesday,

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

ENCM 369 Winter 2016 Lab 11 for the Week of April 4

ENCM 369 Winter 2016 Lab 11 for the Week of April 4 page 1 of 13 ENCM 369 Winter 2016 Lab 11 for the Week of April 4 Steve Norman Department of Electrical & Computer Engineering University of Calgary April 2016 Lab instructions and other documents for ENCM

More information

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly ECPE 170 Jeff Shafer University of the Pacific MIPS Assembly 2 Lab Schedule This Week Activities MIPS discussion Practice problems (whiteboard) Using the QtSPIM simulator Discuss available resources Lab

More information

LAB 7 Writing Assembly Code

LAB 7 Writing Assembly Code Goals To Do LAB 7 Writing Assembly Code Learn to program a processor at the lowest level. Implement a program that will be used to test your own MIPS processor. Understand different addressing modes of

More information

COMP MIPS instructions 2 Feb. 8, f = g + h i;

COMP MIPS instructions 2 Feb. 8, f = g + h i; Register names (save, temporary, zero) From what I have said up to now, you will have the impression that you are free to use any of the 32 registers ($0,..., $31) in any instruction. This is not so, however.

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

More information

Machine 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 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 information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Functions July 1, 2014 Review I RISC Design Principles Smaller is faster: 32 registers, fewer instructions Keep it simple: rigid syntax, fixed instruction length MIPS Registers: $s0-$s7,$t0-$t9, $0

More information

CS61C Machine Structures. Lecture 13 - MIPS Instruction Representation I. 9/26/2007 John Wawrzynek. www-inst.eecs.berkeley.

CS61C Machine Structures. Lecture 13 - MIPS Instruction Representation I. 9/26/2007 John Wawrzynek. www-inst.eecs.berkeley. CS61C Machine Structures Lecture 13 - MIPS Instruction Representation I 9/26/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L13 MIPS Instruction Representation

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

CS 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 information

ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering ECE 30 Introduction to Computer Engineering Study Problems, Set #3 Spring 2015 Use the MIPS assembly instructions listed below to solve the following problems. arithmetic add add sub subtract addi add

More information

Winter 2003 MID-SESSION TEST Monday, March 10 6:30 to 8:00pm

Winter 2003 MID-SESSION TEST Monday, March 10 6:30 to 8:00pm University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2003 MID-SESSION TEST Monday,

More information

Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm

Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructor for L01 and L02: Dr. S. A. Norman Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium

More information

Programmable Machines

Programmable Machines Programmable Machines Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T. Quiz 1: next week Covers L1-L8 Oct 11, 7:30-9:30PM Walker memorial 50-340 L09-1 6.004 So Far Using Combinational

More information

Slide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 5 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2016 ENCM 339 Fall 2016 Slide Set 5 slide 2/32

More information

Winter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page.

Winter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page. University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: S. A. Norman and N. R. Bartley Winter 2012 MID-SESSION TEST Tuesday, March 6

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 13 MIPS Instruction Representation I New 160 Megapixel camera!! The Seitz 6 x 17 panorama camera sells for $36K, and produces a 21,250 x

More information

ENCM 501 Winter 2017 Assignment 3 for the Week of January 30

ENCM 501 Winter 2017 Assignment 3 for the Week of January 30 page 1 of 7 ENCM 501 Winter 2017 Assignment 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Assignment instructions and other

More information

Computer Organization and Components

Computer Organization and Components 2 Course Structure Computer Organization and Components Module 4: Memory Hierarchy Module 1: Logic Design IS1500, fall 2014 Lecture 4: and F1 DC Ö1 F2 DC Ö2 F7b Lab: dicom F8 Module 2: C and Associate

More information

ECE 154A Introduction to. Fall 2012

ECE 154A Introduction to. Fall 2012 ECE 154A Introduction to Computer Architecture Fall 2012 Dmitri Strukov Lecture 4: Arithmetic and Data Transfer Instructions Agenda Review of last lecture Logic and shift instructions Load/store instructionsi

More information

ENCM 501 Winter 2015 Assignment 3 for the Week of February 2

ENCM 501 Winter 2015 Assignment 3 for the Week of February 2 page 1 of 6 ENCM 501 Winter 2015 Assignment 3 for the Week of February 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2015 Assignment instructions and other

More information

Programmable Machines

Programmable Machines Programmable Machines Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T. Quiz 1: next week Covers L1-L8 Oct 11, 7:30-9:30PM Walker memorial 50-340 L09-1 6.004 So Far Using Combinational

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2) Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

More information

ENCM 369 Winter 2015 Lab 6 for the Week of March 2

ENCM 369 Winter 2015 Lab 6 for the Week of March 2 page of 2 ENCM 369 Winter 25 Lab 6 for the Week of March 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 25 Lab instructions and other documents for ENCM 369

More information

EE108B Lecture 2 MIPS Assembly Language I. Christos Kozyrakis Stanford University

EE108B Lecture 2 MIPS Assembly Language I. Christos Kozyrakis Stanford University EE108B Lecture 2 MIPS Assembly Language I Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b 1 Announcements EE undergrads: EE108A and CS106B Everybody else: E40 and CS106B (or equivalent)

More information

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations CS6C L9 MIPS Logical & Shift Ops, and Instruction Representation I () inst.eecs.berkeley.edu/~cs6c CS6C : Machine Structures Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I 25-9-28

More information

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor

More information

ENCM 501 Winter 2015 Tutorial for Week 5

ENCM 501 Winter 2015 Tutorial for Week 5 ENCM 501 Winter 2015 Tutorial for Week 5 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 11 February, 2015 ENCM 501 Tutorial 11 Feb 2015 slide

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Instruction Formats July 2, 2014 Review New registers: $a0-$a3, $v0-$v1, $ra, $sp New instructions: slt, la, li, jal, jr Saved registers: $s0-$s7, $sp, $ra Volatile registers: $t0-$t9, $v0-$v1, $a0-$a3

More information

ENCM 369 Winter 2018 Lab 9 for the Week of March 19

ENCM 369 Winter 2018 Lab 9 for the Week of March 19 page 1 of 9 ENCM 369 Winter 2018 Lab 9 for the Week of March 19 Steve Norman Department of Electrical & Computer Engineering University of Calgary March 2018 Lab instructions and other documents for ENCM

More information

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Guest Lecturer Alan Christopher Lecture 08 MIPS Instruction Representation I 2014-02-07 BOINC MORE THAN JUST SETI@HOME BOINC (developed here

More information

Chapter 2. Instruction Set Architecture (ISA)

Chapter 2. Instruction Set Architecture (ISA) Chapter 2 Instruction Set Architecture (ISA) MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code:

More information

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010 ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010 This homework is to be done individually. Total 9 Questions, 100 points 1. (8

More information

Instructions: Assembly Language

Instructions: Assembly Language Chapter 2 Instructions: Assembly Language Reading: The corresponding chapter in the 2nd edition is Chapter 3, in the 3rd edition it is Chapter 2 and Appendix A and in the 4th edition it is Chapter 2 and

More information

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization Review I Prof. Michel A. Kinsy Computing: The Art of Abstraction Application Algorithm Programming Language Operating System/Virtual Machine Instruction Set Architecture (ISA)

More information

Slide Set 6. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 6. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 6 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2017 ENCM 339 Fall 2017 Section 01 Slide

More information

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition BASIC COMPUTER ORGANIZATION Silberschatz, Galvin and Gagne 2009 Topics CPU Structure Registers Memory Hierarchy (L1/L2/L3/RAM) Machine Language Assembly Language Running Process 3.2 Silberschatz, Galvin

More information

Slide Set 4. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 4. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 4 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 4 slide

More information

University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructor: Steve Norman

University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructor: Steve Norman page of 9 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructor: Steve Norman Winter 26 FINAL EXAMINATION (with corrections) Location: ICT 2

More information

CSCI 402: Computer Architectures. Instructions: Language of the Computer (4) Fengguang Song Department of Computer & Information Science IUPUI

CSCI 402: Computer Architectures. Instructions: Language of the Computer (4) Fengguang Song Department of Computer & Information Science IUPUI CSCI 402: Computer Architectures Instructions: Language of the Computer (4) Fengguang Song Department of Computer & Information Science IUPUI op Instruction address 6 bits 26 bits Jump Addressing J-type

More information

MIPS Assembly: More about Memory and Instructions CS 64: Computer Organization and Design Logic Lecture #7

MIPS Assembly: More about Memory and Instructions CS 64: Computer Organization and Design Logic Lecture #7 MIPS Assembly: More about Memory and Instructions CS 64: Computer Organization and Design Logic Lecture #7 Ziad Matni Dept. of Computer Science, UCSB Lecture Outline Global variables and memory Arrays

More information

Computer Architecture Prof. Mainak Chaudhuri Department of Computer Science & Engineering Indian Institute of Technology, Kanpur

Computer Architecture Prof. Mainak Chaudhuri Department of Computer Science & Engineering Indian Institute of Technology, Kanpur Computer Architecture Prof. Mainak Chaudhuri Department of Computer Science & Engineering Indian Institute of Technology, Kanpur Lecture - 7 Case study with MIPS-I So, we were discussing (Refer Time: 00:20),

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory 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 information

ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections)

ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections) page 1 of 5 ENCM 501 Winter 2018 Assignment 2 for the Week of January 22 (with corrections) Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2018 Assignment instructions

More information

Slide Set 8. for ENCM 501 in Winter Steve Norman, PhD, PEng

Slide Set 8. for ENCM 501 in Winter Steve Norman, PhD, PEng Slide Set 8 for ENCM 501 in Winter 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 501 Winter 2018 Slide Set 8 slide

More information

Computer Architecture I Midterm I

Computer Architecture I Midterm I Computer Architecture I Midterm I April 11 2017 Computer Architecture I Midterm I Chinese Name: Pinyin Name: E-Mail... @shanghaitech.edu.cn: Question Points Score 1 1 2 12 3 16 4 14 5 18 6 17 7 22 Total:

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

Final Programming Project

Final Programming Project Due Thursday, Dec. 7, at 5:00 pm Logistics This assignment should be completed in groups of 3. This is not optional -- you are not allowed to complete it on your own, or in groups of any other size. I

More information

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

Instructions: Language of the Computer

Instructions: Language of the Computer CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

More information

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 $zero all bits are zero 16 $s0 local variable 1 $at assembler temporary 17 $s1 local

More information

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 3 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 3 slide 2/46

More information