RCX internals (Revised February 24)

Similar documents
H8/300L Series Programming Manual

H8/300H Series Software Manual

Hitachi Microcomputer H8/300H Series Application Notes for CPU

H8/500 Series Programming Manual

OMC HITACHI SINGLE-CHIP MICROCOMPUTER H8/300L Series HITACHI

Programming the Motorola MC68HC11 Microcontroller

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

LEGO RCX Hitachi H8/3292

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

EE 3170 Microcontroller Applications

instruction 1 Fri Oct 13 13:05:

Lecture 6 Assembly Programming: Branch & Iteration

Condition Code Register. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

The Motorola 68HC11 Instruc5on Set

Introduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949

EECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups

Chapter 7 Central Processor Unit (S08CPUV2)

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1

INTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000.

Accumulator and memory instructions 1. Loads, stores, and transfers 2. Arithmetic operations 3. Multiply and divide 4. Logical operations 5. Data test

The Assembly Language of the Boz 5

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

EE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name:

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls

ARM Assembly Language. Programming

EE 3170 Microcontroller Applications

EE319K Spring 2016 Exam 1 Solution Page 1. Exam 1. Date: Feb 25, UT EID: Solution Professor (circle): Janapa Reddi, Tiwari, Valvano, Yerraballi

EE319K Exam 1 Summer 2014 Page 1. Exam 1. Date: July 9, Printed Name:

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

CPU08RM/AD REV 3 8M68HC08M. CPU08 Central Processor Unit. Reference Manual

Motorola 6809 and Hitachi 6309 Programmer s Reference

NET3001. Advanced Assembly

Exam 1. Date: Oct 4, 2018

Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015.

(2) Part a) Registers (e.g., R0, R1, themselves). other Registers do not exists at any address in the memory map

MOS 6502 Architecture

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

The 6502 Instruction Set

Microcontroller Intel [Instruction Set]

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

OSIAC Read OSIAC 5362 posted on the course website

8051 Overview and Instruction Set

CPU: SOFTWARE ARCHITECTURE INSTRUCTION SET (PART

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Microcontrollers. Microcontroller

HC11 Instruction Set

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

ARM Instruction Set Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Programming of 8085 microprocessor and 8051 micro controller Study material

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

This training course provides additional details about the CPU architecture of the MCUs in the M16C/2x and M16C/6x series.

EE 3170 Microcontroller Applications

Chapter 2A Instructions: Language of the Computer

TYPES OF INTERRUPTS: -

538 Lecture Notes Week 2

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

Outline. 2.8 Stack. 2.9 Subroutines

ECE232: Hardware Organization and Design

SECTION 6 CENTRAL PROCESSING UNIT

0b) [2] Can you name 2 people form technical support services (stockroom)?

Hitachi SuperH RISC Engine SH-1/SH-2/SH-DSP

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Introduction to Microcontroller. Systems. Embedded system. Assembler or C? Datatypes 2. Datatypes 1

Digital Blocks Semiconductor IP

Cmpt 150 The Freescale CPU12 March, The Freescale HC12

538 Lecture Notes Week 5

Digital Blocks Semiconductor IP

538 Lecture Notes Week 5

Digital IP Cell 8-bit Microcontroller PE80

Introduction to C. Write a main() function that swaps the contents of two integer variables x and y.

Introduction to Embedded Systems EE319K (Gerstlauer), Spring 2013

Digital Blocks Semiconductor IP

By: Dr. Hamed Saghaei

OMC HITACHI MICROCOMPUTER H8/3048 Series (H8/3048, H8/3047, H8/3044) HITACHI

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

Microcomputer Architecture and Programming

Outline. ARM Introduction & Instruction Set Architecture. ARM History. ARM s visible registers

... Executing conditional instructions

Course Administration

3.1 DATA MOVEMENT INSTRUCTIONS 45

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

Q. Classify the instruction set of 8051 and list out the instructions in each type.

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Mark II Aiken Relay Calculator

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

