COMP2011 Assembly Language Programming and Introduction to WRAMP.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Instruction Set Design
Instruction Set-Intro
Chapter 8: Central Processing Unit
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
The 8051 Microcontroller and Embedded Systems
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
COE Computer Organization & Assembly Language
1 Registers and MAL - Part I. Motivation So far there are some details that we have ignored instructions can have different formats most computers have.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
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.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Unit -II CPU Organization By- Mr. S. S. Hire. CPU organization.
EET 2261 Unit 2 HCS12 Architecture
Implementation of a Stored Program Computer
Computer Architecture
RISC and CISC. Dec. 2008/Dec. and RISC versus CISC The world of microprocessors and CPUs can be divided into two parts:
Computer Organization
Micro-operations Are the functional, or atomic, operations of a processor. A single micro-operation generally involves a transfer between registers, transfer.
CS1Q Computer Systems Lecture 3 Simon Gay. Lecture 3CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
Instruction Set Architecture
Designing the WRAMP Dean Armstrong The University of Waikato.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
COMP3221 lec04--prog-model.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 4: Programmer’s Model of Microprocessors
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
Execution of an instruction
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
ECEG-3202 Computer Architecture and Organization Chapter 7 Reduced Instruction Set Computers.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
CompSci Today’s topics Machine Architecture The basic machine Basic programming Assembler programming Upcoming Language Translation Reading Great.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Computer Organization Instructions Language of The Computer (MIPS) 2.
RISC / CISC Architecture by Derek Ng. Overview CISC Architecture RISC Architecture  Pipelining RISC vs CISC.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
1 TM 1 Embedded Systems Lab./Honam University ARM Microprocessor Programming Model.
CPIT Program Execution. Today, general-purpose computers use a set of instructions called a program to process data. A computer executes the.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
ECE 3430 – Intro to Microcomputer Systems
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
The 8051 Microcontroller and Embedded Systems
Chapter 4 The Von Neumann Model
Overview Introduction General Register Organization Stack Organization
A Closer Look at Instruction Set Architectures
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Chapter 4 The Von Neumann Model
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
Chapter 4 The Von Neumann Model
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Central Processing Unit
The University of Adelaide, School of Computer Science
Classification of instructions
Computer Architecture
Introduction to Microprocessor Programming
The Stored Program Computer
CPU Structure CPU must:
Computer Operation 6/22/2019.
Chapter 4 The Von Neumann Model
Presentation transcript:

COMP2011 Assembly Language Programming and Introduction to WRAMP

COMP201 2 Introduction In previous lectures we have been looking at how data is stored in a computer We will now take a look at how a computer operates In “Stored Program” computers, the most common type, the computer “executes” a “program” created by the programmer The level of abstraction where we can best examine the workings of the computer is at the “assembly language” level  E.g. add $3,$4,$5 “C” assembler Machine code CPU

COMP201 3 Why Assembly Assembly language is used for:  Hand optimisation of commonly used code (now rare as modern optimising compilers are very good)  Machine dependent parts of operating systems.  Device drivers  Some embedded devices with limited memory and simple functionality. Most programmers do not use assembly. It is taught to provide understanding of the CPU.

COMP201 4 Binary vs. assembler The computer itself operates on binary numbers. Programming in binary is extremely difficult; to ease this, assembler language was invented. Assembler uses mnemonics to aid the programmer; an additional step is then required, to translate the assembler into binary for the computer—each CPU is different MOV AL,[0200] becomes A (8086 assembler) Op code Address (LSB first)

COMP201 5 Components of a Programming Language  All programming languages must be able to specify four types of operations: Movement of data;  Must be able to handle various data types Arithmetic operations  e.g. sum = a + b - c; Conditional execution  e.g. while (count =1; count < 10; count++;) {…} if (a < b) c=c+1; else c=c-1; Input and Output.  e.g. Printf (“Total %i\n”,sum);

COMP201 6 Why WRAMP? Most Computer Instruction sets are optimised for performance or backwards compatibility  Tends to make them very complex and hard to learn WRAMP was designed specifically for teaching purposes  Allows us to focus on the main concepts rather than a particular manufacturer’s quirks Very few people will program extensively in assembler but it is studied so that you can better understand CPU operation.

