SC61860( ESR-H or old-SC ) basics

SC61860 is a certain model number of implementation of the CPU architecture ESR-H. It is also known as "old-SC" because there is another well-known "SC" cpu, SC62015 or "new-SC" whose architecture is ESR-L. ( I wonder why newer one is named as "L" rather than "H" ! )

ESR-H architecture cpu was widely used for SHARP's pocket computers ( PC-12xx, 13xx and 14xx ) and electronic organizers ( PA-6/7/8000, S1, T1, X1/2/3 and so on ) mostly in '80s or early '90s.

Registers

External storage pointer

There are two 16bit pointer registers to address external storage space. PC and DP. PC is so called program counter. DP is for general use.

Internal RAM pointer

P,Q and R are internal RAM pointers. Internal RAM consists of only 96 byte and it is enough for these pointer registers to be 7bit. Therefore P,Q and R are 7bit long. P and Q are for general use as well as R is the stack pointer.

Arithmetic registers

under construction.

Internal RAM

SC61860(old SC) has 96 byte internal RAM space. Some important registers including accumulator are also mapped in this space. For example, accumulator is located on (0x02). System stack and some I/O ports are also exist here. Internal RAM is faster and more convenient than external RAM. Databus is 8bit wide. Word or greater data are stored in LITTLE endian format.

External storage space

External storage space is 64KB linear address space of 0x0000-0xffff. The first 8KB area(0x0000-0x1fff) of this space is called "internal ROM" which is physically embedded in the CPU chip and only accessible via PC. (You cannot read nor write via DP.) Program codes and many kinds of data is stored in external storage. Databus is 8bit wide. Word or greater data are stored in BIG endian format fundamentally.

Register and Internal RAM map

symbolint.RAM addrusage
P,Q--7bit internal RAM pointer
R--7bit internal RAM pointer(stack)
PC--16bit ext. storage pointer(program counter)
DP--16bit ext. storage pointer
I0x00counter
J0x01
K,L,M,N0x08,...,0x0b
A0x02accumulator
B0x03accumulator (alt.)
XL0x0416bit pointer
XH0x05
YL0x0616bit pointer
YH0x07
IA0x5cI/O port A
IB0x5dI/O port B
FO0x5eI/O port F
OUTC0x5f control port (|-|Bz3|Bz2|Bz1|PowOFF|HLT|CntCLR|DispSW|)

instruction set

mnemonicfunction flag bytecycleop code note
A
adb (P+1,P):=(P+1,P)+BA; P++ C,Z 1 5 0x14
adcm (P):=(P)+A+C C,Z 1 3 0xc4
adia n A:=A+n C,Z 2 4 0x74, n
adim n (P):=(P)+n C,Z 2 4 0x70, n
adm (P):=(P)+A C,Z 1 3 0x44
adn tmp:=I;{ (P):=(P)+A, P-- }wihle(tmp--) C,Z 1 4+3I 0x0c block BCD operation
adw tmp:=I;{ (P):=(P)+(Q), P--, Q-- }wihle(tmp--) C,Z 1 4+3I 0x0e block BCD operation
adia n A:=A&n Z 2 4 0x64, n
anid n [DP]:=[DP]&n Z 2 6 0xd4, n consumes a byte of stack
anim n (P):=(P)&n Z 2 4 0x60, n
anma (P):=(P)&A Z 1 3 0x46
B
C
cal hl push PC; PC=hl - 2 7 0xe0+h, l hl is smaller than 0x2000
call hl push PC; PC=hl - 3 8 0x78, h, l
case1 n hl k:=n; push hl -- 4 8 0x7a,n,h,l switch() ?
case2 n[1] hl[1] .. n[k] hl[k] hl0 if (n[x]=A) {PC=hl[x]} else {PC=hl0} ? 3k+3 5k+7 0x69, n[1],h[1],l[1], ... ,n[k],h[k],l[k], h0,l0 case: .. default: ?
cdn tmp:=I;Z=1;{if(!Xin){Z=0;break;}}while(tmp--) Z 1 4(I-tmp)+1 ? 0x6f for CMT use ?
clra A:=0 - 1 0x23 undocumented instruction
cpia A-n > /dev/null Z,C 2 4 0x67, n
cpim (P)-n >/dev/null Z,C 2 4 0x63, n
cpma (P)-A >/dev/null Z,C 1 3 0xc7
cup tmp:=I;Z:=1;{if(Xin){Z:=0;break;}}while(tmp--) Z 1 4(I-tmp)+1 ? 0x4f complemental of CDN
D
deca A--; Q:=0x02 Z,C 1 4 0x43
decb B--; Q:=0x03 Z,C 1 4 0xc3
deci I--; Q:=0x00 Z,C 1 4 0x41
decj J--; Q:=0x01 Z,C 1 4 0xc1
deck K--; Q:=0x08 Z,C 1 4 0x49
decl L--; Q:=0x09 Z,C 1 4 0xc9
decm M--; Q:=0x0a Z,C 1 4 0x4b
decn N--; Q:=0x0b Z,C 1 4 0xcb
decp P-- - 1 2 0x51
dx X--; DP:=X; Q=0x05; - 1 6 0x05
dxl X--; DP:=X; A=[DP]; Q=0x05; - 1 7 0x25
dy Y--; DP:=Y; Q=0x07; - 1 6 0x07
dys Y--; DP:=Y; [DP]:=A; Q=0x07; - 1 7 0x27
E
exab A <-> B - 1 3 0xda
exam A <-> (P) - 1 3 0xdb
exb tmp:=J; do{(P++)<->(Q++)}while(tmp--) - 1 3+3(J+1) 0x0b
exbd tmp:=J; do{(P++)<->[DP++]}while(tmp--) - 1 3+6(J+1) 0x1b
exw tmp:=I; do{(P++)<->(Q++)}while(tmp--) - 1 3+3(I+1)
exwd tmp:=I; do{(P++)<->[DP++]}while(tmp--) - 1 3+6(I+1)
F
fild - 1 4+3(I+1)
film - 1 4+(I+1)
G
H
I
ina Z 1
inb Z 1
inca Z,C 1
incb Z,C 1
inci Z,C 1
incj Z,C 1
inck Z,C 1
incl Z,C 1
incm Z,C 1
incn Z,C 1
incp - 1
ix X++; DP:=X; Q:=0x05; - 1 0x04
ixl X++; DP:=X; Q:=0x05; A:=[DP]; - 1 0x24
iy Y++; DP:=Y; Q:=0x07; - 1 0x06
iys Y++; DP:=Y; Q:=0x07; [DP]:=A; - 1 0x26
J
under construction...

References