Last active
May 3, 2020 02:11
-
-
Save hasegawayosuke/c5e854d8d18cb98ba652a800a05cf061 to your computer and use it in GitHub Desktop.
CPUエミュレータ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1994年、演習の延長で作ったCPUエミュレータ(Turbo PASCAL製) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:000 | |
0354 LEA GR4,0100H | |
0100 | |
0141 LD GR1,0,GR4 | |
0000 | |
0311 LEA GR1,-1,GR1 | |
FFFF | |
0214 ST GR1,11,GR4 | |
000B | |
0342 LEA GR2,1,GR4 | |
0001 | |
0343 LOOP2: LEA GR3,0,GR4 | |
0000 | |
0121 LOOP1: LD GR1,0,GR2 | |
0000 | |
0A31 CPL GR1,0,GR3 | |
0000 | |
0F50 JPZ SKIP | |
0018 | |
0130 LD GR0,0,GR3 | |
0000 | |
0213 ST GR1,0,GR3 | |
0000 | |
0202 ST GR0,0,GR2 | |
0000 | |
0333 SKIP: LEA GR3,1,GR3 | |
0001 | |
0224 ST GR2,12,GR4 | |
000C | |
0A43 CPL GR3,12,GR4 | |
000C | |
1050 JMI LOOP1 | |
000C | |
0322 LEA GR2,1,GR2 | |
0001 | |
0A42 CPL GR2,0,GR4 | |
0000 | |
1050 JMI LOOP2 | |
000A | |
1350 LOOP3: JMP LOOP3: | |
0026 | |
:010 | |
000A:データの個数 | |
0009:以下、データ | |
0001: | |
0008: | |
0002: | |
0007: | |
0003: | |
0006: | |
0004: | |
0005: | |
0000: | |
0000:ワークエリア | |
0000: 〃 | |
0000: 〃 | |
0000: END | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{************************************************************** | |
* * | |
* Meteor ver.1.0 * | |
* * | |
* 1994 Y.Hasegawa D4-No.27 * | |
* * | |
* MS-DOSコマンドラインで最下行ファンクション表示を * | |
* 消してから、実行して下さい。(Autoexec.Batでも可) * | |
**************************************************************} | |
program meteor; | |
uses crt; | |
const | |
MemSize=640; | |
type | |
_1bit = 0..1; | |
_17bit= 0..$1FFFF; | |
_25bit= 0..$1FFFFFF; | |
hexadecimal=array[0..3]of char; | |
var | |
GR0,GR1,GR2,GR3,GR4,PC,IR,MAR,MBR,BUS,upc:word; | |
AC:_17bit; | |
M :array[0..MemSize-1] of word; | |
FR :array[0..2] of _1bit; | |
uprom:array[0..200] of _25bit; | |
uarom:array[0..$20] of word; | |
loadgr0r ,loadgr1r ,loadgr2r ,loadgr3r ,loadgr4r ,loadpcr ,loadmarr , | |
loadmbrr ,loadirr ,xgategr0r,xgategr1r,xgategr2r,xgategr3r,xgategr4r, | |
xgatepcr ,xgatemarr,xgatembrr,xgateirr ,xgateacr ,ygategr0r,ygategr1r, | |
ygategr2r,ygategr3r,ygategr4r,ygatepcr ,ygatemarr,ygatembrr,ygateirr , | |
testfr0r ,testfr1r ,setfrr ,incpcr ,alumode1r,alumode2r,alumode3r, | |
alumode4r,rnwr ,strober ,csmbrr ,clrupcr ,incupcr ,loadupcr , | |
lloadr ,lgater ,xgate0r ,loadacr ,testfr2r ,lgateyr ,decmbrr , | |
ygate0r :_1bit; | |
loadgr0 ,loadgr1 ,loadgr2 ,loadgr3 ,loadgr4 ,loadpc ,loadmar , | |
loadmbr ,loadir ,xgategr0 ,xgategr1 ,xgategr2 ,xgategr3 ,xgategr4 , | |
xgatepc ,xgatemar ,xgatembr ,xgateir ,xgateac ,ygategr0 ,ygategr1 , | |
ygategr2 ,ygategr3 ,ygategr4 ,ygatepc ,ygatemar ,ygatembr ,ygateir , | |
testfr0 ,testfr1 ,setfr ,incpc ,alumode1 ,alumode2 ,alumode3 , | |
alumode4 ,rnw ,strobe ,csmbr ,clrupc ,incupc ,loadupc , | |
lload ,lgatex ,xgate0 ,loadac ,testfr2 ,lgatey ,decmbr , | |
ygate0 :_1bit; | |
hex_tbl:array[0..15]of char; | |
rwa:word; | |
{-----------------------------------------------------------------------------} | |
procedure Initup; | |
begin | |
{Fetch} {LEA GR,XR} | |
uprom[ 0]:=$0600fab;{ MAR <- PC } uprom[ 16]:=$0600fab;{ MAR <- PC } | |
uprom[ 1]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 17]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 2]:=$0600fc8;{ IR <- MBR } uprom[ 18]:=$0614ce9;{ AC <- MBR+XR} | |
uprom[ 3]:=$0708fff;{ PC <- PC+1 } uprom[ 19]:=$0508f9e;{ GR <- AC } | |
{LD GR,XR} {ST GR,XR} | |
uprom[ 4]:=$0600fab;{ MAR <- PC } uprom[ 10]:=$0600fab;{ MAR <- PC } | |
uprom[ 5]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 11]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 6]:=$0610ce9;{ AC <- MBR+XR} uprom[ 12]:=$0610ec9;{ AC <- MBR+XR} | |
uprom[ 7]:=$0600f9b;{ MAR <- AC } uprom[ 13]:=$0600f9b;{ MAR <- AC } | |
uprom[ 8]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 14]:=$0e00fec;{ MBR <- GR } | |
uprom[ 9]:=$0508fce;{ GR <- MBR } uprom[ 15]:=$0108fcf;{ M[MAR] <- MBR} | |
{ADD GR,XR} {ADD GR,XR} | |
uprom[ 20]:=$0600fab;{ MAR <- PC } uprom[ 27]:=$0600fab;{ MAR <- PC } | |
uprom[ 21]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 28]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 22]:=$0610ce9;{ AC <- MBR+XR} uprom[ 29]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 23]:=$0600f9b;{ MAR <- AC } uprom[ 30]:=$0600f9b;{ MAR <- AC } | |
uprom[ 24]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 31]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 25]:=$0614ec9;{ AC <- GR+MBR} uprom[ 32]:=$0624ec9;{ AC <- GR-MBR} | |
uprom[ 26]:=$0508f9e;{ GR <- AC } uprom[ 33]:=$0508f9e;{ GR <- AC } | |
{AND GR,XR} {OR GR,XR} | |
uprom[ 34]:=$0600fab;{ MAR <- PC } uprom[ 41]:=$0600fab;{ MAR <- PC } | |
uprom[ 35]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 42]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 36]:=$0610ce9;{ AC <- MBR+XR} uprom[ 43]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 37]:=$0600f9b;{ MAR <- AC } uprom[ 44]:=$0600f9b;{ MAR <- AC } | |
uprom[ 38]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 45]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 39]:=$0634ec9;{ AC <- GR&MBR} uprom[ 46]:=$0644ec9;{ AC <-GRorMBR} | |
uprom[ 40]:=$0508f9e;{ GR <- AC } uprom[ 47]:=$0508f9e;{ GR <- AC } | |
{EOR GR,XR} {CPL GR,XR} | |
uprom[ 48]:=$0600fab;{ MAR <- PC } uprom[ 55]:=$0600fab;{ MAR <- PC } | |
uprom[ 49]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 56]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 50]:=$0610ce9;{ AC <- MBR+XR} uprom[ 57]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 51]:=$0600f9b;{ MAR <- AC } uprom[ 58]:=$0600f9b;{ MAR <- AC } | |
uprom[ 52]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 59]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 53]:=$0654ec9;{ AC <-GRxorMBR} uprom[ 60]:=$052cec9;{ AC <- GR-MBR} | |
uprom[ 54]:=$0508f9e;{ GR <- AC } | |
{SLA} {SRA} | |
uprom[ 61]:=$0600fab;{ MAR <- PC } uprom[ 68]:=$0600fab;{ MAR <- PC } | |
uprom[ 62]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 69]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 63]:=$0610ce9;{ AC <- MBR+XR} uprom[ 70]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 64]:=$0e00f9c;{ MBR <- AC } uprom[ 71]:=$0e00f9c;{ MBR <- AC } | |
uprom[ 65]:=$0610e59;{ AC <- GR } uprom[ 72]:=$0610e59;{ AC <- GR } | |
uprom[ 66]:=$1464fff;{ AC <- SLA(AC)} uprom[ 73]:=$1474fff;{ AC <- SRA(AC)} | |
uprom[ 67]:=$0508f9e;{ GR <- AC } uprom[ 74]:=$0508f9e;{ GR <- AC } | |
{SLL} {SRL} | |
uprom[ 75]:=$0600fab;{ MAR <- PC } uprom[ 82]:=$0600fab;{ MAR <- PC } | |
uprom[ 76]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 83]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 77]:=$0610ce9;{ AC <- MBR+XR} uprom[ 84]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 78]:=$0e00f9c;{ MBR <- AC } uprom[ 85]:=$0e00f9c;{ MBR <- AC } | |
uprom[ 79]:=$0610e59;{ AC <- GR } uprom[ 86]:=$0610e59;{ AC <- GR } | |
uprom[ 80]:=$1484fff;{ AC <- SLL(AC)} uprom[ 87]:=$1494fff;{ AC <- SRL(AC)} | |
uprom[ 81]:=$0508f9e;{ GR <- AC } uprom[ 88]:=$0508f9e;{ GR <- AC } | |
{JPZ} {JMI} | |
uprom[ 89]:=$0600fab;{ MAR <- PC } uprom[ 96]:=$0600fab;{ MAR <- PC } | |
uprom[ 90]:=$0600ffc;{ MBR <- M[MAR]} uprom[ 97]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[ 91]:=$0610ce9;{ AC <- MBR+XR} uprom[ 98]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[ 92]:=$0600f9a;{ PC <- AC } uprom[ 99]:=$0608fff;{ PC <- PC + 1} | |
uprom[ 93]:=$0602fff;{ testFR1 } uprom[100]:=$0602fff;{ testFR1 } | |
uprom[ 94]:=$0600fba;{ PC <- MAR } uprom[101]:=$0500f9a;{ PC <- AC } | |
uprom[ 95]:=$0508fff;{ PC <- PC + 1} | |
{JNZ} {JZE} | |
uprom[102]:=$0600fab;{ MAR <- PC } uprom[109]:=$0600fab;{ MAR <- PC } | |
uprom[103]:=$0600ffc;{ MBR <- M[MAR]} uprom[110]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[104]:=$0610ce9;{ AC <- MBR+XR} uprom[111]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[105]:=$0600f9a;{ PC <- AC } uprom[112]:=$0608fff;{ PC <- PC + 1} | |
uprom[106]:=$0601fff;{ testFR0 } uprom[113]:=$0601fff;{ testFR0 } | |
uprom[107]:=$0600fba;{ PC <- MAR } uprom[114]:=$0500f9a;{ PC <- AC } | |
uprom[108]:=$0508fff;{ PC <- PC + 1} | |
{JMP} {NOP} | |
uprom[115]:=$0600fab;{ MAR <- PC } uprom[119]:=$0508fff;{ uPC <- 0 } | |
uprom[116]:=$0600ffc;{ MBR <- M[MAR]} {PUSH} | |
uprom[117]:=$0610ce9;{ AC <- MBR+XR} uprom[125]:=$0600fab;{ MAR <- PC } | |
uprom[118]:=$0500f9a;{ PC <- AC } uprom[126]:=$0600ffc;{ MBR <- M[MAR]} | |
{POP} uprom[127]:=$06b0f49;{ AC <- GR4-1 } | |
uprom[120]:=$0600f4b;{ MAR <- GR4 } uprom[128]:=$0600f94;{ GR4 <- AC } | |
uprom[121]:=$0600ffc;{ MBR <- M[MAR]} uprom[129]:=$0600f4b;{ MAR <- GR4 } | |
uprom[122]:=$06a0f49;{ AC <- GR4+1 } uprom[130]:=$0610ce9;{ AC <- MBR-XR} | |
uprom[123]:=$0600f94;{ GR4 <- AC } uprom[131]:=$0e00f9c;{ MBR <- AC } | |
uprom[124]:=$0508fce;{ GR <- MBR } uprom[132]:=$0108fcf;{ M[MAR] <- MBR} | |
{CALL} {RET} | |
uprom[133]:=$0600fab;{ MAR <- PC } uprom[145]:=$0600f4b;{ MAR <- PC } | |
uprom[134]:=$0600ffc;{ MBR <- M[MAR]} uprom[146]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[135]:=$0610ce9;{ AC <- MBR+XR} uprom[147]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[136]:=$0e00f9c;{ MBR <- AC } uprom[148]:=$0e00f9c;{ MBR <- AC } | |
uprom[137]:=$06b0f49;{ AC <- GR4-1 } uprom[149]:=$0600fba;{ PC <- MAR } | |
uprom[138]:=$0600f94;{ GR4 <- AC } | |
uprom[139]:=$0600f4b;{ MAR <- GR4 } | |
uprom[140]:=$0608fff;{ PC <- PC + 1} | |
uprom[141]:=$0600fc9;{ AC <- MBR } | |
uprom[142]:=$0600fac;{ MBR <- PC } | |
uprom[143]:=$0200fcf;{ M[MAR] <- MBR} | |
uprom[144]:=$0500f9a;{ PC <- AC } | |
{JNC} {JC} | |
uprom[150]:=$0600fab;{ MAR <- PC } uprom[157]:=$0600fab;{ MAR <- PC } | |
uprom[151]:=$0600ffc;{ MBR <- M[MAR]} uprom[158]:=$0600ffc;{ MBR <- M[MAR]} | |
uprom[152]:=$0610ce9;{ AC <- MBR+XR} uprom[159]:=$0610ce9;{ AC <- MBR+XR} | |
uprom[153]:=$0600f9a;{ PC <- AC } uprom[160]:=$0608fff;{ PC <- PC + 1} | |
uprom[154]:=$0603fff;{ testFR2 } uprom[161]:=$0603fff;{ testFR2 } | |
uprom[155]:=$0600fba;{ PC <- MAR } uprom[162]:=$0500f9a;{ PC <- AC } | |
uprom[156]:=$0508fff;{ PC <- PC + 1} | |
uarom[$00]:=119; uarom[$01]:= 4; uarom[$02]:= 10; uarom[$03]:= 16; | |
uarom[$04]:= 20; uarom[$05]:= 27; uarom[$06]:= 34; uarom[$07]:= 41; | |
uarom[$08]:= 48; uarom[$09]:=119; uarom[$0A]:= 55; uarom[$0B]:= 61; | |
uarom[$0C]:= 68; uarom[$0D]:= 75; uarom[$0E]:= 82; uarom[$0F]:= 89; | |
uarom[$10]:= 96; uarom[$11]:=102; uarom[$12]:=109; uarom[$13]:=115; | |
uarom[$14]:=120; uarom[$15]:=125; uarom[$16]:=133; uarom[$17]:=145; | |
uarom[$18]:=150; uarom[$19]:=157; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure InitReg; | |
begin | |
GR0:=0; GR1:=0; GR2:=0; GR3:=0; GR4:=0; PC:=0; IR:=0; | |
MBR:=0; MAR:=0; AC:=0; FR[0]:=0; FR[1]:=0; FR[2]:=0; upc:=0; | |
loadgr0 :=0; loadgr1 :=0; loadgr2 :=0; loadgr3 :=0; loadgr4 :=0; | |
loadpc :=0; loadmar :=0; loadmbr :=0; loadir :=0; xgategr0:=0; | |
xgategr1:=0; xgategr2:=0; xgategr3:=0; xgategr4:=0; xgatepc :=0; | |
xgatemar:=0; xgatembr:=0; xgateir :=0; xgateac :=0; ygategr0:=0; | |
ygategr1:=0; ygategr2:=0; ygategr3:=0; ygategr4:=0; ygatepc :=0; | |
ygatemar:=0; ygatembr:=0; ygateir :=0; testfr0 :=0; testfr1 :=0; | |
setfr :=0; incpc :=0; alumode1:=0; alumode2:=0; alumode3:=0; | |
alumode4:=0; rnw :=0; strobe :=0; csmbr :=0; clrupc :=0; | |
incupc :=0; loadupc :=0; lload :=0; lgatex :=0; xgate0 :=0; | |
loadac :=0; testfr2 :=0; lgatey :=0; decmbr :=0; ygate0 :=0; | |
end; | |
{-----------------------------------------------------------------------------} | |
function hex2dec(i:hexadecimal):word; | |
var dec:array[0..3]of integer; | |
j:integer; | |
begin | |
for j:=0 to 4 do | |
case i[j] of | |
'0':dec[j]:= 0; '1':dec[j]:= 1; '2':dec[j]:= 2; '3':dec[j]:= 3; | |
'4':dec[j]:= 4; '5':dec[j]:= 5; '6':dec[j]:= 6; '7':dec[j]:= 7; | |
'8':dec[j]:= 8; '9':dec[j]:= 9; 'A':dec[j]:=10; 'a':dec[j]:=10; | |
'B':dec[j]:=11; 'b':dec[j]:=11; 'C':dec[j]:=12; 'c':dec[j]:=12; | |
'D':dec[j]:=13; 'd':dec[j]:=13; 'E':dec[j]:=14; 'e':dec[j]:=14; | |
'F':dec[j]:=15; 'f':dec[j]:=15; | |
end; | |
hex2dec:=(dec[0] * $1)+(dec[1] * $10)+(dec[2] * $100)+(dec[3] * $1000); | |
end; | |
{-----------------------------------------------------------------------------} | |
function alloc(i:hexadecimal):word; | |
begin | |
i[3]:=i[2];i[2]:=i[1];i[1]:=i[0];i[0]:='0'; | |
alloc:=hex2dec(i); | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure InitMem(fname:string); | |
var stext:text; | |
buf:hexadecimal; | |
MemC,temp:word; | |
etc:string; | |
i,n:integer; | |
c:char; | |
begin | |
assign(stext,fname); | |
reset(stext); | |
for MemC:=0 to MemSize-1 do M[MemC]:=0; | |
MemC:=0; | |
while not eof(stext) do | |
begin | |
read(stext,buf[3]); | |
read(stext,buf[2]); | |
read(stext,buf[1]); | |
read(stext,buf[0]); | |
readln(stext,etc); | |
if buf[3]=':'then | |
MemC:=alloc(buf) | |
else begin | |
temp:=hex2dec(buf); | |
writeln(temp:4,etc); | |
M[MemC]:=temp; | |
MemC:=MemC+1; | |
end; | |
end; | |
close(stext); | |
writeln('--- end of read ---'); | |
c:=readkey; | |
end; | |
{-----------------------------------------------------------------------------} | |
function bit(x:_25bit;digit:integer):_1bit; | |
var w:integer; | |
begin | |
w:=(x shr digit) and $00001; | |
if w=0 then bit:=0 else bit:=1; | |
end; | |
procedure initVar; | |
begin | |
hex_tbl[ 0]:='0'; hex_tbl[ 1]:='1'; hex_tbl[ 2]:='2'; hex_tbl[ 3]:='3'; | |
hex_tbl[ 4]:='4'; hex_tbl[ 5]:='5'; hex_tbl[ 6]:='6'; hex_tbl[ 7]:='7'; | |
hex_tbl[ 8]:='8'; hex_tbl[ 9]:='9'; hex_tbl[10]:='A'; hex_tbl[11]:='B'; | |
hex_tbl[12]:='C'; hex_tbl[13]:='D'; hex_tbl[14]:='E'; hex_tbl[15]:='F'; | |
end; | |
function ZeroAC:_1bit; | |
begin | |
if AC=0 then ZeroAC:=1 else ZeroAC:=0; | |
end; | |
function N(b:_1bit):_1bit; | |
begin | |
N:=(not(b) and $0001); | |
end; | |
function hex(x:_17bit):string; | |
var temp:string; | |
procedure conv(x:_17bit); | |
var t,k:_17bit; | |
begin | |
temp:=hex_tbl[x mod 16]+temp; | |
t:=(x div 16)and $1ffff; | |
if t<>0 then conv(t) ; | |
end; | |
begin | |
temp:=''; | |
conv((x and $1ffff)); | |
hex:=temp; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure decode; | |
var c,d:_25bit; | |
begin | |
c:=uprom[upc]; | |
lload :=N(bit(c, 0)) and (bit(c, 1)) and (bit(c, 2)) and (bit(c, 3)); | |
lgatex :=N(bit(c, 4)) and (bit(c, 5)) and (bit(c, 6)) and (bit(c, 7)); | |
lgatey :=N(bit(c, 8)) and (bit(c, 9)) and (bit(c,10)) and (bit(c,11)); | |
if lload =1 then c:=(c and $1fffff0)or(longint(IR and $0000f)); | |
if lgatex=1 then c:=(c and $1ffff0f)or(longint(IR and $000f0)); | |
if lgatey=1 then c:=(c and $1fff0ff)or(longint((IR and $0000f)shl 8)); | |
loadgr0r :=N(bit(c, 0)) and N(bit(c, 1)) and N(bit(c, 2)) and N(bit(c, 3)); | |
loadgr1r := (bit(c, 0)) and N(bit(c, 1)) and N(bit(c, 2)) and N(bit(c, 3)); | |
loadgr2r :=N(bit(c, 0)) and (bit(c, 1)) and N(bit(c, 2)) and N(bit(c, 3)); | |
loadgr3r := (bit(c, 0)) and (bit(c, 1)) and N(bit(c, 2)) and N(bit(c, 3)); | |
loadgr4r :=N(bit(c, 0)) and N(bit(c, 1)) and (bit(c, 2)) and N(bit(c, 3)); | |
loadpcr :=N(bit(c, 0)) and (bit(c, 1)) and N(bit(c, 2)) and (bit(c, 3)); | |
loadmarr := (bit(c, 0)) and (bit(c, 1)) and N(bit(c, 2)) and (bit(c, 3)); | |
loadmbrr :=N(bit(c, 0)) and N(bit(c, 1)) and (bit(c, 2)) and (bit(c, 3)); | |
loadirr :=N(bit(c, 0)) and N(bit(c, 1)) and N(bit(c, 2)) and (bit(c, 3)); | |
loadacr := (bit(c, 0)) and N(bit(c, 1)) and N(bit(c, 2)) and (bit(c, 3)); | |
xgategr0r:=N(bit(c, 4)) and N(bit(c, 5)) and N(bit(c, 6)) and N(bit(c, 7)); | |
xgategr1r:= (bit(c, 4)) and N(bit(c, 5)) and N(bit(c, 6)) and N(bit(c, 7)); | |
xgategr2r:=N(bit(c, 4)) and (bit(c, 5)) and N(bit(c, 6)) and N(bit(c, 7)); | |
xgategr3r:= (bit(c, 4)) and (bit(c, 5)) and N(bit(c, 6)) and N(bit(c, 7)); | |
xgategr4r:=N(bit(c, 4)) and N(bit(c, 5)) and (bit(c, 6)) and N(bit(c, 7)); | |
xgatepcr :=N(bit(c, 4)) and (bit(c, 5)) and N(bit(c, 6)) and (bit(c, 7)); | |
xgatemarr:= (bit(c, 4)) and (bit(c, 5)) and N(bit(c, 6)) and (bit(c, 7)); | |
xgatembrr:=N(bit(c, 4)) and N(bit(c, 5)) and (bit(c, 6)) and (bit(c, 7)); | |
xgateirr :=N(bit(c, 4)) and N(bit(c, 5)) and N(bit(c, 6)) and (bit(c, 7)); | |
xgateacr := (bit(c, 4)) and N(bit(c, 5)) and N(bit(c, 6)) and (bit(c, 7)); | |
xgate0r := (bit(c, 4)) and N(bit(c, 5)) and (bit(c, 6)) and N(bit(c, 7)); | |
ygategr0r:=N(bit(c, 8)) and N(bit(c, 9)) and N(bit(c,10)) and N(bit(c,11)); | |
ygategr1r:= (bit(c, 8)) and N(bit(c, 9)) and N(bit(c,10)) and N(bit(c,11)); | |
ygategr2r:=N(bit(c, 8)) and (bit(c, 9)) and N(bit(c,10)) and N(bit(c,11)); | |
ygategr3r:= (bit(c, 8)) and (bit(c, 9)) and N(bit(c,10)) and N(bit(c,11)); | |
ygategr4r:=N(bit(c, 8)) and N(bit(c, 9)) and (bit(c,10)) and N(bit(c,11)); | |
ygatepcr := (bit(c, 8)) and N(bit(c, 9)) and (bit(c,10)) and N(bit(c,11)); | |
ygatemarr:=N(bit(c, 8)) and (bit(c, 9)) and (bit(c,10)) and N(bit(c,11)); | |
ygatembrr:=N(bit(c, 8)) and N(bit(c, 9)) and (bit(c,10)) and (bit(c,11)); | |
ygateirr :=N(bit(c, 8)) and N(bit(c, 9)) and N(bit(c,10)) and (bit(c,11)); | |
ygate0r := (bit(c, 8)) and N(bit(c, 9)) and (bit(c,10)) and N(bit(c,11)); | |
testfr0r := (bit(c,12)) and N(bit(c,13)); | |
testfr1r :=N(bit(c,12)) and (bit(c,13)); | |
testfr2r := (bit(c,12)) and (bit(c,13)); | |
setfrr := (bit(c,14)); | |
incpcr := (bit(c,15)); | |
alumode1r:= (bit(c,16)); | |
alumode2r:= (bit(c,17)); | |
alumode3r:= (bit(c,18)); | |
alumode4r:= (bit(c,19)); | |
clrupcr := (bit(c,20)) and N(bit(c,21)); | |
incupcr :=N(bit(c,20)) and (bit(c,21)); | |
loadupcr := (bit(c,20)) and (bit(c,21)); | |
rnwr := (bit(c,22)); | |
strober :=N(bit(c,22)); | |
csmbrr := (bit(c,23)); | |
decmbrr := (bit(c,24)); | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure control(clk:integer); | |
begin | |
incpc:=0; loadgr0:=0; loadgr1:=0; loadgr2:=0; loadgr3:=0; loadgr4:=0; | |
loadpc:=0; loadmar:=0; loadmbr:=0; loadir:=0; setfr:=0; clrupc:=0; | |
incupc:=0; loadupc:=0; strobe:=0; decmbr:=0; loadac:=0; | |
case clk of | |
1: begin | |
if xgategr0r=1 then xgategr0:=1 else xgategr0:=0; | |
if xgategr1r=1 then xgategr1:=1 else xgategr1:=0; | |
if xgategr2r=1 then xgategr2:=1 else xgategr2:=0; | |
if xgategr3r=1 then xgategr3:=1 else xgategr3:=0; | |
if xgategr4r=1 then xgategr4:=1 else xgategr4:=0; | |
if xgatepcr =1 then xgatepc :=1 else xgatepc :=0; | |
if xgatemarr=1 then xgatemar:=1 else xgatemar:=0; | |
if xgatembrr=1 then xgatembr:=1 else xgatembr:=0; | |
if xgateirr =1 then xgateir :=1 else xgateir :=0; | |
if xgateacr =1 then xgateac :=1 else xgateac :=0; | |
if xgate0r =1 then xgate0 :=1 else xgate0 :=0; | |
if ygategr0r=1 then ygategr0:=1 else ygategr0:=0; | |
if ygategr1r=1 then ygategr1:=1 else ygategr1:=0; | |
if ygategr2r=1 then ygategr2:=1 else ygategr2:=0; | |
if ygategr3r=1 then ygategr3:=1 else ygategr3:=0; | |
if ygategr4r=1 then ygategr4:=1 else ygategr4:=0; | |
if ygatepcr =1 then ygatepc :=1 else ygatepc :=0; | |
if ygatemarr=1 then ygatemar:=1 else ygatemar:=0; | |
if ygatembrr=1 then ygatembr:=1 else ygatembr:=0; | |
if ygateirr =1 then ygateir :=1 else ygateir :=0; | |
if ygate0r =1 then ygate0 :=1 else ygate0 :=0; | |
if alumode1r=1 then alumode1:=1 else alumode1:=0; | |
if alumode2r=1 then alumode2:=1 else alumode2:=0; | |
if alumode3r=1 then alumode3:=1 else alumode3:=0; | |
if alumode4r=1 then alumode4:=1 else alumode4:=0; | |
if rnwr =1 then rnw :=1 else rnw :=0; | |
if csmbrr =1 then csmbr :=1 else csmbr :=0; | |
end; | |
3: begin | |
if incpcr =1 then incpc :=1; | |
if loadpcr =1 then loadpc :=1; | |
end; | |
5: begin | |
if loadgr0r =1 then loadgr0 :=1; | |
if loadgr1r =1 then loadgr1 :=1; | |
if loadgr2r =1 then loadgr2 :=1; | |
if loadgr3r =1 then loadgr3 :=1; | |
if loadgr4r =1 then loadgr4 :=1; | |
if loadmarr =1 then loadmar :=1; | |
if loadmbrr =1 then loadmbr :=1; | |
if loadirr =1 then loadir :=1; | |
if loadacr =1 then loadac :=1; | |
if strober =1 then strobe :=1; | |
end; | |
6: begin | |
if setfrr =1 then setfr :=1; | |
if decmbrr =1 then decmbr :=1; | |
end; | |
7: begin | |
if incupcr =1 then incupc :=1; | |
if clrupcr =1 then clrupc :=1; | |
if loadupcr =1 then loadupc :=1; | |
if testfr0r =1 then if FR[0]=0 then clrupc :=1; | |
if testfr1r =1 then if FR[1]=0 then clrupc :=1; | |
if testfr2r =1 then if FR[2]=0 then clrupc :=1; | |
if decmbrr =1 then if MBR =0 then incupc :=1; | |
end; | |
else ; | |
end | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _uprog; | |
begin | |
if incupc =1 then upc:=upc+1; | |
if clrupc =1 then upc:=0; | |
if loadupc=1 then upc:=uarom[(IR shr 8)and $00ff]; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _IR; | |
begin | |
if loadir=1 then IR:=BUS; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _register; | |
begin | |
if loadgr0=1 then GR0:=BUS; | |
if loadgr1=1 then GR1:=BUS; | |
if loadgr2=1 then GR2:=BUS; | |
if loadgr3=1 then GR3:=BUS; | |
if loadgr4=1 then GR4:=BUS; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _BUS; | |
begin | |
if xgategr0=1 then BUS:=GR0; | |
if xgategr1=1 then BUS:=GR1; | |
if xgategr2=1 then BUS:=GR2; | |
if xgategr3=1 then BUS:=GR3; | |
if xgategr4=1 then BUS:=GR4; | |
if xgatepc =1 then BUS:=PC ; | |
if xgatemar=1 then BUS:=MAR; | |
if xgatembr=1 then BUS:=MBR; | |
if xgateir =1 then BUS:=IR ; | |
if xgateac =1 then BUS:=(AC and $0ffff); | |
if xgate0 =1 then BUS:=0 ; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _PC; | |
begin | |
if loadpc=1 then PC:=BUS; | |
if incpc=1 then PC:=PC+1; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _memory; | |
begin | |
if loadmar=1 then MAR:=BUS; | |
if decmbr =1 then MBR:=MBR-1; | |
if rnw=0 then begin if strobe=1 then begin | |
M[MAR]:=BUS; | |
rwa:=MAR; | |
end ; | |
end; | |
if rnw=1 then begin | |
if (loadmbr=1)and(csmbr=1) then MBR:=BUS; | |
if (loadmbr=1)and(csmbr=0) then MBR:=M[MAR]; | |
end; | |
end; | |
{-----------------------------------------------------------------------------} | |
function SLA(Reg:_17bit):_17bit; | |
var num,flg:word; | |
begin | |
num:=(Reg shl 1)and $7fff; | |
flg:=(Reg and $8000); | |
SLA:=num or flg; | |
end; | |
function SRA(Reg:_17bit):_17bit; | |
var flg,num:word; | |
begin | |
num:=(Reg shr 1)and $3fff; | |
flg:=(Reg and $8000)or((Reg shr 1)and $4000); | |
SRA:=num or flg; | |
end; | |
function SLL(Reg:_17bit):_17bit; | |
begin | |
SLL:=Reg shl 1; | |
end; | |
function SRL(Reg:_17bit):_17bit; | |
begin | |
SRL:=Reg shr 1; | |
end; | |
function CPA(X:word;Y:word):_17bit; | |
{ Warning! Warning! Warning! } | |
{ This function is impossible to } | |
{ realize by hardwere.Depending } | |
{ on Softwere. } | |
var a,b:integer; | |
c:_17bit; | |
begin | |
if bit(x,15)=1 then a:=-(not(x)+1) else a:=x; | |
if bit(y,15)=1 then b:=-(not(y)+1) else b:=y; | |
if a>b then c:=$00001; | |
if a=b then c:=$00000; | |
if a<b then c:=$08000; | |
CPA:=c; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure _ALU; | |
var X,Y,mode:word; | |
begin | |
mode:=(alumode4 * 8)+(alumode3 * 4)+(alumode2 * 2)+(alumode1 * 1); | |
if xgategr0=1 then X:=GR0; if xgategr1=1 then X:=GR1; | |
if xgategr2=1 then X:=GR2; if xgategr3=1 then X:=GR3; | |
if xgategr4=1 then X:=GR4; if xgatepc =1 then X:=PC ; | |
if xgatemar=1 then X:=MAR; if xgatembr=1 then X:=MBR; | |
if xgateir =1 then X:=IR ; if xgate0 =1 then X:=0 ; | |
if ygategr0=1 then Y:=GR0; if ygategr1=1 then Y:=GR1; | |
if ygategr2=1 then Y:=GR2; if ygategr3=1 then Y:=GR3; | |
if ygategr4=1 then Y:=GR4; if ygatepc =1 then Y:=PC ; | |
if ygatemar=1 then Y:=MAR; if ygatembr=1 then Y:=MBR; | |
if ygateir =1 then Y:=IR ; if ygate0 =1 then Y:=0 ; | |
if loadac=1 then | |
case mode of | |
0:AC:=X; 1:AC:=X + Y; | |
2:AC:=X - Y; 3:AC:=X and Y; | |
4:AC:=X or Y; 5:AC:=X xor Y; | |
6:AC:=SLA(AC); 7:AC:=SRA(AC); | |
8:AC:=SLL(AC); 9:AC:=SRL(AC); | |
10:AC:=X + 1; 11:AC:=X - 1; | |
12:AC:=CPA(X,Y); | |
else ; | |
end; | |
if setfr=1 then begin | |
FR[0]:=ZeroAC; | |
FR[1]:=bit(AC,15); | |
FR[2]:=bit(AC,16); | |
end; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure InitDSP; | |
var x,y:byte; | |
i:word; | |
c:char; | |
begin | |
writeln(' ****** Meteor 1994 Hasegawa Press "Q" to abort. ******'); | |
write('+------------------- MEMORY --------------'); | |
writeln('---+--------- REGISTER -----------+'); | |
write('| 0000 0001 0002 0003 0004 0005 0006'); | |
writeln(' 0007| PC 0 FR 000 |'); | |
writeln('|0000: | GR0 0 MAR 0 |'); | |
writeln('|0008: | GR1 0 MBR 0 |'); | |
writeln('|0010: | GR2 0 AC 0 |'); | |
writeln('|0018: | GR3 0 BUS 0 |'); | |
writeln('|0020: | GR4 0 IR 0 |'); | |
writeln('|0028: |------------------------------|'); | |
writeln('|0030: |LD...01xg ST...02gx |'); | |
writeln('|0038: |LEA..03xg ADD..04xg |'); | |
writeln('|0040: |SUB..05xg AND..06xg |'); | |
writeln('|0048: |OR...07xg EOR..08xg |'); | |
writeln('|--------------------------------------------|CPL..0Axg SLA..0Bxg |'); | |
writeln('|0100: |SRA..0Cxg SLL..0Dxg |'); | |
writeln('|0108: |SRL..0Exg JPZ..0Fx? |'); | |
writeln('|0110: |JMI..10x? JNZ..11x? |'); | |
writeln('|0118: |JZE..12x? JNC..18x? |'); | |
writeln('|0120: |JC...19x? JMP..13x? |'); | |
writeln('|0128: |PUSH.14x? POP..15x? |'); | |
writeln('|0130: |CALL.16x? RET..17?? |'); | |
writeln('|0138: | x..XR r..GR ?..Do not care |'); | |
writeln('|0140: | 0:0000 1:0001 2:0010 |'); | |
writeln('|0148: | 3:0011 4:0100 NS:0101 |'); | |
write('+--------------------------------------------+------------------------------+'); | |
for i:=0 to $4f do begin | |
x:=(i mod 8)*5+7; | |
y:=(i div 8)+4; | |
gotoxy(x,y); | |
write(hex(M[i]):4); | |
end; | |
for i:=$100 to $14f do begin | |
x:=(i mod 8)*5+7; | |
y:=((i-$100) div 8)+15; | |
gotoxy(x,y); | |
write(hex(M[i]):4); | |
end; | |
end; | |
{-----------------------------------------------------------------------------} | |
procedure disp; | |
var x,y:byte; | |
c:char; | |
begin | |
if (rwa<$0150)and(rwa>$00ff)then begin | |
x:=(rwa mod 8)*5+7; | |
y:=((rwa-$100) div 8)+15; | |
gotoxy(x,y); | |
write(hex(M[rwa]):4); | |
end; | |
if rwa<$0050 then begin | |
y:=(rwa div 8)+4; | |
x:=(rwa mod 8)*5 + 7; | |
gotoxy(x,y); | |
write(hex(M[rwa]):4); | |
end; | |
gotoxy(54,3);writeln(hex(PC):4); | |
gotoxy(54,4);writeln(hex(GR0):4); | |
gotoxy(54,5);writeln(hex(GR1):4); | |
gotoxy(54,6);writeln(hex(GR2):4); | |
gotoxy(54,7);writeln(hex(GR3):4); | |
gotoxy(54,8);writeln(hex(GR4):4); | |
gotoxy(68,3);writeln(FR[2]:1,FR[1]:1,FR[0]:1); | |
gotoxy(67,4);writeln(hex(MAR):4); | |
gotoxy(67,5);writeln(hex(MBR):4); | |
gotoxy(66,6);writeln(hex(AC):5 ); | |
gotoxy(67,7);writeln(hex(BUS):4); | |
gotoxy(67,8);writeln(hex(IR):4 ); | |
end; | |
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++} | |
var clk,j:integer; | |
PC2:word; | |
c:char; | |
flg:boolean; | |
begin | |
Assign(Input,''); Reset(Input); | |
Assign(Output,''); Rewrite(Output); | |
TextCursor(NoDispCursor); | |
ClrScr; | |
InitMem('bootstrp.rom'); | |
InitVar; | |
InitDSP; | |
Initup; | |
InitReg; | |
PC2:=2; | |
flg:=true; | |
rwa:=$ffff; | |
while flg do begin | |
for clk:=0 to 7 do begin | |
decode; | |
control(clk); | |
_uprog; | |
_PC; | |
_IR; | |
_memory; | |
_BUS; | |
_register; | |
_ALU; | |
if PC2<>PC then begin | |
disp; | |
PC2:=PC; | |
c:=readkey; | |
if (c='Q')or(c='q') then flg:=false; | |
end; | |
end; | |
end; | |
ClrScr; | |
TextCursor(DispCursor); | |
end. | |
{+++++++++++++++++++++++++++++ end of meteor.pas ++++++++++++++++++++++++++++++} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.ハードウェアMETEORの仕様 | |
1.1 処理装置 | |
(1)METEORは,1語16ビットの計算機であって,アクセスできるアドレス | |
は0番地から640番地までである。 | |
(2)1語のビット構成は,次のとおりである。 | |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ ビット | |
・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ 番号 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
↑ | |
└・・・・・ 符号(負:1,非負:0) | |
(3)数値は16ビットの2進数により表現する。負数は,2の補数表記である。 | |
(4)制御方式は逐次制御で,2語長の命令語をもつ。 | |
(5)レジスタとして,GR(16ビット),PC(16ビット),FR(3ビット | |
)をもつ。 | |
GR(汎用レジスタ,general register)は5個あり,汎用レジスタ0番から | |
4番までとする。この5個のレジスタは,算術,論理,比較,シフト演算など | |
に用いる。このうち,1番から4番までのレジスタは,指標レジスタ(index | |
register)としても用いる。また4番のレジスタは,更にスタックポインタ( | |
stack pointer)として用いる。 | |
スタックポインタは,アドレスの最上段(stack top)のアドレスを保持し | |
ているレジスタである。 | |
PC(プログラムカウンタ,program counter)は,実行中の命令語の先頭 | |
アドレスを保持し,命令の実行が終わると,次に実行する命令語の先頭アドレ | |
スが設定される。一般に,命令の実行が終わるとPCに2がアドレス加算(注 | |
)され,分岐,コール,リターン命令の場合は,新たに分岐先のアドレスが設 | |
定される。 | |
(注) アドレス加算:被演算データを符号のない数値とみなし,その和を65 | |
536で割った剰余(和の下位16ビット)を値とする。アドレス減算もこれ | |
に準じた定義とする。 | |
FR(フラグレジスタ,flag register )はロードアドレス命令及び算術, | |
論理,シフトの各演算命令の実行の結果,GRに設定されたデータが負,零, | |
正のいずれであるかの情報および桁溢れ(キャリー),桁落ち(ボロー)の情 | |
報,又は比較演算命令の実行により得られた,二数間の大小関係の情報を保持 | |
する。 | |
すなわち,実行結果により,FRは次の表のとおり設定される(ただし,比 | |
較については,「1.2(4)の比較演算命令」参照)。 | |
右の表で,負はGRの符号ビットが1,・・・・・・・・・・・・・・・・ | |
零はGRの全ビットが0,正は符号ビット・ ・GRに設定されたデータ・ | |
が0で,かつ零でないデータをいう。 ・・・・・・・・・・・・・・・・ | |
FRの第0(左端の)ビットはGRから・ ・ 負 ・ 零 ・ 正 ・ | |
のボローを示し,第1ビットはGRの符号・FRの値・?10 ・?01 ・?00 ・ | |
を示し,第2ビットはGRが0か否かを示・・・・・・・・・・・・・・・・ | |
す。 ・・・・・・・・・・・・・・・・ | |
FRの値は,条件付き分岐命令で参照す・ ・ボローあり・ボローなし・ | |
る。 ・・・・・・・・・・・・・・・・ | |
その他の命令によって,FRの値は変更・FRの値・ 1?? ・ 0?? ・ | |
されない。 ・・・・・・・・・・・・・・・・ | |
(6)命令語の構成 | |
2語長の命令語をもつ。その構成は別に定義する。 | |
(7)命令の表記 | |
各命令の説明には,次の表記法を用いる。 | |
GR GRの値を番号とする汎用レジスタ(ただし,0≦GR≦4) | |
XR XRの値を番号とする汎用レジスタ(ただし,1≦XR≦4) | |
SP スタックポインタ(汎用レジスタ4番) | |
adr ラベル名(ラベル名に対応する番地を示す)又は10進定 | |
数(ただし,ー32768≦adr≦65535 とする。adrはアドレス | |
として0~65535の値をもつが,32768~655 | |
35の値を負の10進定数で記述することもできる。) | |
有効アドレス adrとXRの内容とのアドレス加算値又はその値が示す番地 | |
(X) X番地の内容,Xがレジスタの場合はレジスタの内容 | |
[ ] [ ]に囲まれた部分は,省略可能であることを示す。 | |
XRを省略した場合は,指標レジスタによる修飾を行わない | |
1.2 命令 | |
命令及びその機能を示す。命令は,アセンブラの表記法で記述する。 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ ・ 書き方 ・ ・ | |
・ ・・・・・・・・・・・ ・ | |
・ 命令 ・命令・ オペランド ・ 命令の説明 ・ | |
・ ・コード・ ・ ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(1)ロード,ストア命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・LoaD ・LD GR,adr[,XR] ・(有効アドレス)をGRに設定する。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・STore ・ST GR,adr[,XR] ・(GR)を有効アドレスが示す ・ | |
・ ・ ・番地に格納する。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(2)ロードアドレス命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・Load Effective Address ・LEA GR,adr[,XR] ・有効アドレスをGRに設定する。 ・ | |
・ ・ ・GRの値によりFRを設定する。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(3)算術,論理演算命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ADD arithmetic ・ADD GR,adr[,XR] ・(GR)と(有効アドレス)に,指定し ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・た演算を施し,結果をGRに設定・ | |
・SUBtract arithmetic ・SUB GR,adr[,XR] ・する。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・なお,算術減算では,(GR)から・ | |
・AND ・AND ・(有効アドレス)を減算する。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・演算結果によりFRを設定する。・ | |
・OR ・OR ・ ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・ ・ | |
・Exclusive OR ・EOR ・ ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(4)比較演算命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ ・ ・(GR)と(有効アドレス)の算術比較 ・ | |
・ ・ ・又は論理比較を行い,比較結果・ | |
・ComPare Arithmetic ・CPA GR,adr[,XR] ・によりFRに次の値を設定する。・ | |
・ ・ ・・・・・・・・・・・・・・・・ | |
・ ・ ・・ 比較結果 ・ FR ・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ ・ ・・(GR)>(有効アドレス)・ 00 ・・ | |
・ ・ ・・・・・・・・・・・・・・・・ | |
・ComPare Logical ・CPL GR,adr[,XR] ・・(GR)=(有効アドレス)・ 01 ・・ | |
・ ・ ・・・・・・・・・・・・・・・・ | |
・ ・ ・・(GR)<(有効アドレス)・ 10 ・・ | |
・ ・ ・・・・・・・・・・・・・・・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(5)シフト演算命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ ・ ・(GR)を符号を除き有効アドレスで ・ | |
・Shift Left Arithmetic ・SLA GR,adr[,XR] ・指定したビット数だけ左又は右に・ | |
・ ・ ・シフトする。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・シフトの結果,空いたビット位置に ・ | |
・ ・ ・は,左シフトのときは0,右シフトの ・ | |
・Shift Right Arithmetic ・SRA GR,adr[,XR] ・ときは符号と同じものが入る。・ | |
・ ・ ・シフトの結果によりFRを設定する。・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・ ・ ・(GR)を符号を含み,有効アドレス ・ | |
・Shift Left Logical ・SLL GR,adr[,XR] ・で指定したビット数だけ左又は右・ | |
・ ・ ・にシフトする。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・シフトの結果,空いたビット位置に ・ | |
・ ・ ・は0が入る。 ・ | |
・Shift Left Logical ・SRL GR,adr[,XR] ・シフトの結果によりFRを設定する。・ | |
・ ・ ・ ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(6)分岐命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・Jump on Plus or Zero ・JPZ GR,adr[,XR] ・FRの値により,有効アドレスに分 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・岐する。分岐しないときは次の・ | |
・Jump on MInus ・JMI GR,adr[,XR] ・命令に進む。 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・ 命令|分岐するときのFRの値 ・ | |
・Jump on Non Zero ・JNZ GR,adr[,XR] ・ JPZ | 00,01 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・ JMI | 10 ・ | |
・Jump on Zero ・JZE GR,adr[,XR] ・ JNZ | 00,10 ・ | |
・ ・ ・ JZE | 01 ・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・unconditional JuMP ・JMP GR,adr[,XR] ・無条件に有効アドレスに分岐する。・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(7)スタック操作命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
(8)コール,リターン命令 | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ | |
1.3 文字の組 | |
METEORはJIS X0201ローマ字・片仮名用8単位符号で規定する文字 | |
の組をもつ。 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.METEOR詳細 | |
2.1 起動 | |
(1)ROMの読み込み | |
meteorは起動後、カレントディレクトリの「BOOTSTRP.ROM」を読み込み、その内容 | |
をメモリに格納する。 | |
(2)ファイルの形式 | |
BOOTSTRP.ROMのファイル形式を以下に示す。 | |
+-------------- ・・・ -+ | |
|code:コメント ・・・ | | |
|addr:コメント ・・・ | | |
|code:コメント ・・・ | | |
|addr:コメント ・・・ | | |
+-------------- ・・・ -+ | |
各行には機械語(16進4桁)を書く。5文字目以降は無視される。 | |
ファイルの先頭から順に、1行目が0番地、2行目が1番地...と格納されていく。 | |
2.2 マイクロコード | |
(1)信号 | |
25ビットのマイクロコードの各信号を以下に示す。 | |
0 LdSel1 LdSel4 3 2 1の順に | |
1 LdSel2 0:GR0 1:GR1 2:GR2 3:GR3 4:GR4 | |
2 LdSel3 5:Zero 6: 7: 8:IR 9:AC | |
3 LdSel4 A:PC B:MAR C:MBR D: E:Load F:No Selection | |
4 xGSel1 xGSel4 3 2 1の順に | |
5 xGSel2 0:GR0 1:GR1 2:GR2 3:GR3 4:GR4 | |
6 xGSel3 5:Zero 6: 7: 8:IR 9:AC | |
7 xGSel4 A:PC B:MAR C:MBR D: E:Load F:No Selection | |
8 yGSel1 yGSel4 3 2 1の順に | |
9 yGSel2 0:GR0 1:GR1 2:GR2 3:GR3 4:GR4 | |
10 yGSel3 5: 6: 7: 8:IR 9: | |
11 yGSel4 A:PC B:MAR C:MBR D: E:Load F:No Selection | |
12 Test0 Test1 0の順に | |
13 Test1 1:FR0 2:FR1 3:FR2 | |
14 SetFR | |
15 IncPC | |
16 ALUMode1 ALUMode4 3 2 1 の順に | |
17 ALUMode2 0:Pass 1:ADD 2:SUB 3:AND 4:OR | |
18 ALUMode3 5:EOR 6:SLA 7:SRA 8:SLL 9:SRL | |
19 ALUMode4 A:Inc B:Dec C:CPA | |
20 uCTR1 uCTR2 1 の順に | |
21 uCTR2 0:NOP 1:Clr 2:Inc 3:Load | |
22 R/nW 0:Write 1:else | |
23 CSMBR 0:Memory 1:Reg. | |
24 DecMBR MBR <- MBR-1,If MBR=0 then clrupc <- 1 | |
(2)説明 | |
ビット3、2、1、0が1110となったときは、IRの下位4ビットがLdSel信 | |
号となる。同様に、ビット7、6、5、4ならIRのビット7、6、5、4が | |
xGSel信号、ビット11、10、9、8ならIRの下位4ビットがyGSelとなる | |
2.3 命令と機械語の対応 | |
以下に各命令と機械語の対応を示す。 | |
命令 オペランド 機械語 | |
LD GR,adr[,XR] 01xg adr | |
ST GR,adr[,XR] 02gx adr | |
LEA GR,adr[,XR] 03xg adr | |
ADD GR,adr[,XR] 04xg adr | |
SUB GR,adr[,XR] 05xg adr | |
AND GR,adr[,XR] 06xg adr | |
OR GR,adr[,XR] 07xg adr | |
EOR GR,adr[,XR] 08xg adr | |
CPA GR,adr[,XR] | |
CPL GR,adr[,XR] 0Axg adr | |
SLA GR,adr[,XR] 0Bxg adr | |
SRA GR,adr[,XR] 0Cxg adr | |
SLL GR,adr[,XR] 0Dxg adr | |
SRL GR,adr[,XR] 0Exg adr | |
JPZ adr[,XR] 0Fx* adr | |
JMI adr[,XR] 10x* adr | |
JNZ adr[,XR] 11x* adr | |
JZE adr[,XR] 12x* adr | |
JNC adr[,XR] 18x* adr | |
JC adr[,XR] 19x* adr | |
JMP adr[,XR] 13x* adr | |
PUSH adr[,XR] 14x* adr | |
POP GR 15*r **** | |
CALL adr[,XR] 16x* adr | |
RET 17** **** | |
g .. GR GR0:0 GR1:1 GR2:2 GR3:3 GR4:4 | |
x .. XR GR1:1 GR2:2 GR3:3 GR4:4 NoSelection:5 | |
* .. Don't care. | |
命令はすべて2語長 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment