ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Thursday, October 10 (100 points)
|
|
- Morris Wilkins
- 7 years ago
- Views:
Transcription
1 ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Thursday, October 10 (100 points) Objectives: Get familiar with MIPS instructions Assemble, execute and debug MIPS assembly programs What to hand in: 1. Assembly Programs Submit your project codes in one zip file to 1. MIPS Instructions MIPS stands for Microprocessor without Interlocked Pipeline Stages. MIPS designs are used in many embedded systems such as Sony PlayStation 2, Cisco routers, and Windows CE devices. Since MIPS has greatly influenced later design of instruction sets and processors, MIPS will be the main assembly language used in ECE 473. The following shows a simple loop example in C. We can translate this simple loop into a MIPS program: 2. MIPS simulator running on MARS: SPIM MARS is an interactive software simulator for MIPS based on Java. You can download the latest version of MARS from here In Linux, in command line, run: java -jar Mars.jar In Windows, either double-click the Mars.jar file or run java -jar Mars.jar 1
2 The website also provides the following three sample programs: Fibonacci.asm, row-major.asm, column-major.asm 3. Quick Reference of MIPS Programming 3.1 Accessing Array list:.word 3, 0, 1, 2, 6, -2, 4, 7, 3, 7 la $t3, list # put address of list into $t3 lw $t4, 0($t3) # get the value list[0] lw $t4, 4($t3) # get the value list[1] lw $t4, 8($t3) # get the value list[2] 3.2 Conditional Statement Assume $r1 stores i and $r2 stores j. if ( i == j ) i++ ; j-- ; bne $r1, $r2, L1 # branch if! ( i == j ) addi $r1, $r1, 1 # i++ L1: addi $r2, $r2, -1 # j if ( i == j ) i++ ; j-- ; j += i ; bne $r1, $r2, ELSE # branch if! ( i == j ) addi $r1, $r1, 1 # i++ j L1 # jump over (ADD THIS!!!) ELSE: addi $r2, $r2, -1 # j-- L1: add $r2, $r2, $r1 # j += i if ( i == j && i == k ) i++ ; // if-body j-- ; // -body j = i + k ; bne $r1, $r2, ELSE # cond1: branch if! ( i == j ) bne $r1, $r3, ELSE # cond2: branch if! ( i == k ) addi $r1, $r1, 1 # if-body: i++ j L1 # jump over ELSE: addi $r2, $r2, -1 # -body: j-- L1: add $r2, $r1, $r3 # j = i + k if ( i == j i == k ) i++ ; // if-body j-- ; // -body j = i + k ; beq $r1, $r2, IF # cond1: branch if ( i == j ) bne $r1, $r3, ELSE # cond2: branch if! ( i == k ) IF: addi $r1, $r1, 1 # if-body: i++ j L1 # jump over ELSE: addi $r2, $r2, -1 # -body: j-- L1: add $r2, $r1, $r3 # j = i + k 2
3 switch( i ) { case 1: i++ ; // falls through case 2: i += 2 ; break; case 3: i += 3 ; addi $r4, $r0, 1 # set temp to 1 bne $r1, $r4, C2_COND # case 1 false: branch to case 2 cond j C1_BODY # case 1 true: branch to case 1 C2_COND: addi $r4, $r0, 2 # set temp to 2 bne $r1, $r4, C3_COND # case 2 false: branch to case 2 cond j C2_BODY # case 2 true: branch to case 2 body C3_COND: addi $r4, $r0, 3 # set temp to 3 bne $r1, $r4, EXIT # case 3 false: branch to exit j C3_BODY # case 3 true: branch to case 3 body C1_BODY: addi $r1, $r1, 1 # case 1 body: i++ C2_BODY: addi $r1, $r1, 2 # case 2 body: i += 2 j EXIT # break C3_BODY: addi $r1, $r1, 3 # case 3 body: i += 3 EXIT: # j = i + k 3.3 Loop Statement while ( i < k ){ k++ ; i = i * 2 ; L1: if ( i < k ){ k++; i = i * 2; goto L1; # $r1 = i and $r3 = k. L1: bge $r1, $r3, EXIT # branch if! ( i < k ) addi $r3, $r3, 1 # k++ add $r1, $r1, $r1 # i = i * 2 j L1 # jump back EXIT: for ( <init> ; <cond> ; <update> ) { <for-body> <init> L1: if ( <cond> ) { <for-body> UPDATE: <update> goto L1 ; EXIT: There's only one special case. Suppose the <for-body> has a continue statement. Then, you need to jump to the <update> code, which is at the UPDATE label. Name Number Usage Name Number Usage $zero 0 constant 0 $s0-$s7 16 temporary saved $at 1 reserved for assembler $t8 24 temporary $v0 2 return value $t9 25 temporary $v1 3 return value $k0 26 reserved for OS kernel $a0 4 procedure argument 1 $k1 27 reserved for OS kernel $a1 5 procedure argument 2 $gp 28 pointer to global area $a2 6 procedure argument 3 $sp 29 stack pointer $a3 7 procedure argument 4 $fp 30 frame pointer $t0 8 temporary $ra 31 return address $t1-$7 9 temporary 3
4 3.4 Function Calls Calling a subroutine is between a caller, who makes the subroutine call, and the callee, which is the subroutine itself. The caller passes arguments to the callee by placing the values into the argument registers $a0-$a3. The caller calls jal followed by the label of the subroutine. This saves the return address in $ra. The return address is PC + 4, where PC is the address of the jal instruction If the callee uses a frame pointer, then it usually sets it to the stack pointer. The old frame pointer must be saved on the stack before this happens. The callee usually starts by pushing any registers it needs to save on the stack. If the callee calls a helper subroutine, then it must push $ra on the stack. It may need to push temporary or saved registers as well. Once the subroutine is complete, the return value is place in $v0-$v1. The callee then calls jr $ra to return back to the caller. The following give two examples of recursive function calls. Example 1: Sum all elements of an array. int sum( int arr[], int size ) { if ( size == 0 ) return 0 ; return sum( arr, size - 1 ) + arr[ size - 1 ] ; Assume arr is in $a0 and size is in $a1. sum: addi $sp, $sp, -8 # Adjust sp addi $t0, $a0, -1 # Compute size - 1 sw $t0, 0($sp) # Save size - 1 to stack sw $ra, 4($sp) # Save return address bne $t0, $zero, ELSE # branch! ( size == 0 ) li $v0, 0 # Set return value to 0 addi $sp, $sp, 8 # Adjust sp jr $ra # Return ELSE: move $a1, $t0 # update second arg jal sum lw $t0, 0($sp) # Restore size - 1 from stack sll $t1, $t0, 2 # Multiple size - 1 by 4 add $t1, $t1, $a0 # Compute & arr[ size - 1 ] lw $t2, 0($t1) # t2 = arr[ size - 1 ] add $v0, $v0, $t2 # retval = $v0 + arr[size - 1] lw $ra, 4($sp) # restore return address from stack addi $sp, $sp, 8 # Adjust sp jr $ra # Return 4
5 Example 2: Sum only the odd elements of an array. int sumodd( int arr[], int size ) { if ( size == 0 ) return 0 ; if ( arr[ size - 1 ] % 2 == 1 ) return sumodd( arr, size - 1 ) + arr[ size - 1 ] ; return sumodd( arr, size - 1 ) ; The difficult part is to decide what registers to save. arr is stored in $a0, and it is not changed throughout. size may need to be saved, though size - 1 appears to be more useful. Since we make calls to sumodd, we need to save $ra. So, let's save size - 1 and $ra to the stack. It turns out we also need to save arr[ size - 1 ] to the stack too. sumodd: addi $sp, $sp, -12 # Adjust sp addi $t0, $a0, -1 # Compute size - 1 sw $t0, 0($sp) # Save size - 1 to stack sw $ra, 4($sp) # Save return address bne $t0, $zero, ELSE2 # branch!( size == 0 ) li $v0, 0 # Set return value to 0 addi $sp, $sp, 12 # Adjust sp jr $ra # Return ELSE2: sll $t1, $t0, 2 # Multiple size - 1 by 4 add $t1, $t1, $a0 # Compute & arr[ size - 1 ] lw $t2, 0($t1) # t2 = arr[ size - 1 ] andi $t3, $t2, 1 # is arr[ size - 1 ] odd beq $t3, $zero, ELSE3 # branch if even sw $t2, 8($sp) # save arr[ size - 1 ] on stack move $a1, $t0 # update second arg jal sumodd lw $t2, 8($sp) # restore arr[ size - 1 ] from stack add $v0, $v0, $t2 # update return value lw $ra, 4($sp) # restore return address from stack addi $sp, $sp, 12 # Adjust sp jr $ra # Return 5
6 4. Quick Reference of Mars 4.1 User interface Pictures are obtained from 6
7 4.2 Comments and directives # starts a comment.text is a directive. A directive is a statement that tells the assembler something about what the programmer wants, but does not itself result in any machine instructions. This directive tells the assembler that the following lines are ".text" - - source code for the program..globl main is another directive. It says that the identifier main will be used outside of this source file (that is, used "globally") as the label of a particular location in main memory (here, it is 0x The address of the 1 st instruction)..data starts the data segment. All of these are used in the data segment:.asciiz string Defines a null-terminated string (strings you output with a syscall must end with a null, which is a 00 in ascii).byte b0,b1,b2 Defines and initializes subsequent bytes in memory.half h0,h1,h2 Defines and initializes subsequent half-words (16-bit values) in memory alignment forced to next even address.word w0,w1,w2 Defines and initializes subsequent words (32-bit values) in memory.space n alignment forced to next word address (multiple of 4) allocates n bytes of space Identifier names are sequence of letters, numbers, underbars (_) and dots (.). Labels are declared by putting them at beginning of line followed by colon. Use labels for variables and code locations. Instruction format: op field followed by one or more operands: addi $t0, $t0, 1 Operands may be literal values or registers. Register is hardware primitive, can stored 32-bit value: $s0 Numbers are base 10 by default. 0x prefix indicates hexadecimal. Strings are enclosed in quotes. May include \n=newline or \t=tab. Used for prompts. 4.3 Endianness Endianness is the byte ordering used to represent data. The two orders are called "Little Endian" and "Big Endian". Little Endian means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte LongInt Byte3 Byte2 Byte1 Byte0 will be arranged in memory as follows: Base Address+0 Byte0 Base Address+1 Byte1 Base Address+2 Byte2 Base Address+3 Byte3 Intel processors (those used in PC's) use "Little Endian" byte order. 7
8 Big Endian means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as: Base Address+0 Byte3 Base Address+1 Byte2 Base Address+2 Byte1 Base Address+3 Byte0 Motorola processors (those used in Mac's) use "Big Endian" byte order. 4.4 Data Storage in Memory For ASCII, every character is represented by its corresponding ASCII code (a byte). For example, str:.asciiz the answer = You will see the following in PCSPim (in a system with little endianness). [0x ] 0x x77736E61 0x3D x The data represents: Address Data(hex) F 00 undefined E 00 undefined D 00 <null> C 20 <sp> B 3D = A 20 <sp> r e w s E n a <sp> e h t Here is another example: #specify some data to be loaded into memory.data nums:.byte 1,2,3,4.half 5,6,7,8.word 9,10,11,12.space 5.word 9,10,11,12.asciiz ABCD 8
9 .ascii ABCD.byte -1.text.globl main main: li $v0,10 #sys call for exit syscall After loading the program, the data display would show: DATA [0x ] 0x x x x [0x ] 0x A 0x B 0x C 0x [0x ] 0x x x A 0x B [0x ] 0x C 0x x x0000FF44 Address Data C 0000FF C C B A C C B A C
10 ECE 473 Computer Architecture and Organization Fall 2013 Lab Assignment 4 1. String handling [30 points] Declare a string in the data section:.data string:.asciiz "ABCDEFG" Write a program that converts the string to all lower case characters. Hint: add 0x20 to each character in the string. 2. Pointers [30 points] Write a program in MIPS assembly language that will compute the sum of all the elements in an array. Write this program using a function PSum, which takes two parameters, including a pointer to the running sum and a pointer to the current element. The C function looks like this: int sum = 0; int *sump = int a[10]; void PSum(int *s, int *e) { *s += *e; int main() { for (int i=0; i<10; i++) { a[i] = i; for (int i=0; i<10; i++) { PSum(sump, a+i); 3. Recursion [40 points] Write a program in MIPS Assembly Language that to find fix(i, x), where fix(i, x) is defined recursively as: int fix(int i, int x) { // assume i > 0, x > 0 if (x>0) return fix(i, x-1); if (i>0) return fix(i-1, i-1)+2; return 0; 10
11 ECE 473 Lab Check off Sheet Lab 4: MIPS Assembly Programming Fall 2013 Student Name: TA: Time & Date: 1. String Manipulation (30%) 2. Pointers (30%) 3. Recursion (40%) Total 11
Translating C code to MIPS
Translating C code to MIPS why do it C is relatively simple, close to the machine C can act as pseudocode for assembler program gives some insight into what compiler needs to do what's under the hood do
More informationMIPS Assembly Code Layout
Learning MIPS & SPIM MIPS assembly is a low-level programming language The best way to learn any programming language is to write code We will get you started by going through a few example programs and
More informationTypy danych. Data types: Literals:
Lab 10 MIPS32 Typy danych Data types: Instructions are all 32 bits byte(8 bits), halfword (2 bytes), word (4 bytes) a character requires 1 byte of storage an integer requires 1 word (4 bytes) of storage
More informationIntroduction to MIPS Assembly Programming
1 / 26 Introduction to MIPS Assembly Programming January 23 25, 2013 2 / 26 Outline Overview of assembly programming MARS tutorial MIPS assembly syntax Role of pseudocode Some simple instructions Integer
More informationFigure 1: Graphical example of a mergesort 1.
CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your
More informationInstruction Set Architecture
Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)
More informationMore MIPS: Recursion. Computer Science 104 Lecture 9
More MIPS: Recursion Computer Science 104 Lecture 9 Admin Homework Homework 1: graded. 50% As, 27% Bs Homework 2: Due Wed Midterm 1 This Wed 1 page of notes 2 Last time What did we do last time? 3 Last
More informationLab Work 2. MIPS assembly and introduction to PCSpim
Lab Work 2. MIPS assembly and introduction to PCSpim The goal of this work is for the student to become familiar with the data types and the programming in assembly (MIPS32). To realize this lab work you
More informationComputer Systems Architecture
Computer Systems Architecture http://cs.nott.ac.uk/ txa/g51csa/ Thorsten Altenkirch and Liyang Hu School of Computer Science University of Nottingham Lecture 10: MIPS Procedure Calling Convention and Recursion
More informationStack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.
Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables
More informationInstruction Set Architecture. or How to talk to computers if you aren t in Star Trek
Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture
More informationExceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine
7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change
More informationAssembly Language Programming
Assembly Language Programming Assemblers were the first programs to assist in programming. The idea of the assembler is simple: represent each computer instruction with an acronym (group of letters). Eg:
More informationChapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
More informationLecture Outline. Stack machines The MIPS assembly language. Code Generation (I)
Lecture Outline Code Generation (I) Stack machines The MIPS assembl language Adapted from Lectures b Profs. Ale Aiken and George Necula (UCB) A simple source language Stack- machine implementation of the
More informationWinter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2002 MID-SESSION TEST Friday,
More informationReduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying
More informationA single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc
Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc
More informationSyscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas
Syscall 5 System call 5 allows input of numerical data from the keyboard while a program is running. Syscall 5 is a bit unusual, in that it requires the use of register $v0 twice. In syscall 5 (as for
More informationIntel 8086 architecture
Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086
More informationAn Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
More informationM A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE
M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE 1. Introduction 6.004 Computation Structures β Documentation This handout is
More informationMemory Systems. Static Random Access Memory (SRAM) Cell
Memory Systems This chapter begins the discussion of memory systems from the implementation of a single bit. The architecture of memory chips is then constructed using arrays of bit implementations coupled
More informationThe programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
More informationHow To Write An Array In A Microsoft Zil
Array Declaration and Storage Allocation The first step is to reserve sufficient space for the array: 1.data list:.space 1000 # reserves a block of 1000 bytes This yields a contiguous block of bytes of
More informationChapter 5 Instructor's Manual
The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction
More information5 MIPS Assembly Language
103 5 MIPS Assembly Language Today, digital computers are almost exclusively programmed using high-level programming languages (PLs), eg, C, C++, Java The CPU fetch execute cycle, however, is not prepared
More informationCOMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59
COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59 Overview: In the first projects for COMP 303, you will design and implement a subset of the MIPS32 architecture
More informationReview: MIPS Addressing Modes/Instruction Formats
Review: Addressing Modes Addressing mode Example Meaning Register Add R4,R3 R4 R4+R3 Immediate Add R4,#3 R4 R4+3 Displacement Add R4,1(R1) R4 R4+Mem[1+R1] Register indirect Add R4,(R1) R4 R4+Mem[R1] Indexed
More informationBefore entering the lab, make sure that you have your own UNIX and PC accounts and that you can log into them.
1 Objective Texas A&M University College of Engineering Computer Science Department CPSC 321:501 506 Computer Architecture Fall Semester 2004 Lab1 Introduction to SPIM Simulator for the MIPS Assembly Language
More informationLecture 22: C Programming 4 Embedded Systems
Lecture 22: C Programming 4 Embedded Systems Today s Goals Basic C programming process Variables and constants in C Pointers to access addresses Using a High Level Language High-level languages More human
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationInstruction Set Architecture (ISA) Design. Classification Categories
Instruction Set Architecture (ISA) Design Overview» Classify Instruction set architectures» Look at how applications use ISAs» Examine a modern RISC ISA (DLX)» Measurement of ISA usage in real computers
More informationPROBLEMS (Cap. 4 - Istruzioni macchina)
98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary
More informationIntroduction to MIPS Programming with Mars
Introduction to MIPS Programming with Mars This week s lab will parallel last week s lab. During the lab period, we want you to follow the instructions in this handout that lead you through the process
More informationMIPS Assembler and Simulator
MIPS Assembler and Simulator Reference Manual Last Updated, December 1, 2005 Xavier Perséguers (ing. info. dipl. EPF) Swiss Federal Institude of Technology xavier.perseguers@a3.epfl.ch Preface MIPS Assembler
More informationCSE 141 Introduction to Computer Architecture Summer Session I, 2005. Lecture 1 Introduction. Pramod V. Argade June 27, 2005
CSE 141 Introduction to Computer Architecture Summer Session I, 2005 Lecture 1 Introduction Pramod V. Argade June 27, 2005 CSE141: Introduction to Computer Architecture Instructor: Pramod V. Argade (p2argade@cs.ucsd.edu)
More informationStack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
More informationInstruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
More informationPCSpim Tutorial. Nathan Goulding-Hotta 2012-01-13 v0.1
PCSpim Tutorial Nathan Goulding-Hotta 2012-01-13 v0.1 Download and install 1. Download PCSpim (file PCSpim_9.1.4.zip ) from http://sourceforge.net/projects/spimsimulator/files/ This tutorial assumes you
More informationASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)
ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6) 1 COMPUTER LANGUAGES In order for a computer to be able to execute a program, the program must first be present
More informationJonathan Worthington Scarborough Linux User Group
Jonathan Worthington Scarborough Linux User Group Introduction What does a Virtual Machine do? Hides away the details of the hardware platform and operating system. Defines a common set of instructions.
More informationC Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands
C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is
More informationThe Operating System and the Kernel
The Kernel and System Calls 1 The Operating System and the Kernel We will use the following terminology: kernel: The operating system kernel is the part of the operating system that responds to system
More informationThe stack and the stack pointer
The stack and the stack pointer If you google the word stack, one of the definitions you will get is: A reserved area of memory used to keep track of a program's internal operations, including functions,
More informationASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER
ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER Pierre A. von Kaenel Mathematics and Computer Science Department Skidmore College Saratoga Springs, NY 12866 (518) 580-5292 pvonk@skidmore.edu ABSTRACT This paper
More informationEE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100)
EE282 Computer Architecture and Organization Midterm Exam February 13, 2001 (Total Time = 120 minutes, Total Points = 100) Name: (please print) Wolfe - Solution In recognition of and in the spirit of the
More informationIntroducción. Diseño de sistemas digitales.1
Introducción Adapted from: Mary Jane Irwin ( www.cse.psu.edu/~mji ) www.cse.psu.edu/~cg431 [Original from Computer Organization and Design, Patterson & Hennessy, 2005, UCB] Diseño de sistemas digitales.1
More information2) Write in detail the issues in the design of code generator.
COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage
More informationFall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly
Lab Objectives: Fall 2006 CS/ECE 333 Lab 1 Programming in SRC Assembly 1. How to assemble an assembly language program for the SRC using the SRC assembler. 2. How to simulate and debug programs using the
More informationComputer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.
Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.tw Review Computers in mid 50 s Hardware was expensive
More informationX86-64 Architecture Guide
X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationHow To Write Portable Programs In C
Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important
More informationMACHINE ARCHITECTURE & LANGUAGE
in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based
More informationMICROPROCESSOR AND MICROCOMPUTER BASICS
Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit
More informationAn Introduction to the ARM 7 Architecture
An Introduction to the ARM 7 Architecture Trevor Martin CEng, MIEE Technical Director This article gives an overview of the ARM 7 architecture and a description of its major features for a developer new
More informationC Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
More informationlanguage 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
More informationEC 362 Problem Set #2
EC 362 Problem Set #2 1) Using Single Precision IEEE 754, what is FF28 0000? 2) Suppose the fraction enhanced of a processor is 40% and the speedup of the enhancement was tenfold. What is the overall speedup?
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code
More informationIntel Hexadecimal Object File Format Specification Revision A, 1/6/88
Intel Hexadecimal Object File Format Specification Revision A, 1/6/88 DISCLAIMER Intel makes no representation or warranties with respect to the contents hereof and specifically disclaims any implied warranties
More informationwhat operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?
Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the
More informationLC-3 Assembly Language
LC-3 Assembly Language Programming and tips Textbook Chapter 7 CMPE12 Summer 2008 Assembly and Assembler Machine language - binary Assembly language - symbolic 0001110010000110 An assembler is a program
More informationCS61: Systems Programing and Machine Organization
CS61: Systems Programing and Machine Organization Fall 2009 Section Notes for Week 2 (September 14 th - 18 th ) Topics to be covered: I. Binary Basics II. Signed Numbers III. Architecture Overview IV.
More informationLecture 27 C and Assembly
Ananda Gunawardena Lecture 27 C and Assembly This is a quick introduction to working with x86 assembly. Some of the instructions and register names must be check for latest commands and register names.
More informationUnix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2
Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................
More informationSummary of the MARIE Assembly Language
Supplement for Assignment # (sections.8 -. of the textbook) Summary of the MARIE Assembly Language Type of Instructions Arithmetic Data Transfer I/O Branch Subroutine call and return Mnemonic ADD X SUBT
More informationKeil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
More informationHexadecimal Object File Format Specification
Hexadecimal Object File Format Specification Revision A January 6, 1988 This specification is provided "as is" with no warranties whatsoever, including any warranty of merchantability, noninfringement,
More informationTable 1 below is a complete list of MPTH commands with descriptions. Table 1 : MPTH Commands. Command Name Code Setting Value Description
MPTH: Commands Table 1 below is a complete list of MPTH commands with descriptions. Note: Commands are three bytes long, Command Start Byte (default is 128), Command Code, Setting value. Table 1 : MPTH
More informationCS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture CS:APP2e Instruction Set Architecture Assembly Language View Processor state Registers, memory, Instructions addl, pushl, ret, How instructions
More informationDesign of Digital Circuits (SS16)
Design of Digital Circuits (SS16) 252-0014-00L (6 ECTS), BSc in CS, ETH Zurich Lecturers: Srdjan Capkun, D-INFK, ETH Zurich Frank K. Gürkaynak, D-ITET, ETH Zurich Labs: Der-Yeuan Yu dyu@inf.ethz.ch Website:
More informationCS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of
CS:APP Chapter 4 Computer Architecture Wrap-Up William J. Taffe Plymouth State University using the slides of Randal E. Bryant Carnegie Mellon University Overview Wrap-Up of PIPE Design Performance analysis
More informationInstruction Set Design
Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,
More informationChapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC
Chapter 2 Topics 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC See Appendix C for Assembly language information. 2.4
More information1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
More informationAn Overview of Stack Architecture and the PSC 1000 Microprocessor
An Overview of Stack Architecture and the PSC 1000 Microprocessor Introduction A stack is an important data handling structure used in computing. Specifically, a stack is a dynamic set of elements in which
More informationCSE 141L Computer Architecture Lab Fall 2003. Lecture 2
CSE 141L Computer Architecture Lab Fall 2003 Lecture 2 Pramod V. Argade CSE141L: Computer Architecture Lab Instructor: TA: Readers: Pramod V. Argade (p2argade@cs.ucsd.edu) Office Hour: Tue./Thu. 9:30-10:30
More informationWhat to do when I have a load/store instruction?
76 What to do when I have a load/store instruction? Is there a label involved or a virtual address to compute? 1 A label (such as ldiq $T1, a; ldq $T0, ($T1);): a Find the address the label is pointing
More informationCPU Organization and Assembly Language
COS 140 Foundations of Computer Science School of Computing and Information Science University of Maine October 2, 2015 Outline 1 2 3 4 5 6 7 8 Homework and announcements Reading: Chapter 12 Homework:
More informationMIPS Assembly Language Programming CS50 Discussion and Project Book. Daniel J. Ellard
MIPS Assembly Language Programming CS50 Discussion and Project Book Daniel J. Ellard September, 1994 Contents 1 Data Representation 1 1.1 Representing Integers........................... 1 1.1.1 Unsigned
More informationCommunicating with a Barco projector over network. Technical note
Communicating with a Barco projector over network Technical note MED20080612/00 12/06/2008 Barco nv Media & Entertainment Division Noordlaan 5, B-8520 Kuurne Phone: +32 56.36.89.70 Fax: +32 56.36.883.86
More informationHacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail
Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail All materials is licensed under a Creative Commons Share Alike license http://creativecommonsorg/licenses/by-sa/30/ # whoami Ali
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More informationEfficient Low-Level Software Development for the i.mx Platform
Freescale Semiconductor Application Note Document Number: AN3884 Rev. 0, 07/2009 Efficient Low-Level Software Development for the i.mx Platform by Multimedia Applications Division Freescale Semiconductor,
More informationROM Monitor. Entering the ROM Monitor APPENDIX
APPENDIX B This appendix describes the Cisco router ROM monitor (also called the bootstrap program). The ROM monitor firmware runs when the router is powered up or reset. The firmware helps to initialize
More informationUNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995
UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering EEC180B Lab 7: MISP Processor Design Spring 1995 Objective: In this lab, you will complete the design of the MISP processor,
More information64-Bit NASM Notes. Invoking 64-Bit NASM
64-Bit NASM Notes The transition from 32- to 64-bit architectures is no joke, as anyone who has wrestled with 32/64 bit incompatibilities will attest We note here some key differences between 32- and 64-bit
More informationCaml Virtual Machine File & data formats Document version: 1.4 http://cadmium.x9c.fr
Caml Virtual Machine File & data formats Document version: 1.4 http://cadmium.x9c.fr Copyright c 2007-2010 Xavier Clerc cadmium@x9c.fr Released under the LGPL version 3 February 6, 2010 Abstract: This
More informationEmbedded Software development Process and Tools: Lesson-4 Linking and Locating Software
Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software 1 1. Linker 2 Linker Links the compiled codes of application software, object codes from library and OS kernel functions.
More informationFirst Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
More informationİSTANBUL AYDIN UNIVERSITY
İSTANBUL AYDIN UNIVERSITY FACULTY OF ENGİNEERİNG SOFTWARE ENGINEERING THE PROJECT OF THE INSTRUCTION SET COMPUTER ORGANIZATION GÖZDE ARAS B1205.090015 Instructor: Prof. Dr. HASAN HÜSEYİN BALIK DECEMBER
More informationExplain the relationship between a class and an object. Which is general and which is specific?
A.1.1 What is the Java Virtual Machine? Is it hardware or software? How does its role differ from that of the Java compiler? The Java Virtual Machine (JVM) is software that simulates the execution of a
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects
More informationCOMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING
COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING 2013/2014 1 st Semester Sample Exam January 2014 Duration: 2h00 - No extra material allowed. This includes notes, scratch paper, calculator, etc.
More informationJAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
More informationEmbedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
More informationMICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1
MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable
More information