-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathASSEMBLR.F83
executable file
·1 lines (1 loc) · 31 KB
/
ASSEMBLR.F83
1
\ The Rest is Silence 04Apr84map************************************************************* ************************************************************* *** *** *** Please direct all questions, comments, and *** *** miscellaneous personal abuse to: *** *** *** *** Henry Laxen or Michael Perry *** *** 1259 Cornell Avenue 1125 Bancroft Way *** *** Berkeley, California Berkeley, California *** *** 94706 94702 *** *** *** ************************************************************* ************************************************************* \ Load Screen for 68000 Dependent Code \ 20:21 15Jun89 b0b ONLY FORTH ALSO DEFINITIONS DECIMAL .( Loading 68000 ASSEMBLER ) 2 LOAD ( assembler ) \ 20 LOAD ( low-level debug ) \ 23 LOAD ( low-level Multitasker ) CR .( 68000 machine dependent code loaded ) \ 68000 Assembler Load Screen 11/13/85 plmONLY FORTH ALSO DEFINITIONS 3 19 THRU : NEXT A3 ) JMP ; : INIT [ ASSEMBLER ] WORD ; ONLY FORTH ALSO DEFINITIONS HEX 4EAC CONSTANT DOES-OP DECIMAL 4 CONSTANT DOES-SIZE : DOES? (S IP -- IP' F ) DUP DOES-SIZE + SWAP @ DOES-OP = ; : LABEL CREATE ASSEMBLER [ ASSEMBLER ] INIT ; : CODE CODE [ ASSEMBLER ] INIT ; \ 68000 ASSEMBLER 11/13/85 plm ASSEMBLER ALSO DEFINITIONS : A?>MARK (S -- addr f ) HERE TRUE ; : A?>RESOLVE (S addr f -- ) ?CONDITION HERE OVER - SWAP 1- C! ; : A?<MARK (S -- addr f ) HERE TRUE ; : A?<RESOLVE (S addr f -- ) ?CONDITION HERE - HERE 1- C! ; \ 68000 Assembler 1119nov85plm DEFER C, FORTH ' C, ASSEMBLER IS C, DEFER , FORTH ' , ASSEMBLER IS , DEFER ?>MARK ' A?>MARK IS ?>MARK DEFER ?>RESOLVE ' A?>RESOLVE IS ?>RESOLVE DEFER ?<MARK ' A?<MARK IS ?<MARK DEFER ?<RESOLVE ' A?<RESOLVE IS ?<RESOLVE : DELTA HERE - 2- ( PC offset ) ; \ 68000 Meta Assembler \ 2Jan87 bl : C; END-CODE ; : ?, IF , THEN , ; : 2, , , ; 8 BASE ! VARIABLE SIZE VARIABLE I-MODE 0 I-MODE ! : BYTE 10000 SIZE ! ; : WORD 30100 SIZE ! ; WORD : LONG 24600 SIZE ! ; : SZ CONSTANT DOES> @ SIZE @ AND OR ; 00300 SZ SZ3 00400 SZ SZ4 04000 SZ SZ40 30000 SZ SZ300 : LONG? SIZE @ 24600 = ; : -SZ1 LONG? IF 100 OR THEN ; \ addressing modes 11/13/85 plm: MODE CONSTANT DOES> @ SWAP 7007 AND OR ; ; : REGS 10 0 DO DUP 1001 I * OR CONSTANT LOOP DROP ; 0000 REGS D0 D1 D2 D3 D4 D5 D6 D7 0110 REGS A0 A1 A2 A3 A4 A5 A6 A7 0220 MODE ) ( address register indirect ) 0330 MODE )+ ( adr reg ind post-increment ) 0440 MODE -) ( adr reg ind pre-decrement ) 0550 MODE D) ( adr reg ind displaced ) 0770 CONSTANT #) ( immediate address ) 1771 CONSTANT L#) ( immediate long address ) 2772 CONSTANT PCD) ( PC relative displaced ) 4774 CONSTANT # ( immediate data ) \ DI) AND PCDI) 11/13/85 plm : SET-L I-MODE LONG? IF ON ELSE OFF THEN ; : <DI> 0660 SWAP 7007 AND OR ; 3773 CONSTANT <PCDI> : DI) SET-L <DI> ; : PCDI) SET-L <PCDI> ; \ fields and register assignments 02Apr84map: FIELD CONSTANT DOES> @ AND ; 7000 FIELD RD 0007 FIELD RS 0070 FIELD MS 0077 FIELD EAS 0377 FIELD LOW : DN? (S ea -- ea flag ) DUP MS 0= ; : SRC (S ea instr -- ea instr' ) OVER EAS OR ; : DST (S ea instr -- ea instr' ) SWAP RD OR ; A7 CONSTANT SP ( Stack pointer ) A6 CONSTANT RP ( Return stack pointer ) A5 CONSTANT IP ( Interpreter pointer ) A4 CONSTANT BASE ( base-address register ) D7 CONSTANT W ( Working register ) D6 CONSTANT SCRATCH ( Hi-half ALWAYS zero ) \ extended addressing plm 11/9/85 : ILONG? I-MODE @ ; : DOUBLE? ( mode -- flag ) DUP L#) = SWAP # = LONG? AND OR ; : INDEX? ( {n} mode -- {m} mode ) DUP >R DUP 0770 AND A0 <DI> = SWAP <PCDI> = OR IF DUP RD 10 * SWAP MS IF 100000 OR THEN ILONG? IF SIZE @ >R LONG THEN SZ40 SWAP LOW OR ILONG? IF R> SIZE ! THEN THEN R> ; : MORE? ( ea -- ea flag ) DUP MS 0040 > ; : ,MORE ( ea -- ) MORE? IF INDEX? DOUBLE? ?, ELSE DROP THEN ; \ extended addressing extras 10Jan84mapCREATE EXTRA HERE 5 DUP ALLOT ERASE \ temporary storage area : EXTRA? ( {n} mode -- mode ) MORE? IF >R R@ INDEX? DOUBLE? EXTRA 1+ SWAP IF 2! 2 ELSE ! 1 THEN EXTRA C! R> ELSE 0 EXTRA ! THEN ; : ,EXTRA ( -- ) EXTRA C@ ?DUP IF EXTRA 1+ SWAP 1 = IF @ , ELSE 2@ 2, THEN EXTRA 5 ERASE THEN ; \ immediates & address register specific 31Oct83map: IMM CONSTANT DOES> @ >R EXTRA? EAS R> OR SZ3 , LONG? ?, ,EXTRA ; ( n ea ) 0000 IMM ORI 1000 IMM ANDI 2000 IMM SUBI 3000 IMM ADDI 5000 IMM EORI 6000 IMM CMPI : IMMSR CONSTANT DOES> @ SZ3 2, ; ( n ) 001074 IMMSR ANDI>SR 005074 IMMSR EORI>SR 000074 IMMSR ORI>SR : IQ CONSTANT DOES> @ >R EXTRA? EAS SWAP RS 1000 * OR R> OR SZ3 , ,EXTRA ; ( n ea ) 050000 IQ ADDQ 050400 IQ SUBQ : IEAA CONSTANT DOES> @ DST SRC SZ4 , ,MORE ; ( ea An ) 150300 IEAA ADDA 130300 IEAA CMPA 040700 IEAA LEA 110300 IEAA SUBA \ shifts, rotates, and bit manipulation 31Oct83map: ISR CONSTANT DOES> @ >R DN? IF SWAP DN? IF R> 40 OR >R ELSE DROP SWAP 1000 * THEN RD SWAP RS OR R> OR 160000 OR SZ3 , ELSE DUP EAS 300 OR R@ 400 AND OR R> 70 AND 100 * OR 160000 OR , ,MORE THEN ; ( Dm Dn ) ( m # Dn ) ( ea ) 400 ISR ASL 000 ISR ASR 410 ISR LSL 010 ISR LSR 420 ISR ROXL 020 ISR ROXR 430 ISR ROL 030 ISR ROR : IBIT CONSTANT DOES> @ >R EXTRA? DN? IF RD SRC 400 ELSE DROP DUP EAS 4000 THEN OR R> OR , ,EXTRA ,MORE ; ( ea Dn ) ( ea n # ) 000 IBIT BTST 100 IBIT BCHG 200 IBIT BCLR 300 IBIT BSET \ branch, loop, and set conditionals 18Apr84map: SETCLASS ' SWAP 0 DO I OVER EXECUTE LOOP DROP ; : IBRA 400 * 060000 OR CONSTANT ( label ) DOES> @ SWAP ?>MARK DROP 2+ - DUP ABS 200 < IF LOW OR , ELSE SWAP 2, THEN ; 20 SETCLASS IBRA BRA BSR BHI BLS BCC BCS BNE BEQ BVC BVS BPL BMI BGE BLT BGT BLE : IDBR 400 * 050310 OR CONSTANT ( label \ Dn - ) DOES> @ SWAP RS OR , ?>MARK DROP - , ; 20 SETCLASS IDBR DXIT DBRA DBHI DBLS DBCC DBCS DBNE DBEQ DBVC DBVS DBPL DBMI DBGE DBLT DBGT DBLE : ISET 400 * 050300 OR CONSTANT ( ea ) DOES> @ SRC , ,MORE ; 20 SETCLASS ISET SET SNO SHI SLS SCC SCS SNE SEQ SVC SVS SPL SMI SGE SLT SGT SLE \ moves 10Jan84map: MOVE EXTRA? 7700 AND SRC SZ300 , ,MORE ,EXTRA ; ( ea ea ) : MOVEQ RD SWAP LOW OR 070000 OR , ; ( n Dn ) : MOVE>USP RS 047140 OR , ; ( An ) : MOVE<USP RS 047150 OR , ; ( An ) : MOVEM> EXTRA? EAS 044200 OR -SZ1 , , ,EXTRA ; ( n ea ) : MOVEM< EXTRA? EAS 046200 OR -SZ1 , , ,EXTRA ; ( n ea ) : MOVEP DN? IF RD SWAP RS OR 410 OR ELSE RS ROT RD OR 610 OR THEN -SZ1 2, ; ( Dm d An ) ( d An Dm ) : LMOVE 7700 AND SWAP EAS OR 20000 OR , ; ( long reg move ) \ odds and ends 16Jan84map: CMPM RD SWAP RS OR 130410 OR SZ3 , ; ( An@+ Am@+ ) : EXG DN? IF SWAP DN? IF 140500 ELSE 140610 THEN >R ELSE SWAP DN? IF 140610 ELSE 140510 THEN >R SWAP THEN RS DST R> OR , ; ( Rn Rm ) : EXT RS 044200 OR -SZ1 , ; ( Dn ) : SWAP RS 044100 OR , ; ( Dn ) : STOP 47162 2, ; ( n ) : TRAP 17 AND 47100 OR , ; ( n ) : LINK RS 047120 OR 2, ; ( n An ) : UNLK RS 047130 OR , ; ( An ) : EOR EXTRA? EAS DST SZ3 130400 OR , ,EXTRA ; ( Dn ea ) : CMP 130000 DST SRC SZ3 , ,MORE ; ( ea Dn ) \ arithmetic and logic 08Apr84map: IBCD CONSTANT DOES> @ DST OVER RS OR [ FORTH ] SWAP MS IF 10 OR THEN , ; ( Dn Dm ) ( An@- Am@- ) 140400 IBCD ABCD 100400 IBCD SBCD : IDD CONSTANT DOES> @ DST OVER RS OR [ FORTH ] SWAP MS IF 10 OR THEN SZ3 , ; ( Dn Dm ) ( An@- Am@- ) 150400 IDD ADDX 110400 IDD SUBX : IDEA CONSTANT DOES> @ >R DN? ( ea Dn ) ( Dn ea ) IF RD SRC R> OR SZ3 , ,MORE ELSE EXTRA? EAS DST 400 OR R> OR SZ3 , ,EXTRA THEN ; 150000 IDEA ADD 110000 IDEA SUB 140000 IDEA AND 100000 IDEA OR : IEAD CONSTANT DOES> @ DST SRC , ,MORE ; ( ea Dn ) 040600 IEAD CHK 100300 IEAD DIVU 100700 IEAD DIVS 140300 IEAD MULU 140700 IEAD MULS \ arithmetic and control \ 26Apr87 b0b : IEA CONSTANT DOES> @ SRC , ,MORE ; ( ea ) 047200 IEA JSR 047300 IEA JMP 042300 IEA MOVE>CCR 040300 IEA MOVE<SR 043300 IEA MOVE>SR 044000 IEA NBCD 044100 IEA PEA 045300 IEA TAS : IEAS CONSTANT DOES> @ SRC SZ3 , ,MORE ; ( ea ) \ 047200 IEA JSR 047300 IEA JMP \ 042300 IEA MOVE>CCR 041000 IEAS CLR 043000 IEAS NOT 042000 IEAS NEG 040000 IEAS NEGX 045000 IEAS TST : ICON CONSTANT DOES> @ , ; 47160 ICON RESET 47161 ICON NOP 47163 ICON RTE 47165 ICON RTS \ structured conditionals +/- 256 bytes 08Apr84map: THEN ?>RESOLVE ; : IF , ?>MARK ; HEX : ELSE 6000 IF 2SWAP THEN ; : BEGIN ?<MARK ; : UNTIL , ?<RESOLVE ; : AGAIN 6000 UNTIL ; : WHILE IF ; : REPEAT 2SWAP AGAIN THEN ; : DO ?>MARK DROP [ FORTH ] SWAP ; : LOOP DBRA ; 6600 CONSTANT 0= 6700 CONSTANT 0<> 6A00 CONSTANT 0< 6B00 CONSTANT 0>= 6C00 CONSTANT < 6D00 CONSTANT >= 6E00 CONSTANT <= 6F00 CONSTANT > DECIMAL \ Metacompiler special words D6.W D6.L, etc. 11/14/85 PLM : D0.L LONG D0 ; : D0.W WORD D0 ; : D1.L LONG D1 ; : D1.W WORD D1 ; : D6.L LONG D6 ; : D6.W WORD D6 ; : D7.L LONG D7 ; : D7.W WORD D7 ; : A0.L LONG A0 ; : A0.W WORD A0 ; : SP.L LONG SP ; : SP.W WORD SP ; : W.L LONG W ; : W.W WORD W ; \S These words are needed to differentiate between long and word Index fields in the d(Xn.L,An) and d(Xn.W,An) formats. Ex: 0 D1.L A6 DI) WORD D3 MOVE = MOVE.W 0(D1.L,A6),D3 ..and 0 D1.W A6 DI) LONG D3 MOVE = MOVE.L 0(D1.W,A6),D3 \ Machine-level DEBUG 11/13/85 plm 1 2 +THRU \ Vocabulary, Range test 11/15/85 PLMVOCABULARY BUG BUG ALSO DEFINITIONS VARIABLE <IP VARIABLE IP> VARIABLE CNT VARIABLE 'DEBUG LABEL FNEXT IP )+ W MOVE HERE 0 W.L BASE DI) D6.W MOVE 0 D6.L BASE DI) JMP CONSTANT FNEXT1 \ Debug version of Next 11/15/85 PLMLABEL DEBNEXT HEX IP D0 LMOVE LONG BASE D0 SUB WORD <IP DELTA PCD) D0 CMP 6500 ( U>= ) IF IP> DELTA PCD) D0 CMP 6200 ( U<= ) IF CNT DELTA PCD) A0 LEA A0 ) D1 MOVE 1 D1 ADDQ D1 A0 ) MOVE 2 # D1 CMP 0= IF A0 ) CLR FNEXT DELTA PCD) A3 LEA D0.W SP -) MOVE 'DEBUG DELTA PCD) W MOVE FNEXT1 BRA THEN THEN THEN FNEXT BRA C; DECIMAL CODE PNEXT DEBNEXT DELTA PCD) A3 LEA NEXT C; ONLY FORTH ALSO DEFINITIONS \ Load Screen for the MultiTasker 18APR83HHLONLY FORTH ALSO DEFINITIONS 1 2 +THRU CR .( MultiTasker Low Level Loaded ) ONLY FORTH ALSO DEFINITIONS EXIT The MultiTasker is loaded as an application on top of the regular Forth System. There is support for it in the nucleus in the form of USER variables and PAUSEs inserted inside of KEY EMIT and BLOCK. The Forth multitasking scheme is co-operative instead of interruptive. All IO operations cause a PAUSE to occur, and the multitasking loop looks around at all of the current task for something to do. \ Multitasking low level 22jan86plm CODE (PAUSE) (S -- ) IP SP -) LMOVE ( push IP ) RP SP -) LMOVE ( push RP ) UP DELTA PCD) D6.W MOVE 0 D6.L BASE DI) A0 LEA SP A0 ) LMOVE ( SP to TOS ) LONG 6 A0 ADDQ A0 ) A0 LMOVE A0 ) JMP ( to next task) C; LABEL RESTART (S -- ) SP )+ D0 MOVE ( drop SR ) SP )+ A0 LMOVE ( return address) LONG 6 A0 SUBQ A0 ) SP LMOVE ( restore SP ) SP )+ RP LMOVE ( pop RP ) SP )+ IP LMOVE ( pop IP ) LONG BASE A0 SUBA UP DELTA PCD) A1 LEA WORD A0 A1 ) MOVE ( restore UP ) NEXT C; \ Manipulate Tasks 08JAN84MAPHEX : LOCAL (S base addr -- addr' ) UP @ - + ; : @LINK (S -- addr ) LINK @ ; : !LINK (S addr -- ) LINK ! ; : SLEEP (S addr -- ) 4EF8 SWAP ENTRY LOCAL ! ; : WAKE (S addr -- ) 4E47 SWAP ENTRY LOCAL ! ; : STOP (S -- ) UP @ SLEEP PAUSE ; : SINGLE (S -- ) ['] PAUSE >BODY ['] PAUSE ! ; : MULTI (S -- ) 0 9C ! RESTART 9E ! ( trap 7 ) ['] (PAUSE) @ ['] PAUSE ! ; DECIMAL \ Manipulate Tasks 22jan86plmHEX : LOCAL (S base addr -- addr' ) UP @ - + ; : @LINK (S -- addr ) LINK 2@ ; : !LINK (S addr -- ) LINK 2! ; : SLEEP (S addr -- ) 4EF9 ( jmp ) SWAP ENTRY LOCAL ! ; : WAKE (S addr -- ) 4E47 ( trap 7 ) SWAP ENTRY LOCAL ! ; : STOP (S -- ) UP @ SLEEP PAUSE ; : SINGLE (S -- ) ['] PAUSE >BODY ['] PAUSE ! ; : MULTI (S -- ) RESTART ADD-BASE 09C. L2! ['] (PAUSE) @ ['] PAUSE ! ; DECIMAL \ 26Apr87 b0b