AXIS Communications A world of intelligent networks

Exam 1 Feb. 23, 25, 27?

Highlights. FP51 (FPGA based 1T 8051 core)

Transcription:

CMSC 23000 Winter 2006 Operating Systems Handout 3 January 27 RCX internals (Revised February 24) 1 Introduction This document collects together various pieces of information about the hardware in the LegoMindstorms RCX brick. The RCX uses a Hitachi H8/3292 microcontroller (a member of the H8/3297 family) running at 16MHz. We use the term RCX to refer to both the microcontroller and the other parts of the RCX hardware. 2 Registers The RCX has eight 16-bit general-purpose registers (r0-r7). These can be used both to address memory and to hold data. As data registers, they can also be viewed as 16 eight-bit registers (r0h, r0l,...). The RCX uses r7 as the stack pointer (sp). It also has a 16-bit program counter (pc) and an eight-bit condition-code register (ccr). The C ABI for the RCX uses r6 as the frame (or base) pointer. The first three function arguments are passed in r0, r1, and r2; additional arguments are passed on the stack, and function results are returned in r0. Registers r4 and r5 are callee-save. The condition code register is organized as follows: Bit Name Description 0 C Carry flag 1 V Overflow flag 2 Z Zero flag 3 N Negative flag 4 User bit 5 H Half-carry flag 6 User bit 7 I Interrupt mask bit Most arithmetic instructions affect the ccr, as do data move instructions. There are also instructions for performing logical operations on the ccr.

3 Instructions The RCX is largely a load-store architecture. Most arithmetic instructions work on registers, although it supports some bit operations that work on absolute addresses. 1 The RCX processor supports a number of addressing modes: Mode rn @rn @(d:16,rn) @rn+ @-rn @a:8 @a:16 #x:8 #x:16 @(d:16,pc) @@a:8 Description register register indirect register indirect with displacement register indirect with post-increment register indirect with pre-decrement 8-bit absolute (use 0xff as high bits) 16-bit absolute 8-bit immediate 16-bit immediate PC relative Memory indirect Note: when addressing words, the least bit of the address is ignored (i.e., regarded as 0). 4 Memory The RCX supports byte addressing with a 16-bit address space. The address space includes ROM, RAM, on-chip RAM, and device registers. These memories are mapped into a 16-bit address space as follows: Address range Memory type Contents 0x0000 0x3fff on-chip ROM RCX executive 0x4000 0x7fff Reserved (unmapped) 0x8000 0xfb7f off-chip RAM program and data 0xfb80 0xfd7f Reserved (unmapped) 0xfd80 0xff7f on-chip RAM ROM data 0xfe00 0xff7f on-chip RAM initial program stack 0xff80 0xff87 Reserved (unmapped) 0xff88 0xffff on-chip device registers H8/3293 device registers 5 Interrupts The RCX hardware supports 23 distinct interrupts (listed in Table 1). This table includes the name, RAM interrupt-vector location, and short description of each interrupt. When an interrupt occurs, the RCX hardware handles it as follows: 1. The I bit (bit 7) of the ccr register is tested; if it is set, and the interrupt is not a NMI, then it is marked as pending and execution continues. 1 This operations are used to manipulate the on-chip device registers that are mapped into the address space. 2

