MIPS Assembly Language Using QtSpim

2y ago
49 Views
2 Downloads
2.56 MB
122 Pages
Last View : 16d ago
Last Download : 2m ago
Upload by : Baylee Stein
Transcription

MIPSAssembly Languageusing QtSpimEd JorgensenVersion 1.0January 2013

Cover image:MIPS R3000 Custom ChipUsed with permission: http://commons.wikimedia.org/wiki/File:RCP-NUS 01.jpgPermission to reproduce this material for non-commercial use is granted.2

Table of Contents1.0 Introduction.51.1 Additional References.52.0 MIPS Architecture Overview.72.1 Architecture Overview.72.2 Data Types/Sizes.82.3 Memory.82.4 Memory Layout.92.5 Registers.92.5.1 Reserved Registers.103.0 Data Representation.113.1 Integer Representation.113.1.1 Two's Compliment.123.1.2 Byte Example.123.1.3 Word Example.133.2 Unsigned and Signed Addition.133.3 Floating-point Representation.133.3.1 IEEE 32-bit Representation.143.3.1.1 IEEE 32-bit Representation Examples.143.3.1.1.1 Example 7.7510.153.3.1.1.2 Example 0.12510.153.3.1.1.3 Example 4144000016.163.3.2 IEEE 64-bit Representation.164.0 QtSpim Program Formats.174.1 Assembly Process.174.2 Comments.174.3 Assembler Directives.174.4 Data Declarations.174.4.1 Integer Data Declarations.184.4.2 String Data Declarations.194.4.3 Floating-Point Data Declarations.194.5 Constants.204.6 Program Code.204.7 Program Template.215.0 Instruction Set Overview.235.1 Pseudo-Instructions vs Bare-Instructions.235.2 Notational Conventions.235.3 Data Movement.245.4 Integer Arithmetic Operations.255.5 Example Program, Integer Arithmetic.261

5.6 Labels.285.7 Control Instructions.285.7.1 Unconditional Control Instructions.285.7.2 Conditional Control Instructions.295.8 Example Program, Sum of Squares.295.9 Floating-Point Instructions.305.9.1 Floating-Point Register Usage.305.9.2 Floating-Point Instruction Notation.315.9.3 Floating-Point Data Movement.315.9.4 Floating-Point Arithmetic Operations.325.10 Example Program, Floating-Point Arithmetic.336.0 Addressing Modes.376.1 Direct Mode.376.2 Immediate Mode.376.3 Indirection.376.4 Examples.386.4.1 Example Program, Sum and Average.386.4.2 Example Program, Median.397.0 Stack.437.1 Stack Example.437.2 Stack Implementation.447.3 Push.447.4 Pop.447.5 Multiple push/pop's.457.6 Example Program, Stack Usage.458.0 Procedures/Functions.478.1 MIPS Calling Conventions.478.2 Procedure Format.478.2.1 Procedure Format Example.488.3 Caller Conventions.488.4 Linkage.498.5 Argument Transmission.498.5.1 Call-by-Value.498.5.2 Call-by-Reference.498.5.3 Argument Transmission Convention.508.6 Function Results.508.7 Registers Preservation Conventions.508.8 Miscellaneous Register Usage.518.9 Summary, Callee Conventions.518.10 Procedure Call Frame.518.10.1.1 Stack Dynamic Local Variables.528.11 Procedure Examples.528.11.1 Example Program, Power Function.528.11.2 Example program, Summation Function.548.11.3 Example Program, Pythagorean Theorem Procedure.562

9.0 QtSpim System Service Calls.639.1 Supported QtSpim System Services.639.2 QtSpim System Services Examples.649.2.1 Example Program, Display String and Integer.649.2.2 Example Program, Read Integer.659.2.3 Example Program, Display Array.6710.0 Multi-dimension Array Implementation.6910.1 High-Level Language View.6910.2 Row-Major.7010.3 Column-Major.7110.4 Example Program, Matrix Diagonal Summation.7111.0 Recursion.7511.1 Example, Recursive Factorial.7511.1.1 Example Program, Recursive Factorial Function.7611.1.2 Recursive Factorial Function Call Tree.7811.2 Example Fibonacci.7911.2.1 Example Program, Recursive Fibonacci Function.7911.2.2 Recursive Fibonacci Function Call Tree.8112.0Appendix A – Example Program.8313.0 Appendix B – QtSpim Tutorial.8713.1 Downloading and Installing QtSpim.8713.1.1 QtSpim Download URLs.8713.1.2 Installing QtSpim.8713.2 Sample Program.8713.3 QtSpim – Executing Programs.8813.3.1 Starting QtSpim.8813.3.2 Main Screen.8813.3.3 Load Program.8913.3.4 Data Window.9113.3.5 Program Execution.9213.3.6 Log File.9313.3.7 Making Updates.9413.4 Debugging.9514.0 Appendix C – MIPS Instruction Set.10114.1 Arithmetic Instructions.10114.2 Comparison Instructions.10314.3 Branch and Jump Instructions.10414.4 Load Instructions.10714.5 Logical Instructions.10814.6 Store Instructions.11014.7 Data Movement Instructions.11114.8 Floating Point Instructions.11214.9 Exception and Trap Handling Instructions.11615.0Appendix D – ASCII Table.1173

