The Hitachi 63x09E Processor

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

The Hitachi 63x09E Processor

Post by zephyr »

The Hitachi 63x09E is a direct pin-for-pin replacement for the 6809E found in the Dragon 32 and 64. Besides being a CMOS chip, which runs much cooler than the 6809E, the Hitachi 63x09E also contains an enhanced instruction set and additional CPU registers that bring significant performance beyond what a 6809 can provide. The processor is usually socketed on a Dragon, so replacing it is a very easy task.

Brand new Hitachi 63x09E chips are available to buy from http://www.cloud9tech.com/ and several other online sources.


The following information explains the 63x09E chip in more detail...
HD63B09EP Technical Reference Guide
By Chet Simpson
Additions by Alan DeKok


Introduction


The HD63B09EP microprocessor by Hitachi, is a MC68B09E compatible
chip containing additional registers and an additional instruction set.
The 6309 was thought to be a flakey chip though, because it would
sometimes crash or change the values of registers when it encountered an
addressing mode or opcode invalid to the 6809. This was later found to be
an extended instruction set and a feature that would trap some programming
errors and jump to a specified location in memory.

Hitachi licensed the rights of the 6809 instruction set from
Motorola to make a 6809 compatible chip. When they finished the design,
they found there was a lot of unused space in the chip. With this in mind
they added extra registers and expanded on the instruction set, but due to
the licensing agreement with Motorola, they were unable to release the
information about the extra features.

Not only did the chip have an expanded instruction set, but it also
had a native mode that would run many of the instructions in fewer clock
cycles and a mode select for the FIRQ (Fast Interrupt ReQuest) that would
enable it to opperate the same as the IRQ.

In fact, all new instructions will execute in emulation mode, which
was originally seen when 'illegal' 6809 instructions produced odd results
when run on a computer with a 6309 installed.

The additional instruction set was first written about in the April
1988 issue of "Oh!FM", a Japanese magazine, and was later brought to
the attention of the 6809 community by Hirotsugu Kakagawa. He followed
up a series of '6809-6309 differences' messages on comp.sys.m6809 by
posting a detailed
explanation of the new features and instructions of the 6309.
This opened a whole new door to those who wished to
use the 6309 in place of the 6809.

The information in this reference is of technical nature and makes no
attempt to teach assembly language programming. It is ONLY a technical
reference guide for those who already know assembly and wish to use these
features in their programs. Although all of the opcodes for the 6309/6809
chip are listed in the appendix, only the additional features supplied by
the 6309 will be discussed in detail.



Summary of Features


More registers:
one 8/16 bit 'zero' register
Two 8bit accumulators.
One 16bit concatenated register
One 16bit value register.
One 8bit mode/error register.
One 32bit concatenated register

Two modes: MC68B09E emulation mode and HD63B09EP native mode.

Reduced execution cycles when running in native mode.

Many additional instructions.

Error trapping of illegal instructions and zero divisions.



HD63B09EP Technical Reference Guide Page 2




Description of Additional Registers


The 6309 has 7 additional registers. Only 4 of these are actual
registers. 2 are combinations of registers, and the last is a
constant-value register. These registers are:

ACCE - 8 bit accumulator.
ACCF - 8 bit accumulator.
W - 16 bit concatenated register (ACCE and ACCF combined).
Q - 32 bit concatenated register (ACCA, ACCB ,ACCE and ACCF
combined).
V - 16 bit register (which can only be accessed with the
inter-register instructions).
0 - zero register
MD - 8 bit mode/error register.


ACCE and ACCF both work in much the same manner as the ACCA and ACCB
accumulators. This makes for easier programming in math and data oriented
routines.

The W register is like the D register in the 6809. It is a
concatenated register containing the values of ACCE and ACCF as one 16 bit
value. ACCE is contained in the high 8 bits and ACCF is contained in the
low 8 bits.