Table 1: RCX interrupts Name RAM vector Description NMI 0xfd92 Non Maskable Interrupt IRQ0 0xfd94 Interrupt 0 IRQ1 0xfd96 Interrupt 1 IRQ2 0xfd98 Interrupt 2 ICIA 0xfd9a 16 bit Timer Input Capture A ICIB 0xfd9c 16 bit Timer Input Capture B ICIC 0xfd9e 16 bit Timer Input Capture C ICID 0xfda0 16 bit Timer Input Capture D OCIA 0xfda2 16 bit Timer Output Compare A OCIB 0xfda4 16 bit Timer Output Compare B FOVI 0xfda6 16 bit Timer Overflow CMI0A 0xfda8 8 bit Timer 0 Compare Match A CMI0B 0xfdaa 8 bit Timer 0 Compare Match B OVI0 0xfdac 8 bit Timer 0 Overflow CMI1A 0xfdae 8 bit Timer 1 Compare Match A CMI1B 0xfdb0 8 bit Timer 1 Compare Match B OVI1 0xfdb2 8 bit Timer 1 Overflow ERI 0xfdb4 Serial Receive Error RXI 0xfdb6 Serial Receive End TXI 0xfdb8 Serial TDR Empty TEI 0xfdba Serial TSR Empty ADI 0xfdbc A/D Conversion End WOVF 0xfdbe Watchdog Timer Overflow 3

Low addresses Stack grows down r6 return PC saved r6 CCR ignored interrupted PC High addresses Figure 1: Stack layout upon entry in interrupt handler. 2. If the I bit is clear, or the interrupt is an NMI, then the hardware pushes the ccr register (plus a byte of padding), and the PC. 3. The I bit of the ccr is set. 4. The PC is loaded from the ROM interrupt vector, which contains the address of the dispatch code, which is also in ROM, for the particular interrupt. 5. The dispatch code saves r6 on the stack, loads the address of the interrupt handler from the RAM interrupt vector, and then does a jsr to the handler. 6. The interrupt handler runs. 7. Upon return, it restores r6 and does a rte, which restores the ccr and pc to their values at the time of the interrupt. Figure 1 gives the state of the stack upon entry to the interrupt handler. Note that the RCX is a big-endian machine, so the saved ccr register will be at an even address. To install a handler for an interrupt, one need only store the handler s address in the interrupt s RAM vector location. The ROM also contains a default handler, which just returns to the dispatch code, at address 0x046a. Appendix The H8/300L instruction set add.b #x:8,rd 8-bit addition add.b rs,rd 8-bit addition add.w rs,rd 16-bit addition 4

adds #1,rd 16-bit increment by 1(does not affect ccr) adds #2,rd 16-bit increment by 2 (does not affect ccr) addx #x:8,rd 8-bit addition with carry addx rs,rd 8-bit addition with carry and #x:8,rd 8-bit logical and and rs,rd 8-bit logical and andc #x:8,ccr 8-bit logical and with ccr band #x:3,@a:8 bit and band #x:3,@rd bit and band #x:3,rd bit and bcc d:8 conditional branch on carry clear (also called bhs) bclr #x:3,@a:8 bit clear bclr #x:3,@rd bit clear bclr #x:3,rd bit clear bclr rn,@a:8 bit clear bclr rn,@rd bit clear bclr rn,rd bit clear bcs d:8 conditional branch on carry set (also called blo) beq d:8 conditional branch on equal bge d:8 conditional branch on greater or equal bgt d:8 conditional branch on greater than bhi d:8 conditional branch on high biand #x:3,@a:8 bit invert and biand #x:3,@rd bit invert and biand #x:3,rd bit invert and bild #x:3,@a:8 bit invert load bild #x:3,@rd bit invert load bild #x:3,rd bit invert load bior #x:3,@a:8 bit invert or bior #x:3,@rd bit invert or bior #x:3,rd bit invert or bist #x:3,@a:8 bit invert store bist #x:3,@rd bit invert store bist #x:3,rd bit invert store bixor #x:3,@a:8 bit invert exclusive or bixor #x:3,@rd bit invert exclusive or bixor #x:3,rd bit invert exclusive or bld #x:3,@a:8 bit load bld #x:3,@rd bit load bld #x:3,rd bit load ble d:8 conditional branch on less or equal bls d:8 conditional branch on low or same blt d:8 conditional branch on less than bmi d:8 conditional branch on minus bne d:8 conditional branch on not equal bnot #x:3,@a:8 bit not bnot #x:3,@rd bit not 5

