Write a program to calculate x**y, given x and y.

Slides:



Advertisements
Similar presentations
Chapter 3 Introduction to the 68000
Advertisements

EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
Control Structures in ARM Implementation of Decisions Similar to accumulator instructions One instruction sets the flags, followed by another instruction.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
Deeper Assembly: Addressing, Conditions, Branching, and Loops
CMPT 334 Computer Organization Chapter 2 Instructions: Language of the Computer [Adapted from Computer Organization and Design 5 th Edition, Patterson.
The Little man computer
Flow Control Instructions
CEG 320/520: Computer Organization and Assembly Language ProgrammingFlow Control 1 Flow Control.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Making Decision – Microprocessor
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
9/20/6Lecture 3 - Instruction Set - Al1 Program Design Examples.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
ARM Instructions ARM instructions are written as an operation code (opcode), followed by zero or more operands Operands may be constants (8-bit value),
5-1 EE 319K Introduction to Microcontrollers Lecture 5: Conditionals, Loops, Modular Programming, Sub- routines, Parameter passing.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
David Kauchak CS 52 – Spring 2017
Deeper Assembly: Addressing, Conditions, Branching, and Loops
The Little man computer
Unit 1 Instruction set M.Brindha AP/EIE
Slide 7 Mikroprosesor Sub. Algoritma Program___
e. g. Write a program to count the spaces in a string
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
MIPS Instruction Set Advantages
Control Unit Lecture 6.
Assembly Language Programming of 8085
ECE 3430 – Intro to Microcomputer Systems
The University of Adelaide, School of Computer Science
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
SUBJECT:COMPUTER ORGANISATION SUBJECT CODE: B.E. 4th SEMESTER
Decimal Arithmetic (alternative to binary arithmetic)
Making Decisions and Writing Loops
ECE 3430 – Intro to Microcomputer Systems
Decision Making.
Processor Instructions set. Learning Objectives
Addressing Modes Immediate #<data> or Imm
Assembly Language Programming Part 2
Lecture 16 Arithmetic Circuits
68000 Arithmetic Instructions
Lecture 3 - Instruction Set - Al
Branching and Loops.
CS 235 Computer Organization & Assembly Language
CSC 3210 Computer Organization and Programming
ECE232: Hardware Organization and Design
Instruction encoding The ISA defines Format = Encoding
ECE 3430 – Intro to Microcomputer Systems
Homework Reading Machine Projects Labs PAL, pp
ECEG-3202 Computer Architecture and Organization
The University of Adelaide, School of Computer Science
Logical Operations bitwise logical operations AND, OR, EOR, NOT
M68k Arithmetic Instructions
ECEG-3202 Computer Architecture and Organization
COMS 361 Computer Organization
MIPS assembly.
Branch & Call Chapter 4 Sepehr Naimi
Shift and Rotate Instructions.
Conditional Control Structure
ECE511: Digital System & Microprocessor
An Introduction to the ARM CORTEX M0+ Instructions
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

Write a program to calculate x**y, given x and y. (revisited) inputs: x (w – because of the multiply instruction) y (b – it is a counter) output: ans (l – because of the multiply instruction) org $400 main move.w x,D0 get base move.w x,D2 and make copy move.b y,D1 get exponent beq skip if zero, skip calc loop mulu D0,D2 do product sub.b #1,D1 decrement counter bne loop skip move.l D2,ans save x**y stop #$2700 We have some problems: x dc.w 5 y dc.b 3 ans ds.l 1 end main

Valid flags for signed arithmetic e.g. A – B if N=0 A – B 0 if N=1 A – B 0 if N=V A B if N≠V A B if N=V and Z=0 A B if N≠V or Z=1 A B V = 1 → result incorrect → signed overflow 0 → result correct Z = 1 → result is zero 0 → result is not zero N = 1 → result is negative 0 → result is positive (includes zero)

Decision Structures … if-then in assembly language in pseudo-code: … if condition then … code A end if … code B “if condition then” decomposes into a series of operations 1) test condition → sets flags 2) branch on the flags

Decision Structures … testing conditions to “test” condition: arithmetic logical shifts, rotates data movement compare, test CMP <ea>,Dn [destination] - [source] e.g. move.b #5,D0 cmp.b #6,D0 TST <ea> compare [destination] to 0 ≡ [destination] – 0 e.g. move.b #-1,D0 tst.b D0

Conditional Branch …Bcc M68000 Assembly Language [p16, N. Znotinas] conditional branches, an alternate view: BHI | BLS Br high |Br low or same BCC | BCS Br C clear |Br C set BHS*| BLO* Br high/same |Br low BNE | BEQ Br not equal |Br equal BVC | BVS Br V clear |Br V set BPL | BMI Br plus |Br minus BGE | BLT Br ≥ |Br < BGT | BLE Br > |Br ≤ * depends on assembler if synonym accepted

Decision Structures … if-then-else in assembly language in pseudo-code: … if condition then … code A else … code B end if … code C Assembly code logic should flow from top to bottom like a waterfall.

Testing for out-of-range data/results perform arithmetic input operation data ↓ result/data in range? → error continue processing input data and calculated data may be out-of-range, i.e. too large to store correctly you are responsible for testing for out-of-range conditions you would not test …

Testing for out-of-range results e.g. ** technique 1 … ADD.W D0,D1 B Ans_OK … code to put … out err msg JMP END_M Ans_OK … next code … section END_M e.g. ** technique 2 … ADD.W D0,D1 B V_err … next code … section JMP END_M V_err … code to put … out err msg … END_M

Loops … conditional loops in assembly language in pseudo-code: … while condition do … code A end while … code B

e.g. If a 16 bit number is negative, generate the absolute value of the number. Store the result in the number’s original memory location.

e.g. Find the larger of two 32 bit numbers.

M68000 Assembly Language [pdf, 92p; N. Znotinas] Reading: M68000 Assembly Language [pdf, 92p; N. Znotinas] Look at the Bcc command and relate the use of the condition codes in the table to the relationships we developed in the last two lectures. The relationships are the same but written in different formats. Look at the unconditional branch commands: BRA, JMP review the operation of the various binary add (ADD, ADDA, ADDI, ADDQ) and subtract (SUB, SUBA, SUBI, SUBQ) instructions review the operation of the test (TST) instruction and the various forms of the compare (CMP, CMPA, CMPI) instruction review the operation of the MULS|MULU (multiply) and DIVS|DIVU (divide) instructions Expectations: starting with assignment 4, we will expect arithmetic results to be checked for out-of-range results when appropriate you can write any decision structure (if, if-then-else, if-elseif, case) in assembly language you can write a simple looping structure in assembly language you can select the correct conditional branch for any given signed or unsigned test