Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.

Slides:



Advertisements
Similar presentations
Instruction Set-Intro
Advertisements

Chapter 10- Instruction set architectures
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler I.
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
Low-Level Programming Languages
Programming and Problem Solving
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
MIPS Instruction Set Advantages
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
Assembly & Machine Languages
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Writing an Assembly-language program Atmel assembly language CS-280 Dr. Mark L. Hornick 1.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language.
A Simple Two-Pass Assembler
Programming and Problem Solving ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
CE-2810 Dr. Mark L. Hornick 1 GNU GCC Assembler and C/C++ compiler.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2)
Lecture 15 Today’s lecture MARIE programming Assembler
Execution of an instruction
1 Assemblers System Programming by Leland L. Beck Chapter 2.
Computer Operations A computer is a programmable electronic device that can store, retrieve, and process data Data and instructions to manipulate the data.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
8086/8088 Instruction Set, Machine Codes and Addressing Modes.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Simulator Outline of MIPS Simulator project  Write a simulator for the MIPS five-stage pipeline that does the following: Implements a subset of.
Today’s Agenda Exam 2 Part 2 (11:15am-12:30pm)
MIPS Instruction Set Advantages
Control Unit Lecture 6.
Assembly Language Assembly Language
MIPS assembly syntax Comments
Computer Science 210 Computer Organization
Instructions for Making Decisions
MIPS coding.
Chapter 7 LC-2 Assembly Language.
Computer Science 210 Computer Organization
Lecture 4: MIPS Instruction Set
Assembler CASE Tool.
Chap. 6 Programming the Basic Computer
MIPS Instruction Encoding
Chapter 7 Assembly Language
ECEG-3202 Computer Architecture and Organization
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
MIPS Instruction Encoding
Chapter 7 LC-2 Assembly Language.
Keith Carolus and Dr. Alphonce
CS334: Memory _ Mars simulator Lab 4(part2-2)
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
A Discussion on Assemblers
COMS 361 Computer Organization
University of Gujrat Department of Computer Science
Program Execution.
MIPS coding.
Chapter 6 Programming the basic computer
CS334: MIPS language _Mars simulator Lab 2_1
Computer Organization and Assembly Language
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Computer Architecture and System Programming Laboratory
Presentation transcript:

Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1

CS-2710 Dr. Mark L. Hornick 2 The MARS Assembler …is a modern, “single pass” Assembler Converts mnemonics to machine instructions (opcodes + operands) Ex: add $t0, $s1, $s2 is assembled to 0x Case on instructions is irrelevant; alternately: ADD $t0, $s1, $s2 Case on registers matters: $T0 is not permitted Reports syntactical errors Ex: add $t0, $s1 (e.g. too few operands) Can generate files containing machine code in a format that can be downloaded to real hardware

CS-2710 Dr. Mark L. Hornick 3 MARS also implements a Debugger/Simulator Simulates execution of the compiled program Start, stop, single-step Backwards step Breakpoints Can view contents of memory, registers Tracks cycles required to execute And lots more – see the help documentation

CS-2710 Dr. Mark L. Hornick 4 Number representation in MIPS assembly language All values are decimal unless notated otherwise addi $t0, $s1, 100 # decimal 100 (default) addi $t0, $s1, 0144 # octal 100 (note leading 0) addi $t0, $s1, 0x64 # hex 100 (note leading 0x) Radix prefixes 0 – octal 0x, 0X – hexadecimal 0x002a is equivalent to 0x2A

CS-2710 Dr. Mark L. Hornick 5 Labels can be used in place of actual addresses Every input line can be preceded by a label an alphanumeric string terminated by a colon (:) Labels are used as targets for jump and branch instructions The assembler automatically figures out what address to assign to a label

CS-2710 Dr. Mark L. Hornick 6 Every input line can be preceded by a label Example: Start: addi $t0, $s1, 100 # t0 = s Here: j Here# repeat forever Labels are alphanumeric strings terminated by a colon(:) Labels are given the value of the location in memory where the following instruction will be placed Labels can be used as jump and branch targets in program instructions The label Start: is assigned the value of the location of the addi instruction (0x ); Here: is assigned 0x c, the location of the j instruction The assembler automatically figures out what address to assign to a label

CS-2710 Dr. Mark L. Hornick 7 Directives are used within an assembly language program to control certain aspects of the operation of the Assembler Directives begin with a period (.) Directive often take operands, but not always Ex:.text Ex:.byte 1,2,3,4 Case does not matter.TEXT is equivalent Directives are not instructions – they are not translated to machine instructions They only “direct” the Assembler how to interpret subsequent assembly language instructions All directives are documented in the online help of MARS Directives may appear anywhere in an assembly program

CS-2710 Dr. Mark L. Hornick 8 Some assembler directives are used to define where to place things in memory:.text [loc] Alerts the Assembler that subsequent assembly statements are intended to generate instructions for the Text Segment of main memory ie, where executable machine code is placed Location set by MARS memory configuration settings If absent, a default value will be used by the Assembler.data [loc] Directs the Assembler where to begin placing subsequent data in memory Example:.data.byte 1,2,3,4 directs the subsequent data bytes 1,2,3,4,5 to be placed in the data segment of main memory