Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng
|
|
- Merry Goodman
- 5 years ago
- Views:
Transcription
1 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
2 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 2/43 Contents ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
3 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 3/43 Outline of Slide Set 3 ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
4 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 4/43 Review of the ASCII character set Text in English can be represented using ASCII codes, which are integers in the range from 0 up to and including 127. Example ASCII codes... character ASCII code \0 0 \n 10! 33 A 65 a
5 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 5/43 How much memory for one ASCII code? Smallest ASCII code in base two: Largest ASCII code in base two: So, a single byte (8 bits) is more than large enough to hold any possible ASCII code. Typically, ASCII character strings are stored in memory in arrays of bytes and in file systems as sequences of bytes.
6 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 6/43 Unicode: Good to know about but not an ENCM 369 topic Text in most human languages requires characters outside the ASCII character set. (Think of text in Greek, Russian, Arabic, South Asian and East Asian languages, and so on....) Unicode is a system that attempts to represent all of the characters of most of the world s written languages, by, roughly speaking, assigning a unique integer a code point to each character (and assigning more unique integers to mostly regrettable emoji). At present there are roughly 120,000 different code points in Unicode = 65,536, so it s impossible to represent a sequence of code points using exactly two 8-bit bytes per code point.
7 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 7/43 UTF-32, UTF-16, and UTF-8 32 bits are more than enough to represent any possible Unicode code point. UTF-32 represents each code point as a 32-bit unsigned number. This is simple but wastes space. UTF-16 is used by Java, and is therefore important. In UTF-16 some characters are represented using single 16-bit chunks, while others are represented as pairs of 16-bit chunks. UTF-8 is in wide use. Some code points need only one byte in UTF-8, some need two bytes, some need three bytes, and, as of now, the rest need four. UTF-8 has two big advantages: (1) It s reasonably space-efficient, and (2) as a result of careful design, any sequence of characters encoded in ASCII is also a UTF-8 encoding of the same sequence of characters.
8 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 8/43 Errors on page 322 of Harris and Harris Our textbook says this: Other programming languages, such as Java, use different character encodings, most notably Unicode. Unicode uses 16 bits to represent each character, so it supports accents, umlauts, and Asian languages. That is disappointingly imprecise and inaccurate, especially in a textbook that is very clear and correct in most respects.
9 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 9/43 ASCII is the character set of ENCM 369 Unicode is interesting and important, but working with encodings such as UTF-16 and UTF-8 is complicated! (It s not really, really hard it just requires committing time to building understandings of many, many details.) To keep things as simple as possible in ENCM 369, we ll assume that character strings are represented in ASCII, one 8-bit byte per character.
10 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 10/43 Outline of Slide Set 3 ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
11 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 11/43 Bytes Within Memory Words in MIPS We ve already seen that each memory word can also be used as a group of four bytes with consecutive addresses. For example, consider the two words with addresses 0x and 0x What are the addresses of the bytes in these words? What would be the maximum length of a C character string stored in those bytes?
12 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 12/43 Preview of MIPS sb, lb, and lbu instructions The MIPS sb instruction writes a single byte within a 4-byte memory word, leaving the other 3 bytes unchanged. The MIPS lb and lbu instructions both read a single byte from within a 4-byte memory word. (We ll look at the difference between lb and lbu a bit later on.) Before studying these instructions in detail, let s look at the relationship between a byte in memory and the memory word that contains the byte.
13 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 13/43 Bit numbering within an n-bit pattern Here is the most usual and most convenient way to do this: the number of the MSB (most significant bit) is n 1; the number of the LSB (least significant bit) is 0. A general n-bit pattern is then b n 1 b n 2 b 2 b 1 b 0, where each b i is either 0 or 1. One reason why this is convenient is that it gives a natural, simple formula for the unsigned integer the bit pattern represents: b n 1 2 n 1 + b n 2 2 n b b b (The formula for the signed two s-complement integer the bit pattern represents is almost as simple, as we ll see later in the course.)
14 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 14/43 Bit numbering: examples Machine code for MIPS instruction addi $17, $16, A byte containing the ASCII code for A, which is 65 ten = 0x41 = two
15 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 15/43 Bit numbering, continued What you will always see in this course, in lectures, tutorials, labs, and the textbook: Bit n 1 is the MSB; bit 0 is the LSB. What you will see in most current real world computer system documentation: Bit n 1 is the MSB; bit 0 is the LSB. (Same as in this course.) Alternate schemes you might encounter: Bit 0 is the MSB; bit n 1 is the LSB. Bit n is the MSB; bit 1 is the LSB. Bit 1 is the MSB; bit n is the LSB.
16 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 16/43 Little-endian organization of bytes within words Little-endian is the name given to this way of addressing bytes within a word: numbers for bits within the word address offsets of bytes numbers for bits within bytes MARS has little-endian memory organization. So do some very important architectures, such as x86 and x There is another widely-used organization called big-endian; we ll study that much later in the course.
17 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 17/43 Bytes within words in MARS: a demonstration Use the editor to set up two strings of length 3. (So, 4 bytes per string.) Use to assemble the code. Data Segment display is... Use to show the actual characters...
18 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 18/43 Example: External arrays of bytes and words Two C arrays defined outside of function definitions... char foo[ ] = "hello"; int bar[ ] = { -10, 20, 30 }; One way to write MARS A.L. to set up these two arrays....data.globl foo foo:.byte h, e, l, l, o, \0.globl bar bar:.word -10, 20, -30 Note:.byte was used just to show its similarity to.word. It s usually more convenient to use.asciiz for strings.
19 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 19/43 Layout of foo and bar within the data segment Fragment of data segment used for foo and bar... higher addresses Why are these two bytes not used? l \0 l e o h bar[2] bar[1] bar[0] foo[4] foo[0] Access to elements of bar will be with lw and sw instructions, but access to elements of foo will use lb (or lbu) and sb.
20 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 20/43 Contents of foo and bar as 1 s and 0 s instead of symbols like h and -10 Fragment of data segment used for foo and bar... higher addresses bar[2] bar[1] bar[0] foo[4] foo[0] Of course, when the program runs, the 1 s and 0 s are high and low voltages at various nodes in a memory circuit.
21 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 21/43 Outline of Slide Set 3 ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
22 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 22/43 Byte loads and stores in MIPS: lb, lbu, and sb instructions lb and lbu: Both copy a byte from memory into bits 7 0 of a GPR. There is a difference in what happens to bits 31 8 of the GPR let s illustrate that with a picture. sb copies bits 7 0 from a GPR to a memory byte. Bits 31 8 of the GPR are ignored.
23 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 23/43 lb and lbu: examples Suppose that $s0 contains 0x ; the value of the byte at address 0x is 0x99; the value of the byte at address 0x a is 0x7e. What values will $t0 $t3 get? lb lbu lb lbu $t0, 0($s0) $t1, 0($s0) $t2, 1($s0) $t3, 1($s0)
24 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 24/43 sb: examples Suppose that $s1 contains 0x ; $t0 contains 0x What will these instructions do? sb $t0, ($s1) sb $t0, 1($s1)
25 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 25/43 Which to use: lb or lbu? If you know that the byte being read is an ASCII code, it doesn t matter bit 7 of the byte will be 0, so lb and lbu have the same effect. An example on page 324 of the textbook uses lb, but would work equally well if lbu were used instead. Examples in ENCM 369 lectures, labs, and tutorials will use lbu, to be consistent with examples used in the course over the last few years.
26 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 26/43 Why do lb and lbu both exist? (part 1) Sometimes arrays of bytes are used not for character codes but for collections of integers with small magnitudes. We re not going to study that in detail right now. The difference between lb and lbu has to do with rules for converting 8-bit integers into 32-bit integers with either sign-extension for signed numbers or zero-extension for unsigned numbers.
27 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 27/43 Why do lb and lbu both exist? (part 2) lb does the right thing when an array of bytes is used as a collection of signed char numbers with values from the set { 128, 127,..., 1, 0, 1,..., 126, 127}. lbu does the right thing when an array of bytes is used as a collection of unsigned char numbers with values from the set {0, 1, 2,..., 253, 254, 255}. For more about signed and unsigned number systems, see textbook Section 1.4 (which was covered early in ENEL 353 in Fall 2017) and ENCM 369 lectures in future weeks.
28 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 28/43 Byte access programming example void my_strcpy(char *dest, const char *src) { while (*src!= \0 ) { *dest = *src; dest++; src++; } *dest = \0 ; } This is like the strcpy function in the standard C library, except that my_strcpy does not return a value. Let s write a MIPS A.L. translation for my_strcpy.
29 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 29/43 Mixing word and byte accesses to memory Usually, data written as bytes is later read back as bytes; data written as words is later read back as words. However, studying code that mixes access types helps to check whether you understand exactly how byte addressing works. Suppose that $s0 contains 0x What will $t2 contain after these instructions are executed...? addi addi sw sb sb lw $t0, $zero, 0xab $t1, $zero, 0xcd $zero, 4($s0) $t0, 7($s0) $t1, 5($s0) $t2, 4($s0)
30 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 30/43 Outline of Slide Set 3 ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
31 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 31/43 A complex stack frame example int g(char *p, int n); int h(int *q, int j, int k); int f(void) { int a, b; char x[5]; int y[4]; a = g(x, 5); b = h(y, 4, a); // MORE CODE: uses a, b, &b, // x, y, but NEVER &a. return b; }
32 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 32/43 Complex stack frame example: Questions How to allocate a, b, x, and y? What are the stack frame needs for f? What will be the layout of the stack frame? What will be the A.L. code for a = g(x, 5);? What will be the A.L. code for b = h(y, 4, a);? Attention: The lecture will skip writing the prologue and epilogue for f. Make sure you know what code would be needed!
33 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 33/43 Outline of Slide Set 3 ASCII and Unicode Bytes Within Memory Words in MIPS Byte loads and stores in MIPS: lb, lbu, and sb A Complex Stack Frame Example Logical Instructions
34 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 34/43 Logical Instructions Textbook Section sll: shift left, logical (already seen) srl: shift right, logical or, ori: bitwise OR ( bitwise means operate on multiple pairs of input bits in parallel ) lui: copy 16-bit constant into bits of GPR and, andi: bitwise AND nor: bitwise NOR xor, xori: bitwise XOR
35 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 35/43 srl: shift right, logical srl is like sll, but shifts right instead of left. Example: Suppose $t0 = 24 zeros Then what does srl $t1, $t0, 3 put in $t1?
36 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 36/43 or, ori OR truth table for one pair of input bits: x y OR(x,y) MIPS or and ori instructions do 32 simultaneous OR operations on 32 pairs of bits.
37 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 37/43 Logical instructions: or example or $t2, $t0, $t1... Suppose $t0 contains 1101_[24 zeros]_0011 and $t1 contains 0001_[24 zeros]_0101. The result, which goes into $t2, is...?
38 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 38/43 Logical instructions: or vs. add Attention: bitwise OR is not addition! The OR of 1 and 1 is 1. The arithmetic SUM of 1 and 1 is 0, with a CARRY of 1. Previous example, with or changed to add... $t0 contents _[24 zeros]_0011 $t1 contents _[24 zeros]_0101 result, goes to $t _[24 zeros]_1000 The add result is not the same as the or result!
39 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 39/43 Logical instructions: ori ori: one source is a GPR, the other is a constant. Example: ori $t4, $t3, 0x895a Suppose $t3 contains 0xab00_0034. What value does $t4 get?
40 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 40/43 Logical instructions: lui lui: load upper immediate This copies a constant into bits of a GPR, and makes bits 15 0 of the GPR zero. Example: lui $t0, 0xf7b3 What value does $t0 get?
41 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 41/43 lui and big constants Suppose i is an int in $s0. What would the instruction(s) be for this? i = 0x49b1_ae09; The constant is too big to embed in a single instruction, so the job gets split into two instructions: lui $s0, 0x49b1 # update bits ori $s0, $s0, 0xae09 # update bits 15-0 What is in $s0 after lui? After ori?
42 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 42/43 lui, ori, li, la li is a MIPS pseudoinstruction for getting a large constant into a GPR. Example: li $s0, 0x49b1ae09 gets translated into what we just saw... lui ori $s0, 0x49b1 $s0, $s0, 0xae09 The assembler handles pseudoinstructions of the form la GPR, label in a similar way.
43 ENCM 369 Winter 2018 Section 01 Slide Set 3 slide 43/43 Logical instructions: and, andi, nor, xor, xori These are easy to understand if you understand or and ori. Read Section of the textbook for details and examples.
Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides
Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section
More informationSlide 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 informationSlide 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 informationContents. 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 informationSlide 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 informationENCM 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 informationSlide 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 informationSlide 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#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 informationENCM 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 informationT02 Tutorial Slides for Week 2
T02 Tutorial Slides for Week 2 ENEL 353: Digital Circuits Fall 2017 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 19 September, 2017
More informationSlide 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 informationWinter 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 informationComputer 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 informationCSCI 402: Computer Architectures
CSCI 402: Computer Architectures Instructions: Language of the Computer (2) Fengguang Song Department of Computer & Information Science IUPUI Memory Operands Two tribes: Big Endian: Most-significant byte
More informationENCM 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 informationSlide 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 informationComputer Organization and Components
Computer Organization and Components IS1500, fall 2016 Lecture 2: Assembly Languages Associate Professor, KTH Royal Institute of Technology Slides version 1.0 2 Course Structure Module 1: C and Assembly
More informationECE 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 informationChapter 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 informationECE260: Fundamentals of Computer Engineering
Accessing and Addressing Memory James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy American
More informationInteger 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 informationQ1: /30 Q2: /25 Q3: /45. Total: /100
ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam One September 19 th 2013 This is a closed book, closed note texam. Calculators are not permitted. Please work the exam in pencil and
More informationWe 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 informationSlides 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 informationECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationIntroduction 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 informationWinter 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 informationSlide 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 informationSlide 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 informationMIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions
Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register
More informationSlide Set 4. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 4 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 informationChapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface RISC-V Edition Chapter 2 Instructions: Language of the Computer These slides are based on the slides by the authors. The slides doesn t
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 informationContents 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 informationSlide 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 informationCS 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 informationENCM 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 informationCS3350B Computer Architecture MIPS Instruction Representation
CS3350B Computer Architecture MIPS Instruction Representation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada
More informationMIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"
MIPS Hello World MIPS Assembly 1 # PROGRAM: Hello, World!.data # Data declaration section out_string:.asciiz "\nhello, World!\n".text # Assembly language instructions main: # Start of code section li $v0,
More informationMIPS ProgramTemplate
MIPS Load and Store Instructions Cptr280 Dr Curtis Nelson MIPS ProgramTemplate # Comment giving name of program and description of function # Template.s # Bare-bones outline of MIPS assembly language program.data
More informationUniversity 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 informationInstructions: Language of the Computer
Instructions: Language of the Computer Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class
More informationSlide Set 5. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary
Slide Set 5 for ENEL 353 Fall 207 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 207 SN s ENEL 353 Fall 207 Slide Set 5 slide
More informationSlide 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 informationRISC-V Assembly and Binary Notation
RISC-V Assembly and Binary Notation L02-1 Course Mechanics Reminders Course website: http://6004.mit.edu All lectures, videos, tutorials, and exam material can be found under Information/Resources tab.
More informationICS 233 Computer Architecture & Assembly Language. ICS 233 Computer Architecture & Assembly Language
ICS 233 Computer Architecture & Assembly Language MIPS PROCESSOR INSTRUCTION SET 1 ICS 233 Computer Architecture & Assembly Language Lecture 7 2 1 Lecture Outline MIPS Instruction I-Type Format MIPS I-type
More informationENCM 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 informationENCM 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 information101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009
101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix
More informationCOMP 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 informationComputer Architecture
CS3350B Computer Architecture Winter 2015 Lecture 4.2: MIPS ISA -- Instruction Representation Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design,
More informationLaboratory Exercise 6 Pipelined Processors 0.0
Laboratory Exercise 6 Pipelined Processors 0.0 Goals After this laboratory exercise, you should understand the basic principles of how pipelining works, including the problems of data and branch hazards
More informationECE 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 informationSlide 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 informationInstruction Set Architecture part 1 (Introduction) Mehran Rezaei
Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a
More informationChapter 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 informationComputer 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 informationComputer Organization Lab #3.
Computer Organization Lab #3 https://sites.google.com/a/fci-cu.edu.eg/cs322/ Lab 3 Objectives Review on previous labs Memory Instructions Variables Load/store instructions Announce Assignment 2 Refresh
More informationAssembly 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 information2.1 DOWNLOAD AND INSTALL MARS
L a b # 2 T H E R U D I M E N T S O F M I P S A S S E M B L Y L A N G U A G E Instructor: I Putu Danu Raharja. Objectives: Describe the general structure of MIPS assembly language programs. Learn to read
More informationECE260: Fundamentals of Computer Engineering
Accessing and Addressing Memory James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy American
More informationComputer 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 informationECE 15B Computer Organization Spring 2010
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 7: Procedures I Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy, and classes taught by and
More informationMemory. CS 447, Spring /25/16. Memory. Processor (CPU) transfer
CS 447, Spring 2016 small number of registers instrucfons operate on operands in registers need memory space to hold data and text 1 Fetch, Execute fetch s (reads) instrucfon from memory to CPU Where is
More informationInstruction encoding. MIPS Instruction encoding
Instruction encoding The ISA defines The format of an instruction (syntax) The meaning of the instruction (semantics) Format = Encoding Each instruction format has various fields Opcode field gives the
More informationComputer Architecture Instruction Set Architecture part 2. Mehran Rezaei
Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter
More informationWinter 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 informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationSlides 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 informationECE260: Fundamentals of Computer Engineering
MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS
More informationInstruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers
CSE 675.02: Introduction to Computer Architecture MIPS Processor Memory Instruction Set Architecture of MIPS Processor CPU Arithmetic Logic unit Registers $0 $31 Multiply divide Coprocessor 1 (FPU) Registers
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationCS 61c: Great Ideas in Computer Architecture
Introduction to Assembly Language June 30, 2014 Review C Memory Layout Local variables disappear because the stack changes Global variables don t disappear because they are in static data Dynamic memory
More informationWinter 2002 FINAL EXAMINATION
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Note for Winter 2005 students Winter
More informationProcessor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4
Processor Han Wang CS3410, Spring 2012 Computer Science Cornell University See P&H Chapter 2.16 20, 4.1 4 Announcements Project 1 Available Design Document due in one week. Final Design due in three weeks.
More informationCOMPUTER ORGANIZATION AND DESIGN
COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer
More informationECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
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 informationSlide 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 informationSlides for Lecture 15
Slides for Lecture 5 ENEL 353: Digital Circuits Fall 203 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October, 203 ENEL 353 F3 Section
More informationCSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.
CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned
More informationChapter 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 informationComputer Systems Architecture
Computer Systems Architecture http://cs.nott.ac.uk/ txa/g51csa/ Thorsten Altenkirch and Liyang Hu School of Computer Science and IT University of Nottingham Lecture 05: Comparisons, Loops and Bitwise Operations
More informationECE260: Fundamentals of Computer Engineering
MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS
More informationSlide 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 informationComputer Organization and Structure. Bing-Yu Chen National Taiwan University
Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing
More informationFive classic components
CS/COE0447: Computer Organization and Assembly Language Chapter 2 modified by Bruce Childers original slides by Sangyeun Cho Dept. of Computer Science Five classic components I am like a control tower
More informationA Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3
A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 2.16-20, 4.1-3 Announcements! HW2 available later today HW2 due in one week and a half Work alone
More informationsyscall takes a service ID (number) in $v0 Read integer $v0=5, after syscall, $v0 holds the integer read from keyboard
Interacting with the OS We need the OS s help!!! How to print a number? (output) How to read a number? (input) How to terminate (halt) a program? How to open, close, read, write a file? These are operating
More informationComputer Organization and Structure. Bing-Yu Chen National Taiwan University
Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing
More informationSlide 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 informationTopic Notes: Bits and Bytes and Numbers
Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for
More informationOverview. 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 information3. Instruction Set Architecture The MIPS architecture
3. Instruction Set Architecture The MIPS architecture EECS 370 Introduction to Computer Organization Winter 2007 Prof. Valeria Bertacco & Prof. Scott Mahlke EECS Department University of Michigan in Ann
More informationBranch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015
Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative
More informationMark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA
EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible
More informationProblem 3: Theoretical Questions: Complete the midterm exam taken from a previous year attached at the end of the assignment.
CSE 2021: Computer Organization Assignment # 1: MIPS Programming Due Date: October 25, 2010 Please note that a short quiz based on Assignment 1 will be held in class on October 27, 2010 to assess your
More informationA Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3
A Processor Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 2.16-20, 4.1-3 Let s build a MIPS CPU but using Harvard architecture Basic Computer System Registers ALU
More information