COMP201 7 WRAMP Waikato RISC Architecture Microprocessor Features:  RISC architecture  32 bit data paths  Load/Store memory architecture –limited addressing modes  Three operand format for instructions  Regularity of instructions  Described in VHDL, and implemented in Xilinx FPGA device.  A part of REX, a laboratory exercise machine with WRAMP processor.  Connected to workstation in labs.  Displays for contents of buses.  More: see Exercise 2 (on web page 24/3).

COMP201 8 WRAMP Will use a number of C examples to introduce WRAMP, so the desired operation is clear. Starting with arithmetic operations (+,-,*,/) Generally an assembly language instruction can carry out a single operation, that is… There is a 1:1 mapping between assembler instructions and their binary equivalents sum = a + b; “C” add sum, a, b “pseudo assembler” Exact syntax depends upon processor

COMP201 9 Consider: Where are the variables stored? sum = a + b - c; “C” add temp, a, b sub sum, temp, c “pseudo assembler” add 0x104, 0x100, 0x101 sub 0x103, 0x104, 0x102 “pseudo assembler” a b c sum 0x100 0x101 0x102 0x103 temp 0x104 Memory locations

COMP Instruction Sizes Consider the amount of memory to store the instruction: add a,b,c Number of bits to store an opcode dependent on number of instructions in instruction set--- e.g. 8 bits => 2 8 or 256 instructions (max)…and 6 bits => 64 instructions Operand fields contain addresses of variables being accessed (32 bits per operand) Therefore, instruction size = 8 + (3 * 32) = 102 bits Clearly, something must be done to limit this…

COMP Instruction Sizes (continued)  To execute this instruction would require: 4 memory references to fetch instruction 3 memory references to execute instruction  Several techniques are used which minimize this problem… among them: Use small, local memory (e.g. registers) to store variables Use registers as pointers to memory, instead of directly addressing memory.

COMP Registers  NOTE: Operations inside a processor are significantly faster than those outside, so an operand stored in local memory (registers) can be accessed more quickly than an operand in main memory. Registers analogous to a Nickname (E.g. Palmerston North often referred to as Palmy)  Have to be careful to avoid running out of this local memory; also ambiguity is possible (registers are used for storing many variables at different times during program execution)

COMP Registers  Possibilities: Identify locations referenced frequently and give them a shorter address (sometimes within a given page of memory) create a second small memory (called a register file) to store frequently accessed variables  e.g. 16 word register file requires 4 bit address for any given register, instead of the 32 bits earlier required. Use register contents to point to address within memory, where desired quantity is stored. Sometimes used in conjunction with an offset, allowing access to a block of memory, where a group of data items is stored.

COMP Using registers as pointers to memory Register 1 More registers -16 total 4 bits All of memory 2 32 locations 32 bits Points to a register Points to a memory location Desired contents

COMP Registers (continued)  $i refers to i th word of this memory Instruction add a, b, c could be represented as add $1, $2, $3  As $ predetermined then only need to store 4 bits for each operand, the name of the register where it is stored.  NOTE: values of a,b,c, are encoded in instruction… i.e. the instruction may be different for add $1, $2, $3 and for add $4, $5, $7 0000RdRd RsRs RtRt Register number (0-15)

COMP Registers  As an example, WRAMP has a register file.  This register file is small enough to be stored inside a modern CPU Further reduces number of main memory references, with corresponding speed increase. 0 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $sp ($14) $ra ($15) $ Available for general use Stack pointer Ret address Always 0

COMP Registers  The WRAMP register file has 13 general purpose registers which can be used for whatever temporary storage you need in your program…  But you need to keep track of what variable is stored where! So, make a copy of this page, and allocate your storage space… 0 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $sp ($14) $ra ($15) $ Available for general use

COMP Monitor Commands When running the REX boards, WRAMPmon is the program that interprets your keystrokes into WRAMP actions. The monitor program only responds to certain commands (see web page… resources for the manual) The commands are repeated here, for convenience. load go [address] cont dis [start addr [end]] vm vr [reg] sr sb vb rb s so help or ?

COMP Troubleshooting WRAMP Your major assets for troubleshooting WRAMP are:  A register map  A list of your program  Breakpoints (which you set/reset)  Viewing registers  Program knowledge WRAMP Troubleshooting Aid PC$0$1$2$3 $4$5$6$7 $8$9$10$11 $12$13$sp$ra