home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
asic
/
alu
/
alu_lib.asi
< prev
next >
Wrap
Text File
|
1991-05-04
|
5KB
|
244 lines
REM ASIC ALU LIBRARY
REM (c) May,1991 Steve Almond
REM Call as 'gosub ALU:', _opcode meaning_
REM with 'opcode'=0,1,2,3,4,5,6,7 {0=NOT |
REM Call with 'int1' and 'int2' as |1=OR |
REM the integers to operate |2=AND |
REM on for OR,AND,XOR. If |3=XOR |
REM a NOT then only 'int1' |4=SHIFTRIGHT |
REM must be supplied. If a |5=RINGSHIFTRIGHT|
REM shift operation then |6=SHIFTLEFT |
REM 'int2' must hold the |7=RINGSHIFTLEFT |
REM number of bit positions ----------------
REM to shift (1-15).
REM Results are returned in 'int1';'opcode' and 'int2' are returned
REM unchanged.
REM
REM OPERATION: #bits: OPERANDS: ACTIONS:
REM NOT | |int1 |int1=not int1
REM OR | |int1,int2|int1=int1 or int2
REM AND | |int1,int2|int1=int1 and int2
REM XOR | |int1,int2|int1=int1 xor int2
REM SHIFTRIGHT |1 to 15|int1,int2|int1=shft int1 rgt int2 bits,0 to msb
REM RNGSHFTRGHT|1 to 15|int1,int2|int1=shft int1 rgt int2 bits,lsb to msb
REM SHIFTLEFT |1 to 15|int1,int2|int1=shft int1 lft int2 bits,0 to lsb
REM RNGSHFTLEFT|1 to 15|int1,int2|int1=shft int1 lft int2 bits,msb to lsb
REM
REM Variable names used: opcode, int1, int2, acc1.
REM
REM Routine names used: ALU:, SHIFTRIGHT:, RINGSHIFTRIGHT:, SHIFTLEFT:,
REM RINGSHIFTLEFT:, OR:, AND:, XOR:, NOT:.
REM
REM WARNINGS: When using these routines, compile your program from the
REM command line (ASICC YOURPROG.ASI). Also, these routines use the ASIC
REM String Conversion Buffer located at 0103h-0109h in the current
REM segment. There is NO error checking for the number of bits to shift
REM in the shift operations. (One could supply any number from 0 to 255 so
REM use caution.)
REM
REM Feel free to modify, alter or distribute these routines as you want.
REM (As long as NO fees of any kind are charged for them.)
REM The routines may be used individually ,also, without having to go
REM through ALU:. Simply make sure to supply them with the correct
REM operands.
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