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

Size: px
Start display at page:

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

Transcription

1 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

2 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 2/63 Contents Encoding of MIPS branch and jump instructions Building and running executables starting from C source code Linking and Libraries Notes about some confusing words

3 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 3/63 Outline of Slide Set 4 Encoding of MIPS branch and jump instructions Building and running executables starting from C source code Linking and Libraries Notes about some confusing words

4 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 4/63 Encoding of MIPS branch and jump instructions (Textbook, Section 6.5.) Previous lectures and Lab 2 showed machine code for instructions like add, sub, addi, lw, sw. How is machine code organized for beq, bne, j, jal, jr?

5 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 5/63 Encoding of beq and bne A 6-bit opcode tells what kind of instruction it is. Two 5-bit fields specify which registers to compare. A 16-bit offset field indicates how many instructions to skip forward or back. Note: Unlike load and store offsets, a branch offset counts words, not bytes.

6 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 6/63 The Simplest Model for How a Computer Works and MIPS branch instructions The model is: Perform Step 1, Step 2, Step 1, Step 2,..., forever. For MIPS, Step 1 is: Read the instruction the PC points to, then do PC = PC + 4. If the instruction turns out to be a branch, then Step 2 is: if (branch should be taken) PC = PC + 4 branch offset else do nothing Attention: By the time Step 2 starts, the PC = PC + 4 update in Step 1 has already taken place.

7 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 7/63 beq encoding example What is the MIPS machine code for each of the beq instructions? L1: beq $t0, $t1, L2 # first branch lw $t2, ($t0) add $t3, $t3, $t2 addi $t0, $t0, 4 beq $zero, $zero, L1 # second branch L2: sw $t3, ($s0)

8 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 8/63 Branch encoding and assemblers Assemblers can compute the offset between a branch instruction and its target instruction. (In the previous example, the target of first branch is the sw instruction.) So, humans can use labels as operands in beq and bne. So, humans avoid the pain of writing A.L. for first branch and second branch as and beq $t0, $t1, 4 beq $zero, $zero, -5 (Counting instructions would be painful. Updating the counts correctly when you insert or delete instructions would be more painful, and very hard to do perfectly.)

9 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 9/63 Machine code for j and jal opcode... address field bit number: Both instructions use this format: 6-bit opcode ( for j, for jal); 26-bit address field giving part of the address of the target instruction.

10 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 10/63 PC updates in j and jal A jump can be thought of as updating the PC register with something other than the usual PC+4. The PC update for MIPS j and jal is this: OLD PC: these 26 bits will change 0 0 bit number: bits get copied NEW PC: copy of address field from j or jal instruction 0 0 bit number:

11 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 11/63 Processing of j or jal: example Suppose instruction 0x0c10_0020 is located at address 0x0040_0064. What is the address of the next instruction to be run? Does $ra get updated, and if so, with what?

12 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 12/63 Encoding of j and jal, compared to beq or bne Attention: To encode a j or jal instruction, the address of the jump target must be known. This is unlike encoding beq or bne, in which it is enough to know how many instructions to skip forward or back the exact address of the branch target does not have to be known.

13 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 13/63 Encoding of jr Bits and 5 0 together indicate that this is a jr instruction. The number of the GPR used is encoded in bits So, what is the machine code for jr $ra? (By the way, bits 20 6 don t have any particular use in a jr instruction.) 0 0

14 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 14/63 Outline of Slide Set 4 Encoding of MIPS branch and jump instructions Building and running executables starting from C source code Linking and Libraries Notes about some confusing words

15 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 15/63 Building and running executables starting from C source code Here we consider real programming environments such as Linux, macos, and Windows, not simulated environments like MARS. Examples are focused on C, but are quite applicable to C++ as well. Java works quite differently we won t look at Java in ENCM 369. Textbook reference: Section 6.6. However, note this warning: Section 6.6 oversimplifies things. Contrary to the example on page 339, an assembler won t be able to decide on absolute addresses of procedures and global variables. (Don t worry if this warning doesn t make sense the first time you see it it should make more sense once we get to slide 41 or so.)

16 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 16/63 Building and running C programs: a note about the word compiler Definition One: A compiler is a program that translates high-level language to assembly language. Definition Two: A compiler is a package of programs and other files that can be used to develop software. Example: Apple s Xcode is the compiler used for development of iphone apps. (Such a package includes a compiler, in the Definition One sense of that term.) In ENCM 369, Definition One applies when we use the word compiler.

