Student # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Size: px
Start display at page:

Download "Student # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering"

Transcription

1 ECE 243S - Computer Organization The Edward S. Rogers Sr. Department of Electrical and Computer Engineering Mid-term Examination, March 2005 Name Student # Please circle your lecture section for exam return LEC0101 Mochovos MTuTh LEC0102 Mochovos MWTh LEC0103 Anderson MWF LEC0104 Anderson TuThF Answer all questions. Write your answers on the exam paper. Show your work. Each question has a different assigned value, as indicated. Not all questions will require the same amount of time and effort, use your time wisely. Permitted: textbook and lab manual; one extra page. No other printed or written material. No calculator. NO PHOTOCOPIED MATERIAL Total marks available: Verify that your exam has all the pages. Only exams written in ink will be eligible for remarking. ECE243 Midterm pg 1 of 12 Feb. 2005

2 1. [20] Quick Answer Circle the correct answer in A to E. A. Memory address $40000 contains the word $0034. Is this: a) Data only. b) An instruction only. c) Could be either data or an instruction. B. How many times will the instruction sub be executed in the following code? move.w ETA: beq sub.w bra ETB: #N, d0 koko #2, d0 ETA a) integer part of N / 2 b) integer part of (N - 1) /2 c) either integer part of N / 2 or infinite times The instructions form a loop starting at label ETA. As long as d0 is non-zero the loop will continue executing and at every iteration will subtract 2 from d0. So, if N is an even number the loop will iterate N/2 times. If N is an odd number, then subtracting 2 will never produce 0. Instead, d0 will cycle through 3, 1, -1, -3,. d) either integer part of (N - 1)/2 or infinite times e) 2N f) N + (N 1) g) None of the above C. Which C language construct the following assembly code corresponds to? ETB: ETA: ETG: cmp.w bgt ETA add.w bra ETG add.w d0, d1 #1, d1 #2, d1 a) if (a > b) { a = a + 1; } else { a = a + 2; } b) if (a <= b) { a = a + 1; } else { a = a + 2; } Notice that d1 is either incremented by 1 or 2. The question is whether d1 holds a or b. The cmp and bgt instructions provide the necessary clues. The cmp compares d1 to d1 and the bgt branches to the code that increments d1 by 2 if (d1 > d0). In other words, we will increment d1 by 2 if d1 is greater than d0 or increment it by 1 if d1 is less than or equal than d0. c) if (a > b) { b = b + 1; } else { b = b + 2; } d) if (a <= b) { b = b + 1; } else { a = b + 2; } ECE243 Midterm pg 2 of 12 Feb. 2005

3 D. What will happen when the following code is executed? jsr ETB ETB rts a) jsr and rts will execute an infinite number of times b) jsr and rts will execute once and then execution will continue immediately after rts. c) jsr will execute once, rts will execute twice and then execution will resume at an unspecified address (value at the top of the stack prior to executing the code). Ignoring any memory alignment issues (i.e., assuming that the value of a7 is divisible by 2) the first jsr instruction will push on the stack the address ETB (its return address) and then jump to ETB. At ETB the rts instruction will be executed. It will a long word from the top of the stack and jump there. As explained this value will be ETB. So, the rts will execute once more. It will again read the long word at the top of the stack but now this value is unknown to us (it can not be determined with the information given to us). Hence, execution will continue at an unspecified address. d) None of the above. This will happen: E. How many seconds is taken on a serial link to send the message MY MESSAGE (ignore the quotation marks) over a UART set to 9600 BAUD, 1 Stop Bit, 8 Bit Data, No parity. Ignore the time to set up the communication and assume that characters are sent as fast as possible. a) 80/9600 b) 90/9600 c) 100/9600 In serial communication, each character is transmitted using 8 bits (as stated in the question 8 bit data ). To send a character we always need a stop and a start bit as we have explained in the lectures. The stop/start bit force a 1 to 0 transition on the communication line and this helps us correct any phase differences that may exist. Thus, we need bits per character. There are 10 characters, so in total we need to be able to sent 100 bits. The BAUD rate is the rate at which bit cells occur and it follows that we need 100 x 1/9600 bit cells to sent the message. d) 110/9600 ECE243 Midterm pg 3 of 12 Feb. 2005