The Q register is a 32 bit concatenated register. This register
is composed of the concatenation of D and W, which in turn are composed of
the registers ACCA, ACCB, ACCE and ACCF respectively. This register is used
mostly with the additional math instructions supplied with the 6309 which
will be discussed later.

The V register is a 16 bit register that can only be accessed with
inter-register instructions such a TFR and EXG. The contents of this
register will not change if the CPU is reset, allowing this register to be
used as a constant value for the program.

The 0 register is always zero, independant of writes to it.
It enables a zero value to be used in inter-register operations without
accessing memory, or changing the value of another register.

The MD register is a mode and error register and works much in the
same way as the CC register. The bit definitions are as follows:

Write bits
Bit 0 - Execution mode of the 6309.
If clear ( 0 ), the cpu is in 6809 emulation mode.
If set ( 1 ), the cpu is in 6309 native mode.
Bit 1 - FIRQ mode
If clear ( 0 ), the FIRQ will occur normally.
If set ( 1 ) , the FIRQ will operate the same as the
IRQ

Bits 2 to 5 are unused

Read bits - One of these bits is set when the 6309 traps an error
Bit 6 - This bit is set ( 1 ) if an illegal instruction is
encountered
Bit 7 - This bit is set ( 1 ) if a zero division occurs.








HD63B09EP Technical Reference Guide Page 3



Modes of Operation


The 6309 has two modes of operation; 6809 Emulation mode in which
the chip acts and executes instructions the same as the 6809, and 6309
Native mode which stores an extra two bytes on the stack when an interrupt
(IRQ) occurs, and executes instructions in fewer clock cycles.

When in native mode, the W register (2 additional bytes) is stored
(PSHS) on the system stack when an interrupt occurs, it is stored on the
stack right after the D (general data) register. Since ALL register
values are stored on the system stack when an IRQ (NOT FIRQ - See FIRQ
modes for more information) occurs, great care should be taken when
writing or patching those routines to run in native mode.

Pull <- CC,A,B,E*,F*,DP,Xhi,Xlo,Yhi,Ylo,Uhi,Ulo,PChi,PClo <- Push

* indicates the additional registers stored on the system stack


When in native mode those interrupt routines which modify the return
address by modifying the 10th and 11th byte offsets from the stack (STX
10,S or STY 10,S etc.) will have to be changed to modify the 12th and 13th
byte offsets from the stack (STX 12,S or STY 12,S etc.). If those routines
are not patched to run in native mode they will either get stuck in a
continuous loop or will crash the system due to the fact that they are not
returning to the correct address. This poses a MAJOR problem for OS-9
Level II since its main interrupt handling routine relies highly on the
changing of the return (PC) address on the stack. Disk read/write and
formatting routines also rely heavily on changing the return address
during an NMI (Non-Maskable Interrupt).

To patch those routines which do modify the return address, the
program or routine must be disassembled or modified with a disk sector
editing program. Look for instructions such as STX 10,S or STY 10,S that
has an RTI (Return from Interrupt) instruction within the next few lines
of the routine. The line containing STX 10,S or STY 10,S should be changed
to STX 12,S or STY 12,S respectively.

Remember, after those routines are patched, those programs using them
will NOT work in emulation mode and will require native mode to be enabled
upon startup.



Native Mode and Timing Loops


There is at least one more problem that needs to be addressed. Those
are routines which are dependant on timing loops for accuarate operation.
Since the 6309 executes instructions faster when in native mode, those
routines that use timing loops would be effected. Since this can pose a
problem and can create erratic operation, the delay value or routine will
need to be changed for the routine to operate correctly.

Those routines are usually serial-printer routines, cassette
read/write timimg routines, software clocks and some disk read/write
routines.




HD63B09EP Technical Reference Guide Page 4



Modes of the Fast Interrupt Request (FIRQ)