17 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 17/63 Building and running C programs: tools and the toolchain Tools are programs that read input files and write output files. Preprocessor: tool to convert C code into rearranged or edited C code. Compiler: tool to translate C code into assembly language.

18 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 18/63 Building and running C programs: tools and the toolchain, continued Assembler: tool to create an object file using assembly language input. (Wait, what does object file mean?) Linker: tool to combine object files and information from library files to make an executable file. (Wait, what are the meanings of library files and executable file?) Together, preprocessor, compiler, assembler, and linker make a chain of tools.

19 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 19/63 Building and running C programs: many kinds of files C source code files:.c and.h files written by a programmer as part of a specific program. Library header files:.h files provided to give information about types and functions defined in the library. (Example file: stdio.h. Example types and functions: FILE, fopen, fprintf, printf.)

20 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 20/63 Building and running C programs: many kinds of files, continued Translation unit: File that is output from the preprocessor, which modifies C code according to directives like #include, #define, #ifdef, etc. When you use gcc on Linux, translation units (.i files) usually don t get saved permanently. The same is true with Cygwin64 on Windows and for translation units produced in most other C and C++ development systems. So you ve probably never noticed them.

21 Preprocessor inputs: C source files /* file foo.h */ int foo(int arg); #define BAR 42 /* file foo.c */ #include foo.h int quux = 77; int foo(int arg) { quux++; return arg + BAR; } Preprocessor output: a translation unit int foo(int arg); int quux = 77; int foo(int arg) { quux++; return arg + 42 ; } Note: Some translation unit contents omitted to keep the slide simple.

22 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 22/63 Building and running C programs: many kinds of files, continued again Assembly language file: File that is output from the compiler. Remember, the compiler is the tool that translates C code into assembly language. With gcc on Linux or Cygwin, assembly language files (.s files), like translation units, usually don t get saved permanently, so you ve probably never noticed them either.

23 Compiler input: a translation unit int foo(int arg); int quux = 77; int foo(int arg) { quux++; return arg + 42 ; } Note: Some translation unit contents omitted to keep the slide simple. Compiler output: An assembly language file.data.globl quux quux:.word 77.text.globl foo foo: la $t0, quux lw $t1, ($t0) addi $t2, $t1, 1 sw $t2, ($t0) addi $v0, $a0, 42 jr $ra

24 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 24/63 Building and running C programs: many kinds of files, continued further Source code, library headers, translation units, and assembly language files are all text files sequences of ASCII codes, organized in lines, editable with a text editor. Files yet to be seen object files, library machine code files, executable files are binary files, full mostly of machine code for instructions and base two representations of numbers.

25 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 25/63 Building and running C programs: many kinds of files, on and on... An object file is output from the assembler. Let s make a sketch of typical object file organization.

26 Assembler input: An assembly language file.data.globl quux quux:.word 77.text.globl foo foo: la $t0, quux lw $t1, ($t0) addi $t2, $t1, 1 sw $t2, ($t0) addi $v0, $a0, 42 jr $ra Assembler output: An object file header machine code for instructions of procedure foo 32-bit base two representation of 77 relocation info and symbol table text segment data segment

27 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 27/63 Building and running C programs: many kinds of files, second last slide... Library machine code files contain instructions and static data belonging to library procedures such as printf, fopen, fprintf, strcpy, and thousands more. These files occupy many megabytes or gigabytes in the file system of a modern OS. Chunks of machine code and data can be copied out of these files as needed when building executable files.

28 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 28/63 Building and running C programs: many kinds of files, finally done! An executable file is created by the linker, the last tool in the chain. The linker combines one or more object files; information from the library. Suppose an executable is built from object files alpha.o and beta.o. Let s sketch the organization of the executable file.

29 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 29/63 Linux, Cygwin64, and other platforms These slides were originally written under the assumption that the platform used to build and run programs would be Linux. Building and running programs with Cygwin64 on top of Microsoft Windows is very similar to doing the same things on Linux. So I ve edited all the slides in this slide set to refer to Cygwin64 instead of Linux. Please keep in mind that all of the ideas here apply not only to Cygwin64 but also to important OSes such as Linux, FreeBSD and OpenBSD. (The ideas also apply to macos, for the most part, for now, but might not work so well with future macos versions.)