4 2. [15] Basic Addressing Modes Memory and registers are as on the left side of the table below. Show what happens after all of the following instructions are executed: INST_1 AA equ $1003 INST_2 move.b #6,AA+1 INST_3 move.l $100C,d1 INST_4 move.l #$100C,d2 INST_5 movea.l #$1008,a1 INST_6 move.l (a0)+,d0 INST_7 move.b 5(a2),d3 Address Before After Word contents $1000 $4963 $1002 $1000 $1004 $2039 $0639 The $06 is from INST_1 $1006 $3322 $1008 $5544 $100A $FAA5 $100C $B2FC $100E $0000 $1010 $0203 Registers Long Words d0 $ d1 $23282A2C d2 $ d3 $ABCDEF d4 $0 a0 $1000 a1 $4670 a2 $FFE a3 $6 $ from INST_6 $B2FC0000 from INST_3 $100C from INST_4 $ABCD00 from INST_7 $1004 from INST_6 $1008 from INST_5 ECE243 Midterm pg 4 of 12 Feb. 2005

5 2. [15] Parallel Interface In the following diagram of one bit of a PIT: Vdd DIR Read Registor Data DOR Write D Write DOR Q External connection DDR Write D Write DDR Q a. What is the purpose of the Resistor? The resister is there to set the line at Vdd if no external source is currently drives the wire. It also allows an external source to set the wire s voltage at any value desired. Finally, it can help an external device set the wire to Vdd (in case the device is not as strong at forcing a high voltage). Of course, the latter benefit comes at the expense of making driving the wire to 0V harder. b. What drives DDR Write? An address decoder. The address decoder is a combinatorial circuit that inspects the processor s memory interface and determines whether an access is currently being requested by the CPU for the memory address where DDR is mapped to. c. What drives DOR Write? As in (b). d. What is the purpose of the DDR? To control the direction of the external connection. If DDR is set to 1 then the tri-state buffer is activated passing the value of DOR onto the external wire. In this case, the external connection is an output (from the computer s perspective). If DDR is set to 0 then the tri-state buffer is de-activated effectively isolating DOR s output from the external connection. In this case, an external device can set the wire to any voltage it desires. e. How many flipflops would be in an 8 bit PIT interface of this type? EIGHT per register one per bit. There are two registers DDR and DOR, hence in total we need 16 bits. ECE243 Midterm pg 5 of 12 Feb. 2005

6 4. [25] Writing Assembly Code Write a subroutine in 68k assembly that takes as input three long word parameters on the stack: The first parameter is the base address of an array of long words. The second parameter is the number of array elements counting from 1. The third parameter is a number. The routine should calculate and return in d0 the number of array elements whose value matches that of the third parameter. Assume that all registers are calleesaved. Note that parameters are pushed on the stack in reverse order so that at the end the first parameter appears at the top. There are many possible implementations. We present one of them. We start with what the stack will contain when this function is called. This is part of the calling convention as this is described in the question. We are given that there are three parameters. We do know that the first parameter is the last pushed on the stack. Hence the stack will look as follows: a7 return address +4 base address +8 number of elements +12 number We will use three registers for our routine a0, d1 and d2. Since all registers are callee-saved we must preserve their values. Accordingly we need to push them on the stack and restore them prior to returning: routine movem.l a0/d1/d2, -(a7) ; save the registers we will be changing ; all aforementioned stack offsets will ; have to be adjusted by +12. clr.l d0 ; d0 counts the number of matching elements movea.l 16(a7), a0 ; a0 will point to the next element ; make it point to the first element ; this the base address move.l 20(a7), d1 ; d1 counts elements not processed yet ; read the second parameter off the stack move.l 24(a7), d2 ; d2 hold the value to match against ; this is the third parameter loop tst.l d1 bra done cmp.l (a0), d2 bne nomatch match addq.l #1, d0 nomatch addq.l #4, a0 subq.l #1, d1 bra loop ; any elements left? ; d1 is zero = no elements left ; is this the value we are matching against? ; yes it is increment d0 ; move on to the next element ; one less element to check ECE243 Midterm pg 6 of 12 Feb. 2005

7 done movem.l (a7)+, a0/d1/d2 rts ECE243 Midterm pg 7 of 12 Feb. 2005

