0000:1000 INX BP = BP + 1
0000:1001 XCH CP <=> BP
0000:1010 XCH DP <=> BP
0000:1011 XCH EP <=> BP
0000:1100 DCX BP = BP - 1
0000:1101 XCH CP <=> DP
0000:1110 XCH DP <=> EP
0000:1111 XCH EP <=> CP
0001:bbbb LDI AC = uint4
0010:bbbb ADI AC = AC + uint4 + CF
0011:bbbb CPI AC - uint4
0100:bbbb ANI AC = AC & uint4
0101:bbbb XOI AC = AC ^ uint4
0110:bbbb ORI AC = AC | uint4
0111:0000 BSR [--BP] = PC + 2 ; PC = PC + int8
0111:0001 BRA PC = PC + int8
0111:0010 BNE if ZF==0 ; PC = PC + int8
0111:0011 BEQ if ZF==1 ; PC = PC + int8
0111:0100 BLO if CF==0 ; PC = PC + int8
0111:0101 BHS if CF==1 ; PC = PC + int8
0111:0110 BLT if (SF^OF)==1 ; PC = PC + int8
0111:0111 BGE if (SF^OF)==0 ; PC = PC + int8
0111:1000 JSR [--BP] = PC + 2 ; PC = CP + int8
0111:1001 JMP PC = CP + int8
0111:1010 JNE if ZF==0 ; PC = CP + int8
0111:1011 JEQ if ZF==1 ; PC = CP + int8
0111:1100 JLO if CF==0 ; PC = CP + int8
0111:1101 JHS if CF==1 ; PC = CP + int8
0111:1110 JLT if (SF^OF)==1 ; PC = CP + int8
0111:1111 JGE if (SF^OF)==0 ; PC = CP + int8
1000:dddd STA Rn = AC
1001:dddd LDA AC = Rn
1010:dddd ADC AC = AC + Rn + CF
1011:dddd SBB AC = AC - Rn + CF
1100:dddd AND AC = AC & Rn
1101:dddd XOR AC = AC ^ Rn
1110:dddd ORR AC = AC | Rn
1111:00xx STX [--BP] = An
1111:01xx STX [BP++] = An
1111:10xx LDX An = [--BP]
1111:11xx LDX An = [BP++]
自作CPU設計中
自作CPUコンピュータ製作に使うため、AM2901BDCB(\1604)、AM2964BDC(\855)を若松さんで入手しました。
自己書換せず多段サブルーチンや再配置可能なプログラムが出来て、BASICインタプリタが動く最小CPUを目指しています。
以下のような感じの4bitノイマン型アキュムレータマシンを設計中ですが、使いやすいフラグ変化はどうあるべきか悩み中。
問題点として割込みが全く対応できないのですが、宜しければ他にも何かアドバイスを頂けたら嬉しいです。
Instruction 8bit (+ 8bit displacement)
ALU 4bit
Address Bus 16bit
Data Bus 8bit
AC 4bit
R0..R15 4bit
PC 16bit
BP (R3:R2:R1:R0)
CP (R7:R6:R5:R4)
DP (R11:R10:R9:R8)
EP (R15:R14:R13:R12)
Rn R0..R15
An PC,CP,DP,EP
0000:0000 NOP
0000:0001 HLT
0000:0010 CLC CF = 0
0000:0011 SEC CF = 1
0000:0100 ROR AC(n) = AC(n+1) ; AC(3) = AC(0) ; CF = AC(0)
0000:0101 RRC AC(n) = AC(n+1) ; AC(3) = CF ; CF = AC(0)
0000:0110 ROL AC(n) = AC(n-1) ; AC(0) = AC(3) ; CF = AC(3)
0000:0111 RLC AC(n) = AC(n-1) ; AC(0) = CF ; CF = AC(3)
0000:1000 INX BP = BP + 1
0000:1001 XCH CP <=> BP
0000:1010 XCH DP <=> BP
0000:1011 XCH EP <=> BP
0000:1100 DCX BP = BP - 1
0000:1101 XCH CP <=> DP
0000:1110 XCH DP <=> EP
0000:1111 XCH EP <=> CP
0001:bbbb LDI AC = uint4
0010:bbbb ADI AC = AC + uint4 + CF
0011:bbbb CPI AC - uint4
0100:bbbb ANI AC = AC & uint4
0101:bbbb XOI AC = AC ^ uint4
0110:bbbb ORI AC = AC | uint4
0111:0000 BSR [--BP] = PC + 2 ; PC = PC + int8
0111:0001 BRA PC = PC + int8
0111:0010 BNE if ZF==0 ; PC = PC + int8
0111:0011 BEQ if ZF==1 ; PC = PC + int8
0111:0100 BLO if CF==0 ; PC = PC + int8
0111:0101 BHS if CF==1 ; PC = PC + int8
0111:0110 BLT if (SF^OF)==1 ; PC = PC + int8
0111:0111 BGE if (SF^OF)==0 ; PC = PC + int8
0111:1000 JSR [--BP] = PC + 2 ; PC = CP + int8
0111:1001 JMP PC = CP + int8
0111:1010 JNE if ZF==0 ; PC = CP + int8
0111:1011 JEQ if ZF==1 ; PC = CP + int8
0111:1100 JLO if CF==0 ; PC = CP + int8
0111:1101 JHS if CF==1 ; PC = CP + int8
0111:1110 JLT if (SF^OF)==1 ; PC = CP + int8
0111:1111 JGE if (SF^OF)==0 ; PC = CP + int8
1000:dddd STA Rn = AC
1001:dddd LDA AC = Rn
1010:dddd ADC AC = AC + Rn + CF
1011:dddd SBB AC = AC - Rn + CF
1100:dddd AND AC = AC & Rn
1101:dddd XOR AC = AC ^ Rn
1110:dddd ORR AC = AC | Rn
1111:00xx STX [--BP] = An
1111:01xx STX [BP++] = An
1111:10xx LDX An = [--BP]
1111:11xx LDX An = [BP++]