4

1.0IntroductionThere are number of excellent, comprehensive, and in-depth texts on MIPS assembly languageprogramming. This is not one of them.The purpose of this text is to provide a simple and free reference for university level programming andarchitecture units that include a brief section covering MIPS assembly language. The text uses theQtSpim simulator. An appendix covers the downloading, installation, and basic use of the simulator.The scope of this text addresses basic MIPS assembly language programming including instruction setbasics, stack, procedure/function calls, QtSpim simulator system services, multiple dimension arrays,and basic recursion.1.1 Additional ReferencesSome key references for additional information are listed below: MIPS Assembly-language Programmer Guide, Silicon Graphics MIPS Software Users Manual, MIPS Technologies, Inc. Hennessy and Patterson, Computer Organization and Design: The Hardware/Software InterfaceMore information regarding these references can be found on the Internet.5

6

2.0MIPS Architecture OverviewThe following text presents a basic, general overview of the architecture of the MIPS processor.The MIPS architecture is a Reduced Instruction Set Computer (RISC). This means that there is asmaller number of instructions, using a uniform instruction encoding format. Eachinstruction/operation does one thing (memory access, computation, conditional, etc.). The idea is tomake the lesser number of instructions execute faster. In general RISC architectures, and specificallythe MIPS architecture, are designed for high-speed implementations.2.1 Architecture OverviewThe basic components of a computer include a Central Processing Unit (CPU), Random AccessMemory (RAM), Disk Drive, and Input/Output devices (i.e., screen and keyboard), and aninterconnection referred to as BUS.A very basic diagram of a computer architecture is as follows:CPURandom AccessMemory (RAM)BUS(Interconnection)Screen / Keyboard /MouseDisk Drive /Other Storage MediaIllustration 1: Computer ArchitecturePrograms and data are typically stored on the disk drive. When a program is executed, it must becopied from the disk drive into the RAM memory. The CPU executes the program from RAM. This issimilar to storing a term paper on the disk drive, and when writing/editing the term paper, it is copiedfrom the disk drive into memory. When done, the updated version is stored back to the disk drive.7

2.2 Data Types/SizesThe basic data types include integer, f

1.0 Introduction There are number of excellent, comprehensive, and in-depth texts on MIPS assembly language programming. This is not one of them. The purpose of this text is to provide a simple and free reference for university level programming and architecture units that include a brief section covering M

Related Documents:

bits, gọi là MIPS-64. MIPS xem xét trong môn học này là MIPS làm việc với các thanh ghi chỉ 32 bit, gọi là MIPS-32. ÞTrong phạm vi môn học này, MIPS dùng chung sẽ hiểu là MIPS-32 Tóm lại, chỉ có 3 loại toán hạng trong một lệnh của MIPS 1. Toán hạng thanh ghi (Register Operands) 2.

Table 1: How 2020 MIPS Final Scores Relate to 2022 MIPS Payment Adjustments Final Score Points MIPS Payment Adjustment 0.00 – 11.25 points Negative (-) MIPS payment adjustment of -9% 11.26 – 44.99 points Negative (-) MIPS payment adjustment, between 0% and -9%, on a linear sliding scale 45.00 points (Performance threshold 45.00 points)

Performance on EEMBC benchmarks aggregate for Consumer, Telecom, Office, Network, based on ARM1136J-S (Freescale i.MX31), ARM1026EJ-S, Tensilica Diamond 570T, T1050 and T1030, MIPS 20K, NECVR5000). MIPS M4K, MIPS 4Ke, MIPS 4Ks, MIPS 24K, ARM 968E-S, ARM 966E-S, ARM926EJ-S, ARM7TDMI-S scaled by ratio of Dhrystone MIPS within architecture family.

Q3. Assembly Language Programming in MIPS For the MIPS programming questions, use the QtSpim simulator that you used in Recitation #3. IMPORTANT: Read this whole document – there’s both caveats and tips in here! Differences from Homework 1 These programming questions are almost the

Q3. Assembly Language Programming in MIPS For the MIPS programming questions, use the QtSpim simulator that you used in Recitation #3. These programming questions are almost the same as those from Homework 1 with the following key differences: In HW1, input came from command line arguments. In this assignment, input is typed into the console.

ACOs in MIPS receive advantages by being scored under the MIPS APM Scoring Standard, which gives ACOs favorable treatment for their commitment to value-base care. Based on the low bar set for 2019 reporting in MIPS, ACOs should easily avoid penalties under MIPS and will be eligible for MIPS bonuses and exceptional performance bonuses.

Chapter 1: Getting started with mips Remarks This section provides an overview of what mips is, and why a developer might want to use it. It should also mention any large subjects within mips, and link out to the related topics. Since the Documentation for mips is new, you may need to create initial versions of those related topics. Examples

Devices in ST’s ARM Cortex‑M0‑based STM32F0 series deliver 32‑bit performance while featuring the essentials of the STM32 family and are particularly suited for cost‑sensitive applications. STM32F0 MCUs combine real‑time performance, low‑power operation, and the advanced architecture and peripherals of the STM32 platform.