8 5. [25] Analysing Assembly Code What does the following program do? Show a pseudo-code or flowchart description as part of your answer. SSub movea.l #InList,a0 movea.l a0,a1 addq.l #2,a1 clr.b d1 L0 cmpm.w (a0)+,(a1)+ ;cmpm.w is just like cmp.w ble L1 move.w -2(a0),d0 move.w -2(a1),-2(a0) move.w d0,-2(a1) moveq.b #1,d1 L1 cmpa.l #EndInList,a1 blo L0 ;blo is an unsigned blt instruction tst.b d1 bne SSub L2 rts This code sorts the input array into ascending order. ***** A flowchart should contain the following items: Callee save registers Set up pointers & get parameters Until no swaps required Look at first 2 elements in list Until done list If current element > next element Swap current element and next element Go to next element pair End Until End Until Restore register values Return to caller ***** STEP-BY-STEP analysis of the code: SSub movea.l #InList,a0 movea.l a0,a1 addq.l #2,a1 clr.b d1 ; a0 points to the first array element ; a1 = a0 + 2 so a1 now points to the ; second array element ; d1 is a flag ; it s zero if no changes happened during ; a full scan over the array ; so, we set it to 0 L0 cmpm.w (a0)+,(a1)+ ;cmpm.w is just like cmp.w ; compare the element pointed to by a0 ; with the element pointed to by a1 ; these are always to adjacent elements ; notice that both a0 and a1 will be ; incremented by 2 after this instruction ECE243 Midterm pg 8 of 12 Feb. 2005

9 ble L1 move.w -2(a0),d0 move.w -2(a1),-2(a0) move.w d0,-2(a1) moveq.b #1,d1 ; so they will point to the next pair ; of array elements ; if a1 element is smaller or equal move ; on ; otherwise swap ; these three instructions swap the ; two elements with the help of d0 ; we need the -2 offset since both a0 and ; a1 have been increased by 2 by the ; preceding cmp instruction ; set d1 to 1 to indicate that at least ; one change has happened L1 cmpa.l #EndInList,a1 ; is a1 pointing to the last element? blo L0 ; no, continue with the next element pair tst.b d1 ; We have just completed a full pass ; over the whole array ; if changes occurred we repeat a full ; scan bne SSub L2 rts ; done return to caller NOTE that this algorithm is *NOT* bubble-sort. It s similar in that it scans adjacent elements and swaps them. It is different in that it always scans all of the array. ECE243 Midterm pg 9 of 12 Feb. 2005

10 6. [+10 Extra Credit Question] Not a Assume a computer with a single instruction called subtract and branch if negative or SBN. The SBN instruction accepts four arguments as follows: SBN T, A, B, N Where T and N are memory addresses and A and B can either be 32-bit memory addresses or 32-bit constants. The SBN instruction subtracts the value of B from the value of A, stores the result into T and if this result is negative continues execution at address N. If the result is positive execution continues with the next in memory instruction. If A or B is an address, SBN first reads the 32-bit value at that address. For example: SBN $30, $40, #10, next Reads the 32 bit value at memory address $40, subtracts 10 from it, stores the result into memory location $30 and if this result was negative continues execution at the address defined by the label next. Otherwise execution continues with the next in memory instruction. In all questions that follow the locx identifiers refer to memory addresses. A) What is the minimum number of bytes that will be needed to encode the SBN instruction. Briefly explain your answer. We start by determining the information contained in the instruction: 1. The operation: SBN 2. The four operands We then consider each item separately. 1. There is only one operation SBN. We could explicitly specify this one operation but this turns out to be superfluous. Since the is only one, it is always implied. So we need 0 bits for encoding the operation type. It is always SBN. (+0 bits for the operation type.) 2. There are four parameters. The last is always an address. Hence we need four bytes for it. (+4 bytes for next field.) The same applies for the first parameter. Each of the other two operands can be either an address or an immediate. In either case we need 4 bytes for the address or immediate. So, +4 bytes per operand for the operand s value. But we also need to specify which of the two it is: an address or an immediate. Thus, we need one more bit per operand. (+1 bit for distinguishing between an address and an immediate.) In summary: 2 x (1 bit + 4 bytes) + 2 x (4 bytes) = 16 bytes + 2 bits. Assuming that we must round this off to bytes we need 17 bytes (where 6 bits are left unused). ECE243 Midterm pg 10 of 12 Feb. 2005