The designers of the 6309 decided that with the additional
instructions and native mode of operation, the FIRQ may be used more than
it usually is. With this in mind they decided to allow you to make the
FIRQ run the same as the IRQ and store (PSHS) all the current values of
the registers on the system stack. Normally, the FIRQ only stores the CC
(condition code) and the PC (Program Counter/return address) on the stack,
so to keep compatability with the 6809, they included it as a selectable
feature in the MD (Mode/status) register.



Inter-Register Instructions


The new Inter-Register instructions (ADCR, ADDR, CMPR, EORR, ORR,
SBCR, and SUBR) all work the same as their register/memory (ADCA, ADDA,
etc.) counterparts except that they operate between registers. All of the
new instructions use the same post-byte information as the normal TFR
instruction and use the format of R0,R1 (register 0 and Register 1
respectively) with the result going into R1. See Block Transfers for
information on the TFR block move instructions.

Mixed-size inter-register operations default to using
identical sized register. So TFR A,X actually executes as TFR D,X.
You could also do 'lea(d) d,pc' calculations by doing 'addr pc,d'. As
the new inter-register instructions can now perform math using the PC
register, REALLY odd possibilities exist. Try looking at code like
'eorr d,pc', and figuring out where it ends up.

Inter-register instructions with 16-bit r1 and CC or DP (8-bit r2)
are legal, but the results are unknown.


Bit Manipulation of Memory Locations


The AIM, EIM, OIM and TIM instructions all do logical bit
manipulations to locations in memory, with the result stored into the
location, and the respective bits for each instruction set in the CC
register. They can be used in the DIRECT, INDEXED or EXTENDED adressing
modes.

Instruction descriptions:

AIM - AND IN MEMORY
EIM - EOR IN MEMORY
OIM - OR IN MEMORY
TIM - TEST bits IN MEMORY

Instruction format: X, post byte, operand

Where X is the instruction op-code, post-byte contains the bits to
AND, OR, EOR or TEST against the memory location, and the operand is the
memory location or indexing post-byte depending on the mode of operation.


Mnemonic format:

Instruction logical operation value, memory location or index operation

Mnemonic example:

AIM #$0F,$E00

The example takes the contents of memory location $E00, does a LOGICAL
and with the Value #$0F and then stores the result back into $E00.
The complete document is attached to this post along with others.
Attachments
Hitachi_63x09E_Information.zip
(1.17 MiB) Downloaded 313 times
Alastair
Posts: 669
Joined: Fri Jul 18, 2008 11:33 pm

Re: The Hitachi 63x09E Processor

Post by Alastair »

Are there any 6309 assemblers available for the Dragon, or CoCo, that utilise these extra features?
sixxie
Posts: 1348
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: The Hitachi 63x09E Processor

Post by sixxie »

I'm pretty sure Mamou does (part of toolshed). Also LWTOOLS.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: The Hitachi 63x09E Processor

Post by zephyr »

There's Robert Gault's EDTASM6309 patch. EDTASM is for the CoCo, but it wouldn't be difficult to convert it for use on the Dragon.

There are also several cross assemblers available. Most of them are included with Roger Taylor's Rainbow IDE.

I have attached a good selection of cross assemblers to this post.
Attachments
6809_6309_Cross_Assemblers.zip
(795.9 KiB) Downloaded 317 times
prime
Posts: 267
Joined: Fri Apr 10, 2009 1:40 am

Re: The Hitachi 63x09E Processor

Post by prime »

zephyr wrote:The Hitachi 63x09E is a direct pin-for-pin replacement for the 6809E found in the Dragon 32 and 64. Besides being a CMOS chip, which runs much cooler than the 6809E, the Hitachi 63x09E also contains an enhanced instruction set and additional CPU registers that bring significant performance beyond what a 6809 can provide. The processor is usually socketed on a Dragon, so replacing it is a very easy task.
And I can comfirm that they do indeed work in the Dragon, I bought a couple a while back to upgrade my CoCo3, so I tried one in the Dragon and it works with no apparent problems.

