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

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

MACHINE ARCHITECTURE & LANGUAGE

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

MICROPROCESSOR AND MICROCOMPUTER BASICS

HC12 Assembly Language Programming

Microprocessor/Microcontroller. Introduction

M6800. Assembly Language Programming

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

Introduction to Microcontrollers

Z80 Instruction Set. Z80 Assembly Language

Microprocessor & Assembly Language

BASIC COMPUTER ORGANIZATION AND DESIGN

Computer organization

CPU Organization and Assembly Language

1 Classical Universal Computer 3

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Central Processing Unit (CPU)

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Summary of the MARIE Assembly Language

The stack and the stack pointer

8085 INSTRUCTION SET

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

PART B QUESTIONS AND ANSWERS UNIT I

(Refer Slide Time: 00:01:16 min)

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

EE282 Computer Architecture and Organization Midterm Exam February 13, (Total Time = 120 minutes, Total Points = 100)

Chapter 9 Computer Design Basics!

Notes on Assembly Language

CHAPTER 7: The CPU and Memory

CPU Organisation and Operation

Computer Organization and Architecture

Faculty of Engineering Student Number:

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

Chapter 5 Instructor's Manual

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Binary Numbers. Binary Octal Hexadecimal

Systems I: Computer Organization and Architecture

Computer Science 281 Binary and Hexadecimal Review

2011, The McGraw-Hill Companies, Inc. Chapter 3

Instruction Set Design

The WIMP51: A Simple Processor and Visualization Tool to Introduce Undergraduates to Computer Organization

6800 Basics. By Ruben Gonzalez

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

PROBLEMS (Cap. 4 - Istruzioni macchina)

Instruction Set Architecture (ISA)

Administrative Issues

Programming the Motorola MC68HC11 Microcontroller

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

MACHINE INSTRUCTIONS AND PROGRAMS

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

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

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

An Overview of Stack Architecture and the PSC 1000 Microprocessor

CHAPTER 4 MARIE: An Introduction to a Simple Computer

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

LSN 2 Computer Processors

LABORATORY MANUAL EE0310 MICROPROCESSOR & MICROCONTROLLER LAB

EC 362 Problem Set #2

CSE 141L Computer Architecture Lab Fall Lecture 2

Microprocessor and Microcontroller Architecture

IBCM: The Itty Bitty Computing Machine

Graded ARM assembly language Examples

LC-3 Assembly Language

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

TIMING DIAGRAM O 8085

An Introduction to the ARM 7 Architecture

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Traditional IBM Mainframe Operating Principles

Keil C51 Cross Compiler

ARM Cortex-M3 Assembly Language

The string of digits in the binary number system represents the quantity

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

Building A RISC Microcontroller in an FPGA

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

