Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0053/cmls.bas
There are 2 other files named cmls.bas in the archive. Click here to see a list.
100 REM SIMULATION OF CARDIAC MACHINE LANGUAGE-PDP10 VERSION
105 REM WRITTEN FOR DEC PDP-10 VERSION 17 BASIC.
110 REM M:ACCUMULATOR
111 REM P:PROGRAM OR INSTRUCTION COUNTER
112 REM C: OPCODE WITH SIGN
113 REM D: ADDRESS OPERAND-ALWAYS POSITIVE
114 REM A: NAME OF MEMORY AREA
115 REM COPYRIGHT 1972 STATE UNIVERSITY OF NEW YORK
116 REM CARDIAC WAS DESIGNED AT BELL LABORATORIES
117 REM THIS SIMULATION PROGRAMMED BY S. HOLLANDER
118 REM LATEST REVISION 9-5-72
119 DIMN3(12),N(2),A(99)
120 FORZ=1TO98
125 LETA(Z)=0
130 NEXTZ
135 LETA(0)=1
140 LETA(99)=800
160 PRINT" ","CARDIAC MACHINE LANGUAGE SIMULATION"
165 PRINT
170 PRINT"WHAT IS THE NAME OF YOUR BACKUP FILE";
175 INPUTB$
180 PRINT
185 REM P2:OPTIONAL CELL DEPOSIT COUNTER
190 LETP2=0
195 LETP2=P2+1
200 IFP2=99THEN190
205 PRINT"*("P2")";
206 LETP3=0
210 INPUTC$
211 IFC$="STEP ALL"THEN1135
215 IFC$="STEP"THEN1135
216 REM G: 1 IF IN STEP MODE
220 LETG=0
225 IFC$="H"THEN600
230 IFC$="RUN"THEN1105
235 IFC$="STOP"THEN2000
240 IFC$="CALL"THEN740
245 IFC$="SAVE"THEN700
265 REM
270 REM N(X):NUMBER X FROM INPUT
280 REM N3(X):ASCII CHAR STORAGE
285 LETN(1)=0
290 LETN(2)=0
295 IFLEN(C$)<12THEN310
300 PRINT"?TYPE H FOR HELP"
305 GOTO205
310 CHANGE C$TON3
315 IFN3(0)=0THEN205
320 REM M1: IF N(X) IS TO BE NEGATIVE, M1 WILL BE 1
325 LETM1=0
330 REM X:CURRENT# (1 OR 2)
335 LETX=1
340 FORZ=1TON3(0)
345 REM SPACE
350 IFN3(Z)=32THEN476
355 REM +
360 IFN3(Z)=43THEN476
365 REM :
370 IFN3(Z)=58THEN445
375 REM -
380 IFN3(Z)<>45 THEN420
385 REM ITS NEGATIVE, SET M1
390 LETM1=1
395 GOTO476
410 REM DIGIT??(NO MEANS ILLEGAL)
420 IFABS(N3(Z)-52.5)<=4.5THEN430
425 IF(Z-1)+(N3(Z)-69)=0THEN476
426 GOTO300
430 LETN(X)=N(X)*10
435 LETN(X)=N(X)+N3(Z)-48
440 GOTO476
445 IFM1=0THEN470
450 REM MAINTAIN MINUS SIGN
455 LETN(X)=N(X)*-1
460 LETM1=0
465 REM INC NUMBER COUNT. - MAX OF 2 NUMBERS
470 LETX=X+1
475 IFX=3THEN300
476 NEXTZ
477 REM
480 IFM1=0THEN490
485 LETN(X)=N(X)*-1
490 IFN3(1)=69THEN850
495 REM HOW MANY NUMBERS TYPED?
500 IFX=2THEN525
505 IFABS(N(1))>999THEN550
510 LETA(P2)=N(1)
515 GOTO195
520 REM LEGAL ADDR?
525 IFABS(N(1)-49.5)<=48.5THEN545
530 PRINT"BAD ADDRESS"
535 PRINT
540 GOTO205
545 IFABS(N(2))<999THEN560
550 PRINT"BAD CONTENTS"
555 GOTO535
560 LETP2=N(1)
565 LETA(P2)=N(2)
570 GOTO195
575 REM
600 PRINT
605 PRINT"YOU MAY TYPE ONE OF THE FOLLOWING COMMANDS:"
610 PRINT
615 PRINT"RUN","TO RUN THE PROGRAM NOW IN MEMORY"
620 PRINT"E","TO EXAMINE THE CONTENTS OF MEMORY"
625 PRINT"STEP","TO STEP THROUGH MEMORY ONE INSTRUCTION AT A TIME"
627 PRINT"STEP ALL","SAME AS STEP BUT CONTINUES AFTER INSTRUCTION"
630 PRINT"CALL","TO CALL A SAVED PROGRAM INTO MEMORY"
635 PRINT"SAVE","TO SAVE MEMORY UNDER A FILE NAME ON DISK"
640 PRINT"STOP","TO STOP THIS SIMULATOR"
645 PRINT"H","TO GET THIS MESSAGE"
650 PRINT
660 GOTO205
670 REM
695 REM SAVE
700 GOSUB 800
705 SCRATCH :2
706 REM THE FOLLOWING IS SLOW AND INEFFICIENT, BUT...WHAT COULD I DO?
710 FORZ=1TO98
715 WRITE:2:A(Z)
720 NEXTZ
725 GOTO205
730 REM
735 REM CALL
740 GOSUB800
745 RESTORE:2
750 FORZ=1TO98
755 READ:2:N
760 IFABS(N)<=999THEN775
765 PRINT"BAD FILE"
770 GOTO205
775 LETA(Z)=N
780 NEXTZ
785 GOTO205
790 REM
795 REM NAME SUBROUTINE
800 PRINT"WHAT IS THE NAME OF THE FILE";
805 INPUTD$
810 FILE:2:D$+"%"
815 RETURN
820 REM
850 LETC2=N(1)
855 LETC1=N(2)
860 IFC1>0THEN875
865 LETC1=C2
870 REM C2: LOWER LIMIT, C1: UPPER LIMIT
875 IFC1<C2THEN890
880 IFC2<0THEN890
885 IFC1<=99THEN900
890 PRINT"ILLEGAL ADDRESSES"
895 GOTO205
900 PRINT
905 IFC1-C2<6THEN925
910 PRINT"ADDRESS","CONTENTS"
915 PRINT"-------","--------"
920 PRINT
925 FORZ=C2TOC1
930 PRINTZ;
935 LETL=14
940 LETR=A(Z)
945 GOSUB 1410
950 PRINT
955 NEXTZ
960 PRINT
965 PRINT
970 GOTO205
975 REM
1100 REM RUN
1105 LETZ=0
1110 FILE:2:B$+"%"
1111 REM THE FOLLOWING IS SLOW AND INEFFICIENT, BUT WHAT COULD I DO?
1115 FORZ=1TO98
1120 WRITE:2:A(Z)
1125 NEXTZ
1130 GOTO1140
1135 IFG>0THEN1340
1140 PRINT"INPUT THE STARTING ADDRESS";
1145 INPUTP
1150 LETM=0
1155 LETV=0
1160 IFP<0THEN1205
1165 IFP>99THEN1205
1170 IFP<>INT(P)THEN1205
1175 IFG>0THEN1210
1180 IFC$="RUN"THEN1210
1185 LETG=1
1195 PRINT" CA   PC    I    AC"
1200 GOTO 1215
1205 PRINT"BAD STARTING ADDRESS"
1206 GOTO205
1210 PRINT"START"
1215 PRINT
1220 GOTO1340
1225 IFC$="RUN"THEN1340
1230 LETL=0
1235 LETR=N1
1240 GOSUB1410
1245 LETR=P
1255 GOSUB1410
1260 LETR=R1
1265 GOSUB1410
1270 LETR=M
1275 ONSGN(R)+2GOTO1280,1295,1305
1280 PRINT" -";
1285 LETR=ABS(R)
1290 GOTO1310
1295 PRINT"  0000";
1300 GOTO1330
1305 PRINT" +";
1310 LETN=INT(R/1E3+.0005)
1315 PRINTCHR$(48+N);
1320 LETR=R-N*1E3
1325 GOSUB1455
1330 PRINT
1331 IFP3=1THEN205
1332 IFC$="STEP ALL"THEN1340
1335 GOTO205
1336 REM BEGIN EXECUTION CYCLE HERE
1340 LETR1=A(P)
1345 LETN1=P
1349 REM M(AC) CAN BE 4 DIGITS AT MOST
1350 LETM=M-SGN(M)*INT(ABS(M*1E-4))*1E4
1355 IFR1>=0THEN1375
1360 PRINT"BAD INSTRUCTION";INT(R*.01);"AT LOCATION";P
1365 PRINT
1370 GOTO1940
1375 LETC=INT(R1*.01+.005)
1380 LETD=R1-C*100
1385 LETP=P+1
1390 ONC+1GOTO1500,1600,1630,1660,1700,1750,1800,1850,1880,1920
1400 REM PRINTNUMBER SUBROUTINE
1405 REM L: TAB MARKER
1410 PRINTTAB(L);
1415 LETL=L+5
1420 ONSGN(R)+2GOTO1425,1440,1450
1425 PRINT"-";
1430 LETR=ABS(R)
1435 GOTO1455
1440 PRINT" 000";
1445 RETURN
1450 PRINT"+";
1455 LETR=INT(R+.005)
1460 LETN=INT(R/100+.005)
1465 PRINTCHR$(N+48);
1470 LETR=R-N*100
1475 LETN=INT(R/10+.005)
1480 PRINTCHR$(N+48);
1485 PRINTCHR$(48+R-N*10);
1490 RETURN
1495 REM
1496 REM
1500 REM OP CODE ZERO - INPUT
1505 INPUTN
1510 IFABS(N)>999THEN1520
1515 IFN=INT(N)THEN1530
1520 PRINT"  BAD INPUT VALUE - TRY AGAIN"
1525 GOTO1505
1530 IFN=0THEN1930
1535 IFD=0THEN1545
1540 IFD<>99THEN1560
1545 LETZ$="INPUT"
1550 PRINT"ATTEMPT TO "Z$" INTO LOCATION";D;"AT";P-1
1555 GOTO1940
1560 LETA(D)=N
1565 GOTO1225
1570 REM
1600 REM OPCODE ONE - CLEAR AND ADD
1605 LETM=A(D)
1610 GOTO1225
1615 REM
1630 REM OPCODE TWO - ADD
1635 LETM=M+A(D)
1640 GOTO1225
1645 REM
1660 REM OPCODE THREE - TEST AC CONTENTS
1665 IFM>=0THEN1225
1670 LETP=D
1675 GOTO1225
1680 REM
1700 REM OPCODE FOUR - SHIFT L THEN R
1705 LETL=INT(D/10+.5)
1710 LETR=D-L*10
1715 LETM=M*10^L
1720 LETM=M-SGN(M)*INT(ABS(M*1E-4))*1E4
1725 LETM=SGN(M)*INT(ABS(M/10^R)+.00005)
1730 GOTO1225
1735 REM
1750 REM OPCODE FIVE - OUTPUT
1755 LETL=0
1760 LETR=A(D)
1765 GOSUB1410
1770 PRINT
1775 GOTO 1225
1780 REM
1800 REM OPCODE SIX - STORE
1805 IF(D-99)*D<0THEN1820
1810 LETZ$="STORE"
1815 GOTO1550
1820 LETA(D)=M-SGN(M)*INT(ABS(M*1E-3))*1E3
1825 GOTO1225
1830 REM
1850 REM OPCODE SEVEN - SUBTRACT
1855 LETM=M-A(D)
1860 GOTO1225
1865 REM
1880 REM OPCODE EIGHT - JUMP
1885 LETA(99)=800+P
1890 LETP=D
1895 GOTO1225
1900 REM
1920 REM OPCODE NINE - HALT OR TEST AC OVERFLOW
1925 IFD>0THEN1955
1930 PRINT
1935 PRINT"HALT AT LOCATION";P-1
1940 LETP2=1
1942 LETP3=1
1943 LETG=0
1945 PRINT" CA   PC    I    AC"
1950 GOTO1230
1955 IFABS(M)<1E3THEN1225
1960 LETP=D
1965 GOTO1225
1970 REM
2000 END