bnot #x:3,rd bit not bnot rn,@a:8 bit not bnot rn,@rd bit not bnot rn,rd bit not bor #x:3,@a:8 bit or bor #x:3,@rd bit or bor #x:3,rd bit or bpl d:8 conditional branch on plus bra d:8 branch always brn d:8 branch never bset #x:3,@a:8 bit set bset #x:3,@rd bit set bset #x:3,rd bit set bset rn,@a:8 bit set bset rn,@rd bit set bset rn,rd bit set bsr d:8 branch to subroutine bst #x:3,@a:8 bit store bst #x:3,@rd bit store bst #x:3,rd bit store btst #x:3,@a:8 bit test btst #x:3,@rd bit test btst #x:3,rd bit test btst rn,@a:8 bit test btst rn,@rd bit test btst rn,rd bit test bvc d:8 conditional branch on overflow clear bvs d:8 conditional branch on overflow set bxor #x:3,@a:8 bit exclusive or bxor #x:3,@rd bit exclusive or bxor #x:3,rd bit exclusive or cmp.b #x:8,rd 8-bit compare cmp.b rs,rd 8-bit compare cmp.w rs,rd 16-bit compare daa rd decimal-adjust add das rd decimal adjust subtract dec rd 8-bit decrement divxu rs,rd 16-bit by 8-bit unsigned division ((8+8)-bit result) eepmov move data to EEPROM inc rd 8-bit increment jmp @@a:8 jump jmp @a:16 jump jmp @rn jump jsr @@a:8 jump to subroutine jsr @a:16 jump to subroutine jsr @rn jump to subroutine ldc #x:8,ccr load ccr 6

ldc rs,ccr load ccr mov.b #x:8,rd 8-bit load signed immediate mov.b @(x:16,rs),rd 8-bit load mov.b @a:16,rd 8-bit load mov.b @a:8,rd 8-bit load mov.b @rs+,rd 8-bit load mov.b @rs,rd 8-bit load mov.b rs,@(x:16,rd) 8-bit store mov.b rs,@-rd 8-bit store mov.b rs,@a:16 8-bit store mov.b rs,@a:8 8-bit store mov.b rs,@rd 8-bit store mov.b rs,rd 8-bit register-to-register move mov.w #x:16,rd 16-bit load immediate mov.w @(x:16,rs),rd 16-bit load mov.w @a:16,rd 16-bit load mov.w @rs+,rd 16-bit load (also called pop, when rs is sp) mov.w @rs,rd 16-bit load mov.w rs,@(x:16,rd) 16-bit store mov.w rs,@-rd 16-bit store (also called push, when rd is sp) mov.w rs,@a:16 16-bit store mov.w rs,@rd 16-bit store mov.w rs,rd 16-bit register-to-register move mulxu rs,rd 8-bit by 8-bit unsigned multiply (16-bit result) neg rd 8-bit 2 s complement negation nop no operation not rd 8-bit 1 s complement negation (logical not) or #x:8,rd 8-bit logical or or rs,rd 8-bit logical or orc #x:8,ccr 8-bit logical or with ccr rotl rd 8-bit rotate left rotr rd 8-bit rotate right rotxl rd 8-bit rotate with carry left rotxr rd 8-bit rotate with carry right rte return from exception rts return from subroutine shal rd 8-bit arithmetic left shift shar rd 8-bit arithmetic right shift shll rd 8-bit logical left shift shlr rd 8-bit logical right shift sleep put processor to sleep stc ccr,rd 8-bit store from ccr sub.b rs,rd 8-bit subtraction sub.w rs,rd 16-bit subtraction subs #1,rd 16-bit decrement by 1 (does not affect ccr) subs #2,rd 16-bit decrement by 2 (does not affect ccr) subx #x:8,rd 8-bit subtract with carry 7

subx rs,rd 8-bit subtract with carry xor #x:8,rd 8-bit exclusive or xor rs,rd 8-bit exclusive or xorc #x:8,ccr 8-bit exclusive or with ccr 8