30 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 30/63 Running an executable Suppose you have an executable file called a.exe in the current directory of your Cygwin64 terminal window. Suppose you type and enter the command./a.exe Cygwin64 copies the text and data segments from a.exe into main memory. (That s an oversimplified model a system called demand paging reduces the amount of copying needed to get a program started, but I don t want to get into the complex details of that here.) Cygwin64 starts the program by making the PC point to the start of the in-memory text segment.

31 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 31/63 Running an executable, not just in a terminal window These days, users of desktops, laptops, tablets, and smartphones usually launch programs via some kind of Start menu, or by clicking or double-clicking or tapping a program icon or file icon. At the operating system level, that s the same as entering a command line: text and data segments get copied from an executable file to memory, then the PC gets pointed to the start of the in-memory text segment.

32 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 32/63 Review of the toolchain: running gcc Example command: gcc aa.c bb.c Students might say, informally, that this is running the compiler. Better-educated students would say that this is running a bunch of programs that are tools in the toolchain. What sequence of programs gets run?

33 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 33/63 Outline of Slide Set 4 Encoding of MIPS branch and jump instructions Building and running executables starting from C source code Linking and Libraries Notes about some confusing words

34 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 34/63 Linking and Libraries Topics in the upcoming slides: What the linker does How symbol tables and relocation information in object files help the linker. Comparison of static linking with dynamic linking.

35 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 35/63 Review: object files and executable files Contents of an object file: machine code (in text segment), initial values for static data (in data segment), symbol table, relocation info. An object file is NOT a runnable program! The linker makes an executable file by combining one or more object files with instructions and data from library files. An executable file IS a runnable program!

36 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 36/63 Symbol tables, relocation information, and linking Symbol tables and relocation information are sections within object files; the roles of these sections haven t yet been explained. These two sections play key roles in helping the linker to insert important pieces of addresses into instructions in executable files.

37 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 37/63 The symbol table The symbol table is a part of an object file that lists.globl symbols from the A.L. file used by the assembler to generate the object file. In this context, symbol means the same thing as label. For each symbol coming from a text segment, the table gives the offset of that symbol relative to the start of the text segment in the object file. Similarly, for each symbol coming from a data segment, the table gives the offset of that symbol relative to the start of the data segment in the object file.

38 # A.L. example to help explain symbol tables and relocation info..text.globl foo foo: [... some instructions omitted to save space on slide... ] jal quux [... more instructions omitted to save space on slide... ] jal bar [... more instructions omitted to save space on slide... ] jr $ra.data.globl my_array my_array:.word 0x100, 0x200, 0x300.globl my_int my_int:.word 0x9999.text.globl bar bar: [... some instructions omitted to save space on slide... ] la $t0, my_int [... more instructions omitted to save space on slide... ] jr $ra

39 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 39/63 Attention, regarding the previous slide That is obviously not a complete A.L. program procedures main, quux and possibly other important things were not defined there. So to make an executable file, the linker will have to combine the object file that comes from that A.L. file with one or more other object files.

40 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 40/63 Symbol table example For the A.L. file from two slides back, let s assume... foo has 18 instructions in total; jal quux is the 5th instruction in foo; jal bar is the 11th instruction in foo; la $t0, my_int generates lui and ori instructions that will be the 5th and 6th instructions of bar. Let s sketch out the text segment, data segment, and symbol table that will appear in the object file.

41 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 41/63 Problems solved by relocation information, Part 1 Consider jal quux in our A.L. example. The function quux is not defined in the given A.L. file, so it must be defined in some other file. The assembler is supposed to encode the jal instruction in the text segment of the object file, but can t because the assembler doesn t know what address information to put into bits 25 0 of the machine code for the instruction.

42 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 42/63 Problems solved by relocation information, Part 2 [This slide has been corrected to give the la pseudoinstruction a destination GPR.] Now consider jal bar and la $t0, my_int in our A.L. example. Does the assembler have enough information to completely encode the jal instruction, and the lui and ori instructions that will be needed for the la pseudoinstruction?

43 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 43/63 Solution to problems: role of assembler The assembler partially encodes jal (and j) instructions, but just puts zero bits in the address fields, and makes notes in the relocation info about what must be fixed. The assembler partially encodes lui and ori instructions, but just puts zero bits in the 16-bit constant fields, and makes notes in relocation info about what must be fixed. Let s sketch the relocation info for our A.L. example.