Cheers.

Phill.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: The Hitachi 63x09E Processor

Post by zephyr »

Thanks Phill. I have been running three 63C09E's, and a 63B09E in Dragon 32's, and 64's for more than twelve months without any problems. They use much less current, and always run super cool.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: The Hitachi 63x09E Processor

Post by zephyr »

Enable 6309 Native Mode:

BASIC:

Code: Select all

10 FOR I = 512 TO 515:READ A:POKEI,A:NEXT
20 EXEC512
30 DATA 17,61,1,57 
Assembly (CCASM):

Code: Select all


org	  16384
start	ldmd	#1
        rts
	     end

Disable 6309 Native Mode (6809e emulation mode):

BASIC:

Code: Select all

10 FOR I = 512 TO 515:READ A:POKEI,A:NEXT
20 EXEC512
30 DATA 17,61,0,57 
Assembly (CCASM):

Code: Select all


org	  16384
start	ldmd	#0
        rts
	     end
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: The Hitachi 63x09E Processor

Post by zephyr »

The following program is a PLAY command patch and 63x09 native mode enable for Dragon 64, 32 mode. The program works by copying ROM to RAM (64K mode), patching the PLAY command ($AFF0), and enabling 63x09 native mode. Lines 110 to 130 will patch any version of DragonDOS, SuperDOS, or DosPlus.

Code: Select all

10 '6309 NATIVE MODE PATCH V1.0
20 'FOR THE DRAGON 64, 32 MODE
30 'BY STEVE EVANS (ZEPHYR)
40 '
50 CSUM=0:FOR I=&H5000 TO &H5029:READ A$:A=VAL("&H"+A$):CSUM=CSUM+A:POKE I,A:NEXT
60 IF CSUM<>5875 THEN PRINT"ERROR IN DATA LINES":END
70 EXEC&H5000
80 '
90 'LINES 110 TO 130 PATCH DOS
100 '
110 IF PEEK(&H109)<>&H7E THEN END
120 NMIP=PEEK(&H10A)*256+PEEK(&H10B)+6
130 IF PEEK(NMIP)=&H6C THEN POKE NMIP,&H6E
140 DATA 1A,50,86,67,B1,AF,F0,26,1E,4F,8E,80,0,B7,FF,DE,E6,84,B7,FF
150 DATA DF,E7,80,8C,FE,FF,23,F1,86,69,B7,AF,F0,8E,3,EB,11,3D,1,1C,AF,39
This program returns to 32K mode, and disables 63x09 native mode.

Code: Select all

10 FOR I = &H200 TO &H203:READ A$:POKEI,VAL("&H"+A$):NEXT
20 POKE&HFFDE,0:EXEC&H200
30 DATA 11,3D,0,39
The following program is a PLAY command patch and 63x09 native mode enable for Dragon 64, 64 mode. The program works by patching the PLAY command ($EFF0), and enabling 63x09 native mode.

Code: Select all

10 '6309 NATIVE MODE PATCH V1.0
20 'FOR THE DRAGON 64, 64 MODE
30 'BY STEVE EVANS (ZEPHYR)
40 '
50 CSUM=0:FOR I=&H5000 TO &H5013:READ A$:A=VAL("&H"+A$):CSUM=CSUM+A:POKE I,A:NEXT
60 IF CSUM<>2285 THEN PRINT"ERROR IN DATA LINE":END
70 EXEC&H5000
100 DATA 1A,50,86,67,B1,EF,F0,26,8,86,69,B7,EF,F0,11,3D,1,1C,AF,39
This program restores the default 64 mode PLAY command code, and disables 63x09 native mode.

Code: Select all

10 FOR I = &H200 TO &H203:READ A$:POKEI,VAL("&H"+A$):NEXT
20 POKE&HEFF0,&H67:EXEC&H200
30 DATA 11,3D,0,39
Post Reply