home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
asic
/
alu
/
alu_demo.asi
next >
Wrap
Text File
|
1991-05-04
|
6KB
|
341 lines
REM ASIC ALU LIBRARY DEMONSTRATION
REM (c) May,1991 Steve Almond
REM
REM WARNING!! Compile this from the command line ONLY.(asicc alu-demo.asi)
REM
MAIN:
cls
locate 2,20
color 4,7
print "ASIC ALU Library Demonstration"
locate 3,22
print "(c) May,1991 Steve Almond"
color 7,0
print " "
print " "
print "This will demonstrate the actions of the ALU-LIB functions-NOT:,OR:,";
print "AND:,"
print "XOR:,SHIFTRIGHT:,RINGSHIFTRIGHT:,SHIFTLEFT:,RINGSHIFTLEFT:."
b$=" "
randomize
for k=0 to 7
gosub WAITFORKEY:
int1=rnd(0)
int2=rnd(0)
gosub PRINTRESULT:
next k
color 2,0
locate 22,0
print "Press 'z' to run again. Any other key to end."
gosub WAITFORKEY:
if c$="z" then MAIN:
end
WAITFORKEY:
color 4,0
locate 23,0
print "Press any key to continue."
KEY:
c$=inkey$
if c$="" then KEY:
return
PRINTRESULT:
if k>0 then NEXT1:
d$=" NOT:-if bit=1 then bit=0.If bit=0 then bit=1."
goto PNUM:
NEXT1:
if k>1 then NEXT2:
d$=" OR:-(1 or 1)=1,(1 or 0)=1,(0 or 1)=1,(0 or 0)=0."
goto PNUM:
NEXT2:
if k>2 then next3:
d$=" AND:-(1 and 1)=1,(1 and 0)=0,(0 and 1)=0,(0 and 0)=0."
goto PNUM:
next3:
if k>3 then next4:
d$=" XOR:-(1 xor 1)=0,(1 xor 0)=1,(0 xor 1)=1,(0 xor 0)=0."
goto PNUM:
next4:
if k>4 then next5:
d$=" SHIFTRIGHT:=number shifted right nbits, 0 to msb."
goto PNUM:
next5:
if k>5 then next6:
d$=" RINGSHIFTRIGHT:=number shifted right nbits, lsb to msb."
goto PNUM:
next6:
if k>6 then next7:
d$=" SHIFTLEFT:=number shifted left nbits, 0 to lsb."
goto PNUM:
next7:
d$=" RINGSHIFTLEFT:=number shifted left nbits, msb to lsb."
PNUM:
acc2=int1
locate 10,0
print b$;
print " "
print b$
print b$
print b$
locate 10,0
print "The current function is";
color 4,7
print d$
color 7,0
gosub mnum:
print "=INT1=";
print int1
opcode=k
if k=0 then res:
if k>3 then shf:
acc2=int2
gosub mnum:
print "=INT2=";
print int2
goto res:
shf:
int2=1
for j=1 to 15
locate 12,0
color 7,0
res:
gosub ALU:
acc2=int1
gosub mnum:
print "=result=";
print int1
print "^ ^"
print "msb lsb"
print b$
if k < 4 then DONE:
color 5,0
print "INT1 shifted ";
print j;
print " bits"
color 3,0
locate 22,0
print "'n' to continue shifting."
gosub WAITFORKEY:
locate 22,0
print b$
if c$="n" then nodone:
j=15
nodone:
next j
DONE:
return
mnum:
acc3=15
d$=""
nmloop:
acc1=zbit(acc3,acc2)
if acc1=0 then nextm:
d$=d$+"1"
goto nextm1:
nextm:
d$=d$+"0"
nextm1:
acc3=acc3-1
if acc3 > -1 then nmloop:
print d$;
return
ALU:
if opcode=0 then NOT:
if opcode=1 then OR:
if opcode=2 then AND:
if opcode=3 then XOR:
if opcode=4 then SHIFTRIGHT:
if opcode=5 then RINGSHIFTRIGHT:
if opcode=6 then SHIFTLEFT:
if opcode=7 then RINGSHIFTLEFT:
return
NOT:
acc1=varptr(int1)
code 83
code 137
code 195
code 139
code 7
code 247
code 208
code 137
code 7
code 91
return
OR:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=varptr(int2)
code 83
code 82
code 137
code 195
code 139
code 23
code 139
code 30
code 3
code 1
code 139
code 7
code 9
code 208
code 137
code 7
code 90
code 91
return
AND:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=varptr(int2)
code 83
code 82
code 137
code 195
code 139
code 23
code 139
code 30
code 3
code 1
code 139
code 7
code 33
code 208
code 137
code 7
code 90
code 91
return
XOR:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=varptr(int2)
code 83
code 82
code 137
code 195
code 139
code 23
code 139
code 30
code 3
code 1
code 139
code 7
code 49
code 208
code 137
code 7
code 90
code 91
return
SHIFTRIGHT:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=int2
code 83
code 81
code 136
code 193
code 139
code 30
code 3
code 1
code 139
code 7
code 211
code 232
code 137
code 7
code 89
code 91
return
RINGSHIFTRIGHT:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=int2
code 83
code 81
code 136
code 193
code 139
code 30
code 3
code 1
code 139
code 7
code 211
code 200
code 137
code 7
code 89
code 91
return
SHIFTLEFT:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=int2
code 83
code 81
code 136
code 193
code 139
code 30
code 3
code 1
code 139
code 7
code 211
code 224
code 137
code 7
code 89
code 91
return
RINGSHIFTLEFT:
acc1=varptr(int1)
code 163
code 3
code 1
acc1=int2
code 83
code 81
code 136
code 193
code 139
code 30
code 3
code 1
code 139
code 7
code 211
code 192
code 137
code 7
code 89
code 91
return