44 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 44/63 Solution to problems: role of linker The linker must combine multiple text segments and multiple data segments to build a single text segment and a single data segment for the executable file. The linker unlike the assembler knows what base addresses (for example, 0x0040_0000 and 0x1001_0000) are expected by the operating system for.text and.data segments. So the linker can compute the addresses for all instructions and data items. The linker uses symbol tables and relocation information to insert correct pieces of addresses into instructions such as jal, j, lui, and ori.

45 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 45/63 Example of a common error seen by gcc users A file called joe.c... void foo(void); int main(void) { foo(); return 0; } Will the command gcc joe.c succeed? Why or why not?

46 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 46/63 Error message from command gcc joe.c run on an a Cygwin64 system... /tmp/ccyl2a05.o:joe.c:(.text+0xe): undefined reference to foo /tmp/ccyl2a05.o:joe.c:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol foo collect2: error: ld returned 1 exit status

47 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 47/63 Explanation of a common gcc error What happened? Did the compiler have a problem? Did the assembler have a problem? Did the linker have a problem?

48 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 48/63 Static vs. Dynamic Linking Slides so far have presented the process for creating a kind of executable file called a statically-linked executable. Most executable files on current Mac, Windows, or Linux operating systems are a different kind, called dynamically-linked. (But it s still possible to create and run statically-linked executables on these systems.)

49 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 49/63 Contents of a statically-linked executable file (review from earlier slides) Executable file header (information about sizes and layouts of other segments). Text segment: start-up code; machine code from object files; machine code for all necessary library procedures. Data segment: initial values for static data from object files; initial values for static data belonging to library procedures.

50 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 50/63 Contents of a dynamically-linked executable file Executable file header (information about sizes and layouts of other segments). Text segment: start-up code; machine code from object files; Data segment: initial values for static data from object files; Information about where to find library instructions and library data in the file system.

51 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 51/63 Running a dynamically-linked executable Text and data segments get copied into memory from the executable file (as is the case with a statically-linked executable). It is the operating system s responsibility to make sure library machine code and data are in memory when needed. Often, library machine code is already in memory when a program starts, because some other running programs also need it this is useful sharing of memory by multiple running programs.

52 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 52/63 Running a dynamically-linked executable: example C code Source code blastoff.c... #include <stdio.h> int main(void) { int count; for (count = 10; count > 0; count--) printf("%d... \n", count); printf("blastoff!\n"); return 0; } Command to build executable: gcc blastoff.c -o blastoff

53 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 53/63 Running a dynamically-linked executable: example, continued What is in the executable file called blastoff? What important and relevant information is NOT in the executable file called blastoff? What happens when blastoff is run? (Note: On Cygwin64, the name of the executable file would be blastoff.exe.)

54 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 54/63 Static linking: Advantages Compared to dynamic linking, static linking is easy to understand and implement. Installing software is relatively easy to manage it may require placing only one file, the executable, in the right place.

55 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 55/63 Static linking: Disadvantages Executables are big. A collection of statically-linked executables contains many copies of the same library machine code and data. This wastes space in the file system. If many programs are running on a multi-tasking operating system, many copies of the same library machine code may be in memory. This wastes memory and hurts performance. Installed executables can t take advantage of library upgrades such as bug fixes and performance improvements.

56 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 56/63 Dynamic linking: Advantages Essentially, all the main disadvantages of static linking are overcome: Executables are smaller, less total memory is needed to run multiple executables at the same time, executables can benefit from library upgrades.

57 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 57/63 Dynamic linking: Disadvantages It s harder to understand and implement than static linking. Software installation can be complicated are all the right versions of library files for dynamic linking available to support all the executables? (Failures in this area on older versions of Microsoft Windows were called DLL hell but that was a long time ago.)

58 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 58/63 Quick Tour of C library, for Cygwin64 in Winter 2018 Cygwin64 is a complicated mess that mixes Linux-like stuff with Microsoft Windows, so a quick tour is impossible. (Previous years versions of these slides were able to say a few useful things about where important library files were located on Linux systems in ICT 320.)

59 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 59/63 Outline of Slide Set 4 Encoding of MIPS branch and jump instructions Building and running executables starting from C source code Linking and Libraries Notes about some confusing words

60 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 60/63 Notes about some confusing words Computer programming terminology and jargon have evolved (or have just accumulated chaotically) over the past several decades. Some of the choices that were made were not very helpful to students trying to learn about computers and programming!

61 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 61/63 Notes about some confusing words: text The text segment, where the instructions go in an object file or executable file, is not related to the concept of text as a sequence of character codes in ASCII or some other character set!

