Assembly Language g Example

Similar documents
HC12 Assembly Language Programming

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

The stack and the stack pointer

Programming the Motorola MC68HC11 Microcontroller

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

M6800. Assembly Language Programming

Programmer s Model = model of µc useful to view hardware during execution of software instructions

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

ChE-1800 H-2: Flowchart Diagrams (last updated January 13, 2013)

Introduction to Microcontrollers

Microprocessor/Microcontroller. Introduction

6800 Basics. By Ruben Gonzalez

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

Real-time system programs

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Interrupts and the Timer Overflow Interrupts Huang Sections What Happens When You Reset the HCS12?

Instruction Set Architecture

Lecture 2. Binary and Hexadecimal Numbers

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Application Note AN_106. Interfacing to a USB Printer using Vinculum VNC1L Host Controller

Rossmoor Website SEO Tracking Sheet Updated: April 1, 2014

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

2 SYSTEM DESCRIPTION TECHNIQUES

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Flowchart Techniques

Advanced Encryption Standard (AES) User's Guide

THUMB Instruction Set

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

Computer Architecture. Secure communication and encryption.

1 Classical Universal Computer 3

South East of Process Main Building / 1F. North East of Process Main Building / 1F. At 14:05 April 16, Sample not collected

MACHINE ARCHITECTURE & LANGUAGE

Kids College Computer Game Programming Exploring Small Basic and Procedural Programming

Positional Numbering System

Sources: On the Web: Slides will be available on:

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Computer Programming Lecturer: Dr. Laith Abdullah Mohammed

PROBLEMS (Cap. 4 - Istruzioni macchina)

Fundamentals of Programming and Software Development Lesson Objectives

Lesson 8: Simon - Arrays

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

Apple Pro Training Series: Logic Pro X: Professional Music Production

How To Understand All Instructions In The Power12 Program

How To Write An Array In A Microsoft Zil

USB Human Interface Joystick Demonstration Create a HID USB Device (sample Joystick) By Jared St.Clare, October 2009 Version 1

Lecture 22: C Programming 4 Embedded Systems

Basic Use of the TI-84 Plus

68HC11 Programmer s Reference Manual

Summary of the MARIE Assembly Language

Binary Numbers. Binary Octal Hexadecimal

Lumousoft Visual Programming Language and its IDE

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Introduction to MIPS Assembly Programming

Lab 7. Answer. Figure 1

CS201: Architecture and Assembly Language

Extracting, Storing And Viewing The Data From Dicom Files

Freescale Semiconductor, I

PTC Mathcad Prime 3.0 Keyboard Shortcuts

Creating Online Surveys with Qualtrics Survey Tool

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Reduced Instruction Set Computer (RISC)

Optimize with Shark: Big Payoff, Small Effort

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Two-level logic using NAND gates

Programming Languages

PRODUCTS & QUOTES USING THE KEY & IRESS EXCHANGE

Translating C code to MIPS

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Sample EHG CL and EHG SL10 16-bit Modbus RTU Packet

I. Create Windows 2012 R2 VMware Template for Guest Customization

Apple II Technical Notes

Products and Quotes using Exchange

Niche Market Finder. User Guide

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Working with Visio Connectors

DC Circuits (Combination of resistances)

Notes on Algorithms, Pseudocode, and Flowcharts

First Bytes Programming Lab 2

MICROPROCESSOR AND MICROCOMPUTER BASICS

VISUALIZING DATA POWER VIEW. with MICROSOFT. Brian Larson. Mark Davis Dan English Paui Purington. Mc Grauu. Sydney Toronto

Z80 Instruction Set. Z80 Assembly Language

Tessellations. Practice 1 Identifying Tessellations. In each tessellation, color the repeated shape. Example

AN2183. Using FLASH as EEPROM on the MC68HC908GP32. Introduction. Semiconductor Products Sector Application Note

Fast Arithmetic Coding (FastAC) Implementations

Digital Versus Analog Lesson 2 of 2

8051 MICROCONTROLLER COURSE

Once you have gone through this document you will have a form that, when completed, will create an Account & Contact in Oracle.

COMPUTER SCIENCE. Paper 1 (THEORY)

Machine Learning and Data Mining. Regression Problem. (adapted from) Prof. Alexander Ihler

Planning a Class Session

Making Basic Measurements. Publication Number August Training Kit for the Agilent Technologies Series Logic Analysis System

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Section 1.4 Place Value Systems of Numeration in Other Bases

Chapter 6: Programming Languages

KS3 Computing Group 1 Programme of Study hours per week

Scrolling Marquee Display

Wilson Area School District Planned Course Guide

Logic gates. Chapter. 9.1 Logic gates. MIL symbols. Learning Summary. In this chapter you will learn about: Logic gates

Transcription:

Lecture 9: Assembly Language g Example