How To Write A Microsoft Microsoft 8D (Droid) (Program) (Powerbook) (I386) (Microsoft) (Donga) (Opera) And (Dungeo) (Dugeo

Introduction. What is an Operating System?

The Little Man Computer

5 Combinatorial Components. 5.0 Full adder. Full subtractor

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Chapter 2 Assemblers

Chapter 7 Assembly Language

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

Central Processing Unit

EECS 427 RISC PROCESSOR

High level code and machine code

Let s put together a Manual Processor

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

Call Subroutine (PC<15:0>) TOS, (W15)+2 W15 (PC<23:16>) TOS, Process data. Write to PC NOP NOP NOP NOP

Intel 8086 architecture

Z80 Microprocessors Z80 CPU. User Manual UM Copyright 2014 Zilog, Inc. All rights reserved.

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Transcription:

HC12/S12 Programmer s Model Programmer s Model = model of µc useful to view hardware during execution of software instructions Recall: General Microcontroller/Computer Architecture note: Control Unit & Register File CPU Control Unit ALU Register File Data Path program data m n m n m-bit bus uses n-bit data bus control bus I/O Devices AMS Instruction Execution p.1 HC12/S12 Programmer s Model Programmer s Model = model of µc useful to view hardware during execution of software instructions focus on Register File & Control Unit of a specific controller will be different for each different brand/model of controller Register File A D 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 2@8-bit Accumulator: A, or 1@16-bit Accumulator: D 16-bit Index Register: X 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16-bit Index Register: Y Control Unit IR 7... 0 7... 0 7... 0 7... 0 Multi-byte Instruction Register 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 S X H I N Z V C current instruction 16-bit Program Counter of next instruction 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16-bit Stack Pointer of stack 7 0 8-bit Condition Code Register AMS Instruction Execution p.2

HC12/S12 Programmer s Model Register File store data in/out of memory or ALU Accumulators: 2 @ 8-bit OR 1 @ 16-bit general purpose storage Index Registers: 2 @ 16-bit general purpose or in indexed ing Control Unit Instruction Register (IR) holds current instruction, multi-byte Program Counter () holds of next instruction, 16-bit Stack Pointer () holds of stack (special block of memory), 16-bit Condition Code Register () holds flag s generated by last instruction executed, 8-bit known as Status Register in other controllers Central Processing Unit A L U Control Unit Register File 2@8-bit Accumulator: A, A D IR 7 0 7 0 15 8 15 8 or 1@16-bit Accumulator: D 16-bit Index Register: X 16-bit Index Register: Y Multi-byte Instruction Register: current instruction 16-bit Program Counter: addr. next instruction 16-bit Stack Pointer: of stack 8-bit Condition Code Register 7 0 7 0 7 0 15 8 7 0 7 0 7 0 7 0 15 8 7 0 15 8 7 0 S X H I N Z V C AMS Instruction Execution p.3 Condition Code Register = register 8 of individually functioning bits AKA: Flags Register, Status Register Stop Disable External Interrupt Mask Half Carry Interrupt Mask 7 S X H I N Z V C 0 Carry/orrow Overflow Zero Negative LACK = set by ALU GRAY = other; covered later ALU Status Flags: each condition tested after each instr. exec. C: Carry Flag = 1 if carry (addition) or borrow (subtraction) occurs in instr. exec. V: Overflow Flag C _ Overflow An 1 n 1 Sn 1 An 1 n 1 S = 1 if 2 s complement overflow occurs in instr. exec. Z: Zero Flag: =1 if ALU result = 0 N: Negative Flag: =1 if MSU of ALU result is 1 (i.e., negative in S2C) H: Half-Carry Flag: =1 if carry from lower nibble (nibble = ½ byte =4 bits) 2 n 1 AMS Instruction Execution p.4 1

Examples Instructions & resulting flag status 8-bit addition (hexadecimal) 7 + 4A assign each problem to group of students to evaluate as TPS exercise write answers (C=, V=, etc) on board before next slide 07 + F9 6 + 9A AMS Instruction Execution p.5 Examples Instructions & resulting flag status 8-bit addition 7 + 4A 07 + F9 6 + 9A V (2C overflow) is ALWAYS checked, even if is not in S2C AMS Instruction Execution p.6

Examples & Carry Flag Rules Instructions & resulting flag status 8-bit subtraction (hexadecimal) 00 17 Carry Flag (C) Rules * if A + (addition), then C = carry_out (Cout) * if A (subtraction), then C = Cout (not_cout, inverse) if A >, no borrow is needed C = 0 if A <, borrow needed C = 1 9 AMS Instruction Execution p.7 Example: Carry Flag & Subtraction Evaluate: -4 (-3) operation is A (subt.) C = Cout A < borrow will be needed C should be 1 Note: in S2C form, the more negative a number is, the smaller it is EX: -4 = 1100 is smaller than -3 (= 1101) Thus, you can compare A < or > in normal/decimal or S2C notation 6 AMS Instruction Execution p.8

HC12/S12 Assembly Instructions Assembly (ASM) language: programming in the smallest unit of machine (µc, µp) action Example ASM program code ASM Instruction Format LAEL INSTR_MNEMONIC OPERAND(S) COMMENT example: AMS Instruction Execution p.9 HC12/S12 Assembly Instructions ASM Instruction Format LAEL INSTR_MNEMONIC OPERAND(S) COMMENT example: LAEL: identifies location of a line of code used by Assembler (compiler); not part of actual instructions generally used for looping (jump, branch) CHECK is branch location of later instruction (RA CHECK) MNEMONIC: text code for each ASM instruction translated by Assembler to a specific instr. op-code op-code = hex machine code for each ASM instruction CMPA is instruction to compare in acca to operand OPERAND: data/ used by ASM instruction function of ing mode (discussed later) some instr. don t have operands #$0A is the acca will be compared to AMS Instruction Execution p.10

HC12/S12 Assembler Notation $= HEX EX: $12 = 18 10 %= IN EX: %10 = 2 10 none = DEC EX: 12 = 12 10 #denotes a data (rather than an ) EX: ADDA #$A5, adds $A5 to acca ADDA $A5, adds at $A5 to acca illustration to clarify will come soon! first need to make things even more complicated AMS Instruction Execution p.11 ASM Instructions & Program Assembly Example ASM program code Program Assembly instr._mnemonics converted to HEX op-codes So HEX s can represent instruction op-code bytes instruction data or operand bytes data/instruction bytes and you need to be able to tell which witch is which! AMS Instruction Execution p.12

Clear As Mud! Relationship between Software (instruction) and Hardware Program Elements: SOFTWARE: HARDWARE: location of instr., action to perform, data to act on, CPU control bits, data bits (or of data) Relationship between Program and Data memory all instructions are converted to hex and stored in memory Program = block of memory es allocated to program bytes most instruction act on data and produce results stored in memory Data = block of memory es allocated to data bytes Relationship between Address and Data s evaluate: #1 + #2 = #3 #1 + 2 = #6 block 1 4 block 2 5 block 3 6 no # implies an ; in block 2 is #5, so #1+#5=#6 Address Data within AMS Instruction Execution p.13 68HC12 Expanded Programmer s Model CPU (ALU, Register File, Control Unit) and note separate memory allocated for Program and Data AMS Instruction Execution p.14

Microcontroller Program Development from concept to action A. Write program to complete task check syntax; test functionality (Simulator). Assemble program (Assembler) ASM code Machine code (op-codes and operands) C. Upload program to program memory D. Run program on Microcontroller set to start of program memory 1. fetch instruction to IR from program memory 2. decode instruction: set ALU to perform instruction 3. execute instruction: load/store to data memory & register file advance to next instruction in program memory repeat step 1 until commanded to stop AMS Instruction Execution p.15 Instruction Execution Cycle 3 steps of instruction execution cycle Fetch: Load instruction byte from program memory into IR Decode: Translate op-code to control signals for ALU and Control Unit Execute: Pass data through ALU to generate desired result Example 1. fetch bytes for LDAA #$00 2. decode: set ALU to load #$00 into acca 3. execute: acca contains $00 4. fetch bytes for CMPA #$0A 5. decode: set ALU to compare acca with the $0A 6. execute: set C/V/N/Z flags (e.g., if acca were $0A, Z 1) 7. etc AMS Instruction Execution p.16

Instruction Cycle Example Code Executed: LDAA $3000 (load from $3000) STAA $2000 (store to $2000) Explaining the instruction execution chart AMS Instruction Execution p.17 Instruction Cycle Example Code Executed: LDAA $3000 (load from $3000) STAA $2000 (store to $2000) AMS Instruction Execution p.18

HC12 Instruction Set Instruction Set: the full set of functional instructions a µc/µp can execute varies with each family of controllers, but generally very similar asic types of instructions (see HO_3) Data Transfer/Manipulation move data to/from memory; shift/rotate; etc. Arithmetic add; subtract; increment; decrement; etc. Logic & it Operations oolean logic; condition flag clears; etc. Data Test compare/test data & set flags (test for conditional branches) ranch jump out of program sequence; if-then-else operations Function Call (Subroutine) start/end subroutines; adjust covered later in class AMS Instruction Execution p.19 Reading HO_3 Information in HO_3 instruction tables mnemonic description of function operation in terms of programmer s model elements flag affects Data Transfer/Manipulation Table A. Load instructions put data into CPU memory (e.g. Register File) Mnemonic Function Operation C V Z N LDAA Load accumulator A A M -- 0 LDA Load accumulator M -- 0 LDD Load accumulator D A M, M+1 -- 0 LDX Load index register X X M:M+1 -- 0 LDY Load index register Y Y M:M+1 -- 0 LDS Load stack pointer () M:M+1 -- 0 (M) defined by instruction operand all these instructions CLEAR V (make 0) and CHANGE Z and N based on ALU result AMS Instruction Execution p.20

2-byte Operations Accumulators acca is MSy of accd; acc is LSy of accd operations instructions refer to only one 8-bit memory where does 2 nd byte come from for 16-bit instructions (e.g., LDX) defined/reference memory (M) MSy; M+1 LSy 16-bit Register (e.g., ix) MSy [8:15] LSy [0:7] 8-bit memory M-1 M M+1 M+2 M+3 e.g., M = $679D $679C $679D $679E $679F $67A0 AMS Instruction Execution p.21 Quick Review: HC12 Instructions Data Transfer/Manipulation Table. Store instructions put data (from CPU) into memory Mnemonic Function Operation C V Z N STAA Store accumulator A A M -- 0 STA Store accumulator M -- 0 STD Store accumulator D A M, M+1 -- 0 STX Store index register X X M:M+1 -- 0 STY Store index register Y Y M:M+1 -- 0 STS Store stack pointer () M:M+1 -- 0 You don t have to memorize these. Instruction tables will always be available to you. Even on exams! Table C. Move/transfer instructions copy data to a memory/register Mnemonic Function Operation C V Z N TA Transfer acc. A to acc. A -- 0 TA Transfer acc. to acc. A A -- 0 TAP Transfer acc. A to A TPA Transfer to acc.a A -- -- -- -- MOV Mem to Mem: move byte (M) 1 (M) 2 -- -- -- -- MOVW Mem to Mem: move Word (M:M+1) 1 (M:M+1) 2 -- -- -- -- which is which? Shift/rotate instructions Logic shift: input = 0, output to carry_out Arithmetic shift: shift right puts copy of MS into MS Rotate: input rolls from output (carry_out included) AMS Instruction Execution p.22

Quick Review: HC12 Instructions Arithmetic Addition: adds Register with (or Register), stores in Register note: A A+, but no A+ Subtraction: subtr. Register with (or Register), stores in Register Decrement: subtr. 1 from in (M, A,,, X or Y) Increment: add 1 to in (M, A,,, X or Y) Logic AND, OR, XOR, Complement (invert) 2 s complement = $00 A (or ); additive inverse, same as A +1 it Operations Clear flags: C, I, V it Test; AND s A (or ) with : application unknown to me it Set/Clear clears (make 0) or sets (make 1) individual bits of a byte can affect 1 or multiple bits very useful for defining individual bits of an I/O port requires a mask byte AMS Instruction Execution p.23 Masking Concept it set/clear instructions (SET, CLR) [as well as some others we ll learn later] use mask bytes. Mask byte defines which bits of a byte will be affected by instr. other bits will not be changed Instruction format mnemonic mem_addr mask SET/CLR addr of data bits to set/clr if mask bit = 1 change if mask bit = 0 don t change Examples: ASM instruction *only operates on ; not on CPU registers or operands because masking is bit-wise operation, mask bytes often specified in binary AMS Instruction Execution p.24

SET/CLR Examples Determine memory after each instruction set/clear all bits that are 1 in the mask operand SET $9D %10101010 in $9D is $AD = %1010 1101 bset $AF SET $673 %11100111 in $673 is $00 bset $E7 data: 1010 1101 mask: 1010 1010 bset-> 1010 1111 red=set, blue=pass data: 0000 0000 mask: 1110 0111 bset-> 1110 0111 INITIAL addr. $009C $009D $009E $672 $673 $9C $AD $E2 $FF $00 CLR $009E %10000001 in $009E is $E2 bclr $62 CLR $009C $9C in $9C is $9C mask also $9C = %1001 1100 bclr $00 data: 1110 0010 mask: 1000 0001 bclr-> 0110 0010 red=clr, blue=pass data: 1001 1100 mask: 1001 1100 bclr-> 0000 0000 FINAL addr. $009C $009D $009E $672 $673 $00 $AF $62 $FF $E7 AMS Instruction Execution p.25 Quick Review: HC12 Instructions Data Test Instructions Compare Data Compare: C=, V=, Z=, N= compare 2 s by subtracting them flags will show <, >, or = N will show which was greater EX: CA Compare A=$5D to =$37 A $5D - $37 N = 0 A > (subtraction not negative) Z will show if they were equal Test Data Test: C= 0, V=0, Z=, N= subtracts $00 flags show if in tested memory/register is negative (N) or zero (Z) AMS Instruction Execution p.26

Address Modes 68HC12 has six (6) ing modes ing modes define how data is associated with an instruction Inherent: instruction requires no data form outside the CPU EX: AA {A A+} or INX {increment ix by 1} inherent instructions have no operands all needed data within CPU registers Immediate: data is in operand (not in memory) easily identified by having a # in the operand EX: LDAA #$F3 {put $F3 into acca} or ANDA #$2C Extended: data for instruction is in memory 2-byte operand specifies memory EX: LDA $204 {put in $204 into acc; <$204>} Direct: data for instruction is in memory with 1-byte special case of Extended used for es $0000 $00FF (256 bytes), where MSy is $00 saves program bytes and execution time; eliminates 1 operand es $00 $FF largely used by configuration registers (control I/O functions) EX: ADDA $E3 {A A+<$00E3>} remaining 2 modes are more complicated and will be covered later <..> notation means the at this mem. addr. AMS Instruction Execution p.27 Address Modes Identify the mode for each of the following instructions Inherent, Immediate, Direct, Extended LDA #$4F STAA $8D2C AA LDX #$8D2C STY $8D2C INC ANDA $C6 TA LSL $F0 SUD $8D2C ADDD #$0750 Immediate Extended Inherent Immediate Extended Inherent Direct Inherent Direct Extended Immediate AMS Instruction Execution p.28

Quiz 1 Topics Following topics should be studied for Quiz 1 230 review base conversion S2C form and conversions oolean logic; DeMorgan s rules flip-flop/register operation Microcontroller architecture; structure & name/function of blocks 68HC12 programmers model bits; setting after hexadecimal math 68HC12 instruction format & execution cycle masking concept: SET/CLR instructions 68HC12 modes: the simple ones (INH, IMM, DIR, EXT) AMS Instruction Execution p.29 Instruction Register Chart Initial Values $2100 A AA $ED $2100 Inherent Add to A A2 +4 =ED Initial Values $2100 A INC $4C $0060 $20 $2100 Inherent Increment ( +1) AMS Instruction Execution p.30

Instruction Register Chart Initial Values $2100 A ANDA #$4C $00 $2100 Immediate AND w/ M (A2)(4C) A2 = 1010 0010 4C = 0100 1101 0000 0000 Initial Values A LDX #$8000 Immediate Inherent AX Add to ix C $2100 $0061 $00C7 $2000 $2001 $2002 $00 $FF $31 $5E $20 $8000 $804 AMS Instruction Execution p.31 Instruction Register Chart Initial Values $2100 A LDX $60 $2000 Direct Load ix from M (60) LDAA $C7 Direct C STAA $2001 D Extended $FF $0060 $FF $2000 $4 $20 $2000 $2001 $FF $5E AMS Instruction Execution p.32

Instruction Register Chart: Flags AA INC $ED $2100 $4C $0060 $20 $2100 0 1 0 0 0-0 0 x- ANDA #$4C A LDX #$8000 $00 $2100-0 1 0 - - 1 0 0 - $8000 AMS Instruction Execution p.33 Instruction Register Chart: Flags AX Add to ix C LDX $60 $8048 $2000 0 1 0 0 0-0 0 0 - LDAA $C7 C STAA $2001 D $FF $0060 $FF $2000 $4 $20-1 0 0 - - 1 0 0 - $2000 $2001 $FF $5E AMS Instruction Execution p.34

Indexed Address Mode Indexed: instruction data is in memory at specified relative to (offset from) a reference that is stored in a CPU register reference can be in ix, iy,, or offsets are signed number can offset forward or backward useful for accessing a list of data beginning (or ending) at the reference Several varieties of indexed ing in HC12 ASM we will only study Indexed-Immediate others covered in textbook and HO_3 6017 reference CPU register offset ex: addr. 6015 6016 index 6017 6018 6019 601A $XX 601 601C 601D 601E block of memory AMS Instruction Execution p.35 Indexed-Immediate Addressing Indexed-Immediate reference in ix, iy,, or offset in operand just like Immediate mode has data in operand Format: MNEMONIC offset,reference Example: LDX #$6017 LDAA $05,X {acca <$5+<iX>>} acca loaded with in memory at addr ($65 + in ix) note: at index, < <ix> >, is irrelevant unless instr. was LDAA $00,X acca $AA $27 target of instruction ix 6017 reference offset 1 2 3 4 5 ex: addr. 6015 6016 index 6017 $27 6018 6019 601A 601 601C 601D 601E block of memory AMS Instruction Execution p.36

Indexed Immediate Addressing Example LDY #$5000 ADDA $4C,Y A A + M, M = <$4C + <iy> > M = $504C A $21 + $1A A $3 acca acc $21 $80 ix $2000 iy $5000 reference INITIAL Example (same memory as above) 1) LDY #$5000 1 2) ADDA 0,Y acca $21 3) INY acc $80 4) ADDA $0,Y can add a series of numbers like this ix $2000 iy $5000 reload Y to move to another set 3 28 52 00... 50 4 1A 04 5E addr. 5000 5001 5002 5003... 504A 504 504C 504D 504E memory block acca acc ix iy 2 $D4 $80 $2000 $5000 acca acc $3 $80 ix $2000 iy $5000 reference acca acc ix iy 3 $D4 $80 $2000 $5001 FINAL 3 28 52 00... 50 4 1A 04 5E addr. 5000 5001 5002 5003... 504A 504 504C 504D 504E memory block acca acc ix iy 4 $FC $80 $2000 $5001 AMS Instruction Execution p.37 Instruction Register Chart Initial Values $01 $00F0 $2C $2100...... $3011 $31 $3012 $00...... $301A $20 $3109 $E A LDX $3011 $01 $00F0 $2C $3011 $3100..... $3011 $31 $3012 $00...... $301A $20 $3109 $E Add to A A2 +4 =ED ORA #$F0 $F1 $00F0 $3100 $2C..... $3011 $31 $3012 $00...... $301A $20 $3109 $E C which is right? STA $09,X D OR & $F1 <F0> $00F0 $2C A2 OR 2C $3100..... OR & <F0> $3011 $31 01 OR 2C $3012 $00...... OR & F0 $301A $20 01 OR F0 $F1 $E $3109 which is right? + 09 ix + 09 ix $3011+$09 $3100+$09 $3100+<$09> AMS Instruction Execution p.38

HC12 Compiler Directives Directive: command to compiler; makes coding easier HC12 ASM Directives (see HO_3) EQU equates symbol with numeric valve -use to define memory location or constant -assembler replaces label with correct # EX: LIST EQU $5 defines variable LIST = $5 ORG origin: set memory addr. of instructions/data that follow -all programs must specify their ORG EX: TOP ORG $6000 sets program origin at $6000 END set end of program -any ASM instructions following END are d -can have directives after END AMS Instruction Execution p.39 HC12 Compiler Directives Directive: command to compiler HC12 ASM Directives (see HO_3) FC form constant byte -reserves block of memory & initiates contents of reserved block EX: AC FC $11, $12, $13 reserves 3 bytes w/ valves $11, $12 & $13 at addr. assigned to label AC FD form double-byte -same as FC but 2 bytes per operand FCC form constant character -stores ASCII code for alphanumeric characters enclosed in " " symbols EX: NAME FCC MIKE stores 4 ASCII bytes for MIKE RM reserve block of memory EX: TEMP RM $10 reserves 16 ($10) bytes starting at addr. assigned to label TEMP AMS Instruction Execution p.40

Assembly Process Assembly Process: The process of converting ASM code into executable machine code. Input.ASM (text file) Outputs.LST compiled code program es & op-codes.s19 record HEX file that can be uploaded to C to store program to memory Testing paths Simulator Test on hardware AMS Instruction Execution p.41 Assembly Process Example AMS Instruction Execution p.42