62 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 62/63 Notes about some confusing words: object The term object file has nothing to do with the concept of an object in object-oriented programming in languages such as C++, Java, Objective-C, Python, etc.

63 ENCM 369 Winter 2018 Section 01 Slide Set 4 slide 63/63 Notes about some confusing words: link The word link in the MIPS jump-and-link instruction means, leave a return address to allow return from a callee procedure. The word link in the term linker means, connect together procedures and data from one or more object files to make an executable program. So there are two different meanings for link.

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

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

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

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

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

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

CSCI 2321 (Computer Design), Spring 2018 Homework 3

CSCI 2321 (Computer Design), Spring 2018 Homework 3 CSCI 2321 (Computer Design), Spring 2018 Homework 3 Credit: 50 points. 1 Reading Be sure you have read, or at least skimmed, all assigned sections of Chapter 2 and Appendix A. 2 Honor Code Statement Please

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

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

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

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

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

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine

More information

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading)

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) Instructors: Nicholas Weaver & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Where Are We Now? 2 Linker

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

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

From Code to Program: CALL Con'nued (Linking, and Loading)

From Code to Program: CALL Con'nued (Linking, and Loading) ecture 13 Computer Science 61C Spring 2017 February 15th, 2017 From Code to Program: CALL Con'nued (Linking, and Loading) 1 Administrivia We know it still sucks but: Waitlist students: Please be patient.

More information

Lecture 7: Examples, MARS, Arithmetic

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

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

ENCM 339 Fall 2017: Editing and Running Programs in the Lab page 1 of 8 ENCM 339 Fall 2017: Editing and Running Programs in the Lab Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Introduction This document is a

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

Lecture 10: Program Development versus Execution Environment

Lecture 10: Program Development versus Execution Environment Lecture 10: Program Development versus Execution Environment CSE 30: Computer Organization and Systems Programming Winter 2010 Rajesh Gupta / Ryan Kastner Dept. of Computer Science and Engineering University

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

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

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

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

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

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

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

ENCM 501 Winter 2019 Assignment 9

ENCM 501 Winter 2019 Assignment 9 page 1 of 6 ENCM 501 Winter 2019 Assignment 9 Steve Norman Department of Electrical & Computer Engineering University of Calgary April 2019 Assignment instructions and other documents for ENCM 501 can

More information

Assembler. Lecture 8 CS301

Assembler. Lecture 8 CS301 Assembler Lecture 8 CS301 Discussion Given the following function header, int foo(int a, int b); what will be on the stack before any of the calculations in foo are performed? Assume foo() calls some other

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

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

ECE 15B COMPUTER ORGANIZATION

ECE 15B COMPUTER ORGANIZATION ECE 15B COMPUTER ORGANIZATION Lecture 17 Executing Programs: Compiling, Assembling, Linking and Loading (Part II) Project #3 Due June 10, 5pm Announcements Submit via email Homework #4 Due June 5, 5pm

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#: Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators

More information

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a

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

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

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

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

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

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

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

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

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

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o CS61C L18 Running a Program I (1) inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 19 Running a Program II aka Compiling, Assembling, Linking, Loading 2006-10-11 (aka 2006-0xB)

More information

ENCM 501 Winter 2016 Assignment 1 for the Week of January 25

ENCM 501 Winter 2016 Assignment 1 for the Week of January 25 page 1 of 5 ENCM 501 Winter 2016 Assignment 1 for the Week of January 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2016 Assignment instructions and other

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

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

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

Assembler. #13 Running a Program II

Assembler. #13 Running a Program II CS61C L13 Running a Program II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor

More information

ecture 12 From Code to Program: CALL (Compiling, Assembling, Linking, and Loading) Friedland and Weaver Computer Science 61C Spring 2017

ecture 12 From Code to Program: CALL (Compiling, Assembling, Linking, and Loading) Friedland and Weaver Computer Science 61C Spring 2017 ecture 12 Computer Science 61C Spring 2017 February 13th, 2017 From Code to Program: CALL (Compiling, Assembling, Linking, and Loading) 1 Administrivia My office hours: Monday 1pm-2pm, 424 SDH. We know

More information

Lecture 6: Assembly Programs

Lecture 6: Assembly Programs Lecture 6: Assembly Programs Today s topics: Procedures Examples Large constants The compilation process A full example 1 Procedures Local variables, AR, $fp, $sp Scratchpad and saves/restores, $fp Arguments