Today s Topics Flowcharts Practice assembly programming

Flowcharts There are other more sophisticate t methods of representing programs. Flowcharts work well for software written in assembly code level. W ill l i l b ildi bl k i fl h f l We will see logical building blocks in flowchart formats along with assembly code templates.

Flowcharts Meaning of symbols Start or End flow Decision There are many more symbols other than these. Shapes may be different. In this course, those four symbols are pretty much all we need. Process

Flowcharts If-Then-Else Set CCR bits for decision i Bxx Process A Process B code Color of Pill is RED? Matrix RealWorld If(PillColor == RED) RealWorld Else Matrix Example: ldaa PillColor cmpa #RED bne lmatrix RealWorld bra lskip lmatrix: Matrix lskip:...

Flowcharts While-Do Set CCR bits for decision i Bxx past BRA Process code Set CCR bits for decision BRA to Bxx KnowThis? StudyMore Example: ldaa KnowThis lloop: cmpa #YES beq lnext StudyMore ldaa KnowThis bra lloop lnext: NextStep

Flowcharts Repeat-Until DoSomething Is the Job done? Process code Set CCR bits Bxx to Process code Example: loop: DoSomething ldaa Result beq ldone bra loop ldone:

Flowcharts Case ntemp < 20 ntemp < 70 ntemp < 100 Alarm TurnOnHeater FlashIndicator TurnOnCooler Set CCR bits Bxx to Process 1 Set CCR bits Bxx to Process 2 Set CCR bits Bxx to Process N Default Process code BRA past Process N code Process 1 code BRA past process N code Process 2 code BRA past Process N code Process N code Example: ldaa ntemp cmpa #20 bhs l1 TurnOnHeater bra lres l1: cmpa #70 bhi l2 FlashIndicator bra lres l2: cmpa #100 bhi l3 TurnOnCooler bra lres l3: Alarm lres:

Flowchart Guidelines Do not refer to registers in the flowchart Arrows should never cross They will not need to if the flowchart represents a structured program Th i t ti b t h t The purpose is to remove any questions about how to program and understand the algorithm, and this usually determines when the flowchart contains enough detail.

Assembly Example Convert an array of 4-byte Big-Endian values to an array of Little-Endian values. Let $1000 hold the address of the array of Big-Endian values, $1002 hold the address of the array for the Little-Endian values, $1004 hold the two-byte length of numbers to convert. Write an assembly yprogram to implement these requirements.

Start 1: Point to the first BE item 2: Point to the first LE item 3: Make a copy of the length 4. There are no more elements 5: Copy 1st BE byte to 4th LE byte 6: Copy 2 nd BE byte to 3 rd LE byte 7: Copy 3 rd BE byte to 2 nd LE byte 8: Copy 4 th BE byte to 1 st LE byte 9: Point to next elements & dec length End

Start 1: Point to the first BE item 2: Point to the first LE item 3: Make a copy of the length 4. There are no more elements 5: Copy 1st BE byte to 4th LE byte org $1000 Bend ds.w 1 LEnd ds.w 1 Length ds.w 1 TmpLen ds.w 1 org $2000 ldx BEnd ldy Lend ldd Length Loop std TmpLen ; 3 beq Done ldaa 0,x ; 3 staa 3,y ; 2 ldaa 1,x ; 3 staa 2,y ; 2 ldaa 2,x ; 3 staa 1,y ; 2 ldaa 3,x ; 3 staa 0,y ; 2 6: Copy 2 nd BE byte to 3 rd LE byte inx ; 1 inx 7: Copy 3 rd BE byte to 2 nd LE byte inx inx 8: Copy 4 th BE byte to 1 st LE byte iny ; 1 iny 9: Point to next elements & dec length iny iny End Done ldd TmpLen ; 3 subd #$0001 bra Loop swi

Start 1: Point to the first BE item org $1000 Bend ds.w 1 LEnd ds.w 1 Length ds.w 1 2: Point to the first LE item 3: Make a copy of the length 4. There are no more elements 5: Copy 1st BE byte to 4th LE byte 6: Copy 2 nd BE byte to 3 rd LE byte 7: Copy 3 rd BE byte to 2 nd LE byte 8: Copy 4 th BE byte to 1 st LE byte org $2000 ldx BEnd ldy Lend ldd Length Loop beq Done movb 0,x,3,y ; 5 movb 1,x,2,y movb 2,x,1,y movb 3,x,0,y leax 4,x ; 2 leay 4,y subd #1 ; 2 bra Loop Done swi 9: Point to next elements & dec length End Note: You can save 10 (= 3 + 2x2 + 3) cycles.

Questions?

Wrap-up What we ve learned Flowcharts Templates will be greatly helpful. Assembly program example

What to Come Arithmetic ti instructions ti Logic instructions