11 B) Write a program that adds the values at loca and locb and stores the result into locc without changing the values in loca and locb. Do not assume that locc has a known value to start with. sbn locc, #0, locb, i2 ; locc = -B i2 sbn locc, loca, locc, i3 ; locc = A (locc) = A (-B) ; locc = A + B i3 C) Write a program that checks whether the value at loca is greater than or equal the value at locb and writes 1 if this is true into locc. If this condition is false it should write 0 into locc. If we assume that there is one more memory location (locd) we can use: sbn locc, #1, #0, i3 ; locc = 1 ; assume that A is GT B sbn locd, locb, loca, greater ; locc = B-A notgt sbn locc, #0, #0, greater ; locc = 0 greater If we want to avoid accessing any other memory location: sbn locc, #1, #0, i3 ; locc = 1 ; assume that A is GT B sbn locb, loca, locb, notgt ; locb = A - B sbn locc, #1, #0, notgt ; locc = 1 notgt sbn locb, locb, loca, i4 ; locb = (A B) A = -B i4 sbn locb, #0, locb, i5 ; locb = #0 (-B) = B i5 ECE243 Midterm pg 11 of 12 Feb. 2005

12 Use this page for extra work Results Bonus Total ECE243 Midterm pg 12 of 12 Feb. 2005

Lab 2 Use Traps. Lab 2 Input and Output 2 nd Semester. Lab 2 English. Lab 2 Pseudocode

Lab 2 Use Traps. Lab 2 Input and Output 2 nd Semester. Lab 2 English. Lab 2 Pseudocode Lab 2 Input and Output Lab 2 Use Traps Write (i.e. design and implement) an assembly language program that will accept user input from the keyboard and echo this to the terminal screen. Input should terminate

More information

Subroutine. Chapter 8

Subroutine. Chapter 8 Chapter 8 Subroutine Expected Outcomes Describe and apply the stack for data storage Describe the process of subroutine in any programs Develop a subroutine and code Interpret subroutine process in the

More information

CSE 351 Midterm - Winter 2015 Solutions

CSE 351 Midterm - Winter 2015 Solutions CSE 351 Midterm - Winter 2015 Solutions February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate

More information

CSE 351 Midterm - Winter 2015

CSE 351 Midterm - Winter 2015 CSE 351 Midterm - Winter 2015 February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate will prove

More information

Module 7: Address Registers & Array Processing

Module 7: Address Registers & Array Processing Module 7: Address Registers & Array Processing Special instructions for address registers CMPA, MOVEA, SUBA, ADDA LEA Understanding arrays Array applications 2006 munim@utm.my,athif@fke.utm.my,kamal@bip.utm.my

More information

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000.

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000. INTRODUCTION TO BRANCHING UNCONDITIONAL BRANCHING There are two forms of unconditional branching in the MC68000. BRA instruction BRA Program control passes directly to the instruction located at

More information

PART II: Cap. 6 - Linguaggio macchina M68000

PART II: Cap. 6 - Linguaggio macchina M68000 192 CHAPTER 3 ARM, MOTOROLA, AND INTEL INSTRUCTION SETS 3.20 Rewrite the byte-sorting program in Figure 3.15b as a subroutine that sorts a list of 32-bit positive integers. The calling program should pass

More information

EECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups

EECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups EECE416 :Microcomputer Fundamentals and Design 68000 Instruction Sets and Groups 1 Instruction Groups Data Transfer Groups Arithmetic Group Logical Group Shift and Rotate Group Bit Manipulation Group Binary

More information

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0 Midterm Review 1. Branch instructions BHI (unsigned), BGT (signed) Take a look at the preceding comparison instruction. Then, you can use this instead of using complex formula in the instruction reference.

More information

Tutorial 1 Microcomputer Fundamentals

Tutorial 1 Microcomputer Fundamentals Tutorial 1 Microcomputer Fundamentals Question 1 What do these acronyms mean? (a) CPU? (b) ROM? (c) EPROM? (d) RWM? (e) RAM? (f) I/O? What role does the CPU play in a computer system? Why is ROM an essential

More information

LAB 1: MC68000 CPU PROGRAMMING DATA TRANSFER INSTRUCTIONS

LAB 1: MC68000 CPU PROGRAMMING DATA TRANSFER INSTRUCTIONS LAB 1: MC68000 CPU PROGRAMMING DATA TRANSFER INSTRUCTIONS OBJECTIVES At the end of the laboratory works, you should be able to write simple assembly language programs for the MC68000 CPU using data transfer

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

Subroutines. passing data