More information

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures Review (1/2) CS61C - Machine Structures Lecture 11 - Starting a Program October 4, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ IEEE 754 Floating Point Standard: Kahan pack as much in

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

#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

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

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

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept Instructions: Instructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch

More information

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading)

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology

More information

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept nstructions: nstructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch &

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

Review. Disassembly is simple and starts by decoding opcode field. Lecture #13 Compiling, Assembly, Linking, Loader I

Review. Disassembly is simple and starts by decoding opcode field. Lecture #13 Compiling, Assembly, Linking, Loader I CS61C L13 CALL I (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #13 Compiling, Assembly, Linking, Loader I 2008-7-14 Albert Chae, Instructor Review Disassembly is simple and starts

More information

Communicating with People (2.8)

Communicating with People (2.8) Communicating with People (2.8) For communication Use characters and strings Characters 8-bit (one byte) data for ASCII lb $t0, 0($sp) ; load byte Load a byte from memory, placing it in the rightmost 8-bits

More information

Lectures 3-4: MIPS instructions

Lectures 3-4: MIPS instructions Lectures 3-4: MIPS instructions Motivation Learn how a processor s native language looks like Discover the most important software-hardware interface MIPS Microprocessor without Interlocked Pipeline Stages

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

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

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

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

MIPS Coding Continued

MIPS Coding Continued MIPS Coding Continued Exercise 1 Suppose we have three arrays, A, B, C, all of size 10. Now we want to set C[i] = min(a[i], B[i]) for all 0

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture C.A.L.L. July 7, 2014 Review Three different instruction formats designed to be as similar as possible, while still handling all instructions: R: opcode rs rt rd shamt funct I: opcode rs rt immediate J:

More information

Winter 2009 FINAL EXAMINATION Location: Engineering A Block, Room 201 Saturday, April 25 noon to 3:00pm

Winter 2009 FINAL EXAMINATION Location: Engineering A Block, Room 201 Saturday, April 25 noon to 3:00pm University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: S. A. Norman (L01), N. R. Bartley (L02) Winter 2009 FINAL EXAMINATION Location:

More information

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

Slide Set 8. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 8 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

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor Green Subscription Based PC Announced

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

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

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer 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 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

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Architecture II. Computer Systems Laboratory Sungkyunkwan University MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

More information

LECTURE 2: INSTRUCTIONS

LECTURE 2: INSTRUCTIONS LECTURE 2: INSTRUCTIONS Abridged version of Patterson & Hennessy (2013):Ch.2 Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many

More information

MIPS Instruction Set Architecture (2)

MIPS Instruction Set Architecture (2) MIPS Instruction Set Architecture (2) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu

More information

High Performance Computing Lecture 6. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 6. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 6 Matthew Jacob Indian Institute of Science MULT Instruction Example: MULT R1, R2 32 bits 32 bits R1 R2 The product could be twice as large (i.e., 64b) It may not fit

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER 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 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

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

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

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

Common Problems on Homework

Common Problems on Homework MIPS Functions Common Problems on Homework 1.3: Convert -3000 ten to binary in 8bit, 16bit, and 32bit Even though it overflows with 8bits, there is plenty of room with 16 and 32 bit. Common Problems on

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

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

CSCI 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. 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 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

CS222: MIPS Instruction Set

CS222: MIPS Instruction Set CS222: MIPS Instruction Set Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Previous Introduction to MIPS Instruction Set MIPS Arithmetic's Register Vs Memory, Registers

More information

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates CS 61C: Great Ideas in Computer Architecture MIPS Instruction Representation II Guest Lecturer: Justin Hsia 2/11/2013 Spring 2013 Lecture #9 1 Review of Last Lecture Simplifying MIPS: Define instructions

More information

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set COMPSCI 313 S2 2018 Computer Organization 7 MIPS Instruction Set Agenda & Reading MIPS instruction set MIPS I-format instructions MIPS R-format instructions 2 7.1 MIPS Instruction Set MIPS Instruction

More information

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.

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

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points) ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points) Objectives: Get familiar with MIPS instructions Assemble, execute and debug MIPS

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

Systems Architecture I

Systems Architecture I Systems Architecture I Topics Assemblers, Linkers, and Loaders * Alternative Instruction Sets ** *This lecture was derived from material in the text (sec. 3.8-3.9). **This lecture was derived from material

More information