Subroutines. passing data Subroutines passing data Mechanisms: pass by value pass by result pass by value result/ value return/ copy restore pass by reference pass by name pass by lazy evaluation Techniques: 1. in registers 2.

More information

Recursive Subroutine Calls Example

Recursive Subroutine Calls Example The purpose of this example is to examine how all parameters, local variables, return addresses, and frame pointers are stored on the stack when a main program calls a procedure "Process" as well as when

More information

Addressing Modes. To review data transfer instructions and applying the more advanced addressing modes.

Addressing Modes. To review data transfer instructions and applying the more advanced addressing modes. Addressing Modes Aims To review 68000 data transfer instructions and applying the more advanced addressing modes. Intended Learning Outcomes At the end of this module, students t should be able to Review

More information

C Calling Conventions

C Calling Conventions C Calling Conventions 1. parameters are passed on the run-time or system stack, SP (or A7) 2. parameters pushed on stack in right to left order of call A6 used as the stack frame pointer local variables

More information

CPE/EE 421 Microcomputers

CPE/EE 421 Microcomputers CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S07 Outline Stack and Local Variables C Programs 68K Examples Performance *Material used is in part developed by Dr. D. Raskovic

More information

Exam 1. Date: February 23, 2016

Exam 1. Date: February 23, 2016 Exam 1 Date: February 23, 2016 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

More information

CPE/EE 421 Microcomputers

CPE/EE 421 Microcomputers CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S06 *Material used is in part developed by Dr. D. Raskovic and Dr. E. Jovanov CPE/EE 421/521 Microcomputers 1 Course Administration

More information

Name: University of Michigan uniqname: (NOT your student ID number!)

Name: University of Michigan uniqname: (NOT your student ID number!) The University of Michigan - Department of EECS EECS370 Introduction to Computer Organization Midterm Exam 1 October 22, 2009 Name: University of Michigan uniqname: (NOT your student ID number!) Open book,

More information

ECE251: Tuesday September 12

ECE251: Tuesday September 12 ECE251: Tuesday September 12 Finish Branch related instructions Stack Subroutines Note: Lab 3 is a 2 week lab, starting this week and covers the Stack and Subroutines. Labs: Lab #2 is due this week. Lab

More information

Stack Frames. Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to

Stack Frames. Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to Stack Frames EE 357 Unit 8 Stack Frames Compilers use the stack: to store the to to a subroutine for storage of declared in the subroutine and a place to Every call to a subroutine will create a data structure

More information

stack frame where register An is used as the argument pointer.

stack frame where register An is used as the argument pointer. STACK FRAMES The MC68000 provides two special instructions to allocate and deallocate a data structure called a frame in the stack to make subroutines easier to code. general structure of a frame: SP local

More information

SEE 3223 Microprocessors. 4: Addressing Modes. Muhammad Mun im Ahmad Zabidi

SEE 3223 Microprocessors. 4: Addressing Modes. Muhammad Mun im Ahmad Zabidi SEE 3223 Microprocessors 4: Addressing Modes Muhammad Mun im Ahmad Zabidi (munim@utm.my) Addressing Modes Aims To review 68000 data transfer instruchons and applying the more advanced addressing modes.

More information

EE 361 University of Hawaii Fall

EE 361 University of Hawaii Fall C functions Road Map Computation flow Implementation using MIPS instructions Useful new instructions Addressing modes Stack data structure 1 EE 361 University of Hawaii Implementation of C functions and

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Computer Architecture 5.1. Computer Architecture. 5.2 Vector Address: Interrupt sources (IS) such as I/O, Timer 5.3. Computer Architecture

Computer Architecture 5.1. Computer Architecture. 5.2 Vector Address: Interrupt sources (IS) such as I/O, Timer 5.3. Computer Architecture License: http://creativecommons.org/licenses/by-nc-nd/3./ Hardware interrupt: 5. If in an eternal device (for eample I/O interface) a predefined event occurs this device issues an interrupt request to

More information

Control Instructions

Control Instructions Control Instructions 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 Instruction Set

More information

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Assembly Language and C. Outline

Alex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Assembly Language and C. Outline Outline CPE/EE 421 Microcomputers: Motorola 68: Assembly Language and C Instructor: Dr Aleksandar Milenkovic Lecture Notes ACIA Example: Pseudo-code + Assembly Passing parameters In registers Passing by

More information

Physics 116B Winter 2006: Problem Assignment 8

Physics 116B Winter 2006: Problem Assignment 8 Physics 116B Winter 2006: Problem Assignment 8 Due Wednesday, March 15 1. You may use a calculator for the following: (a) Convert to decimal: $9F03. (b) Express in binary: $3CFA. (c) Convert to hexadecimal:

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions 1. (12 marks) Circle the correct answer for each of the following: The 8-bit two's complement representation of -15

More information

Digital Forensics Lecture 3 - Reverse Engineering

Digital Forensics Lecture 3 - Reverse Engineering Digital Forensics Lecture 3 - Reverse Engineering Low-Level Software Akbar S. Namin Texas Tech University Spring 2017 Reverse Engineering High-Level Software Low-level aspects of software are often the

More information

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off. Department of Electrical and Computer Engineering University of Wisconsin Madison ECE 552 Introductions to Computer Architecture Homework #2 (Suggested Solution) 1. (10 points) MIPS and C program translations

More information

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD A. Assembly Language Programming Programming of a computer system: Machine code direct execution Assembly language tool: assembler High level programming language tool: interpreter tool: compiler Programming

More information

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook) Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter

More information

ECE251: Tuesday September 11

ECE251: Tuesday September 11 ECE251: Tuesday September 11 Finish Branch related instructions Stack Subroutines Note: Lab 3 is a 2 week lab, starting this week and covers the Stack and Subroutines. Labs: Lab #2 is due this week. Lab

More information

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls Instructors: Dr. Phillip Jones 1 Announcements Final Projects Projects: Mandatory

More information

Program Development. Chapter 5

Program Development. Chapter 5 Chapter 5 Program Development Expected Outcomes Distinguish between various codes in the programming language Explain the role of assembler and compiler Distinguish between different data types Use directive

More information

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones CprE 288 Introduction to Embedded Systems Course Review for Exam 3 Instructors: Dr. Phillip Jones 1 Announcements Exam 3: See course website for day/time. Exam 3 location: Our regular classroom Allowed

More information

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm Final Review Format 10 multiple choice 8 points each Make sure to show your work Can write a description to the side as to why you think your answer is correct for possible partial credit 1 short answer

More information

Instructions: Assembly Language

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

More information

CS61c MIDTERM EXAM: 3/17/99

CS61c MIDTERM EXAM: 3/17/99 CS61c MIDTERM EXAM: 3/17/99 D. A. Patterson Last name Student ID number First name Login: cs61c- Please circle the last two letters of your login name. a b c d e f g h i j k l m n o p q r s t u v w x y

More information

Chapter 2A Instructions: Language of the Computer

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

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (October 4, 2017) 1/18 538 Lecture Notes Week 5 Announements Midterm: Tuesday, October 25 Answers to last week's questions 1. With the diagram shown for a port (single bit), what

More information

Subprograms, Subroutines, and Functions

Subprograms, Subroutines, and Functions Subprograms, Subroutines, and Functions Subprograms are also called subroutines, functions, procedures and methods. A function is just a subprogram that returns a value; say Y = SIN(X). In general, the

More information

INFOB3TC Exam 2. Sean Leather. Monday, 30 January 2012, 17:00 20:00

INFOB3TC Exam 2. Sean Leather. Monday, 30 January 2012, 17:00 20:00 Department of Information and Computing Sciences Utrecht University INFOB3TC Exam 2 Sean Leather Monday, 30 January 2012, 17:00 20:00 1 Preliminaries The exam consists of 8 pages (including this page).

More information

538 Lecture Notes Week 5

538 Lecture Notes Week 5 538 Lecture Notes Week 5 (Sept. 30, 2013) 1/15 538 Lecture Notes Week 5 Answers to last week's questions 1. With the diagram shown for a port (single bit), what happens if the Direction Register is read?

More information

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise! Chapter 1: Computer Abstractions and Technology 1. Assume two processors, a CISC processor and a RISC processor. In order to run a particular program, the CISC processor must execute 10 million instructions

More information

Exam 1. Date: February 23, 2018

Exam 1. Date: February 23, 2018 Exam 1 Date: February 23, 2018 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

More information

Lecture 6 Assembly Programming: Branch & Iteration

Lecture 6 Assembly Programming: Branch & Iteration CPE 390: Microprocessor Systems Spring 2018 Lecture 6 Assembly Programming: Branch & Iteration Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ

More information

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture ECE468 Computer Organization & Architecture MIPS Instruction Set Architecture ECE468 Lec4.1 MIPS R2000 / R3000 Registers 32-bit machine --> Programmable storage 2^32 x bytes 31 x 32-bit GPRs (R0 = 0) 32

More information

Midterm 1 topics (in one slide) Bits and bitwise operations. Outline. Unsigned and signed integers. Floating point numbers. Number representation

Midterm 1 topics (in one slide) Bits and bitwise operations. Outline. Unsigned and signed integers. Floating point numbers. Number representation Midterm 1 topics (in one slide) CSci 2021: Review Lecture 1 Stephen McCamant University of Minnesota, Computer Science & Engineering Number representation Bits and bitwise operators Unsigned and signed

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

Go Gators! Relax! May the Schwartz be with you!

Go Gators! Relax! May the Schwartz be with you! Page 1/12 Exam 1 Instructions: Turn off cell phones beepers and other noise making devices. Show all work on the front of the test papers. If you need more room make a clearly indicated note on the front

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming Assembly Programming HCS12 Assembly Programming Basic Assembly Programming Top Assembly Instructions (Instruction You Should Know!) Assembly Programming Concepts Assembly Programming HCS12 Assembly Instructions

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

Exam 1. Date: February 23, 2018

Exam 1. Date: February 23, 2018 Exam 1 Date: February 23, 2018 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

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

Advanced Assembly, Branching, and Monitor Utilities

Advanced Assembly, Branching, and Monitor Utilities 2 Advanced Assembly, Branching, and Monitor Utilities 2.1 Objectives: There are several different ways for an instruction to form effective addresses to acquire data, called addressing modes. One of these

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

CSE 351 Midterm - Winter 2017

CSE 351 Midterm - Winter 2017 CSE 351 Midterm - Winter 2017 February 08, 2017 Please read through the entire examination first, and make sure you write your name and NetID on all pages! We designed this exam so that it can be completed

More information

MIPS Architecture and Assembly Language Overview

MIPS Architecture and Assembly Language Overview MIPS Architecture and Assembly Language Overview Adapted from: http://edge.mcs.dre.g.el.edu/gicl/people/sevy/architecture/mipsref(spim).html [Register Description] [I/O Description] Data Types and Literals

More information

This simulated machine consists of four registers that will be represented in your software with four global variables.

This simulated machine consists of four registers that will be represented in your software with four global variables. CSCI 4717 Computer Architecture Project 1: Two-Stage Instuction Decoder Due: Monday, September 21, 26 at 11:59 PM What to submit: You will be submitting a text file containing two C functions, fetchnextinstruction()

More information

ARM Assembly Language. Programming

ARM Assembly Language. Programming Outline: ARM Assembly Language the ARM instruction set writing simple programs examples Programming hands-on: writing simple ARM assembly programs 2005 PEVE IT Unit ARM System Design ARM assembly language

More information

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: The CPU and Memory How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram: 1 Registers A register is a permanent storage location within

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

Assembly Language. Operand Size. The internal registers. Computers operate on chunks of data composed of a particular number of bits.

Assembly Language. Operand Size. The internal registers. Computers operate on chunks of data composed of a particular number of bits. 1 2 Chapter 6 Assembly Language Operand Size 8 bits 16 bits Computers operate on chunks of data composed of a particular number of bits. The 68K has a 32-bit architecture and a 16-bit organization. Internal

More information

Lecture 2: RISC V Instruction Set Architecture. Housekeeping

Lecture 2: RISC V Instruction Set Architecture. Housekeeping S 17 L2 1 18 447 Lecture 2: RISC V Instruction Set Architecture James C. Hoe Department of ECE Carnegie Mellon University Housekeeping S 17 L2 2 Your goal today get bootstrapped on RISC V RV32I to start

More information

H8/300L Series Programming Manual

H8/300L Series Programming Manual H8/300L Series Programming Manual Notice When using this document, keep the following in mind: 1. This document may, wholly or partially, be subject to change without notice. 2. All rights are reserved:

More information

Today s objective: introduction to really simple subroutines to simplify program structure for I/O

Today s objective: introduction to really simple subroutines to simplify program structure for I/O a 1 st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with the main routine less than 100 lines long Today s objective: introduction

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

CS 2504 Intro Computer Organization Test 1

CS 2504 Intro Computer Organization Test 1 Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet and the MIPS reference card. No calculators

More information

MIPS Instruction Set

MIPS Instruction Set MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central

More information

Reconfigurable Computing Systems ( L) Fall 2012 Tiny Register Machine (TRM)

Reconfigurable Computing Systems ( L) Fall 2012 Tiny Register Machine (TRM) Reconfigurable Computing Systems (252-2210-00L) Fall 2012 Tiny Register Machine (TRM) L. Liu Department of Computer Science, ETH Zürich Fall semester, 2012 1 Introduction Jumping up a few levels of abstraction.

More information

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 Lecture Overview The 68000 Instruction Set continued The understand and effectively use an architecture must understand the register

More information

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name:

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name: EE319K Fall 2012 Exam 1A Modified Page 1 Exam 1 Fun Times Date: October 5, 2012 Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will

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

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

231 Spring Final Exam Name:

231 Spring Final Exam Name: 231 Spring 2010 -- Final Exam Name: No calculators. Matching. Indicate the letter of the best description. (1 pt. each) 1. address 2. object code 3. condition code 4. byte 5. ASCII 6. local variable 7..global

More information

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be tricky) when you translate high-level code into assembler code. MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to

More information

University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section

University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section Name: SOLUTION IS IN RED Thursday 15 February 2018 Net ID: Be sure that your exam booklet has ELEVEN pages. Write your

More information

The University of Michigan - Department of EECS EECS 370 Introduction to Computer Architecture Midterm Exam 1 February 17, 2011

The University of Michigan - Department of EECS EECS 370 Introduction to Computer Architecture Midterm Exam 1 February 17, 2011 The University of Michigan - Department of EECS EECS 370 Introduction to Computer Architecture Midterm Exam 1 February 17, 2011 Name: KEY_(Answers in red) University of Michigan uniqname: (NOT your student

More information

Computer Architecture I Midterm I

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

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 8: Procedures (cont d), Binary Numbers and Adders Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Review: Procedure Calling Steps

More information

Course Administration

Course Administration Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes.

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes. Addressing Modes This is an important feature of computers. We start with the known fact that many instructions have to include addresses; the instructions should be short, but addresses tend to be long.

More information

CS61 Section Solutions 3

CS61 Section Solutions 3 CS61 Section Solutions 3 (Week of 10/1-10/5) 1. Assembly Operand Specifiers 2. Condition Codes 3. Jumps 4. Control Flow Loops 5. Procedure Calls 1. Assembly Operand Specifiers Q1 Operand Value %eax 0x104

More information

Supplement for MIPS (Section 4.14 of the textbook)

Supplement for MIPS (Section 4.14 of the textbook) Supplement for MIPS (Section 44 of the textbook) Section 44 does a good job emphasizing that MARIE is a toy architecture that lacks key feature of real-world computer architectures Most noticable, MARIE

More information

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015 EE319K Spring 2015 Exam 1 Page 1 Exam 1 Date: Feb 26, 2015 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help

More information

Programming at different levels

Programming at different levels CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 EMY MNEMONIC MACHINE LANGUAGE PROGRAMMING EXAMPLES Programming at different levels CS1114 Mathematical Problem : a = b + c CS2214 CS2214 The C-like

More information

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer? Interfacing Compiler and Hardware Computer Systems Architecture FORTRAN 90 program C++ program Processor Types And Sets FORTRAN 90 Compiler C++ Compiler set level Hardware 1 2 What s Should A Processor

More information

ORG ; TWO. Assembly Language Programming

ORG ; TWO. Assembly Language Programming Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify

More information

SRC Assembly Language Programming - III

SRC Assembly Language Programming - III Computer Architecture Laboratory SRC Assembly Language Programming - III Goals: a) Learn assembly language subroutine methodology b) Write a subroutine in SRC assembler 1. As a group we will develop a

More information

Course Administration

Course Administration Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu

More information

Lecture 9 Subroutines

Lecture 9 Subroutines CPE 390: Microprocessor Systems Spring 2018 Lecture 9 Subroutines Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ 07030 Adapted from HCS12/9S12

More information

INFOB3TC Solutions for Exam 2

INFOB3TC Solutions for Exam 2 Department of Information and Computing Sciences Utrecht University INFOB3TC Solutions for Exam 2 Sean Leather Monday, 30 January 2012, 17:00 20:00 Please keep in mind that there are often many possible

More information