Pk2.asm

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Pk2.asm as PDF for free.

More details

  • Words: 2,206
  • Pages: 7
PK2

IDNT 1,0 NOPAGE INCLUDE MACROS.INC NOFORMAT INCLUDE 4:MACROS2.INC

* * * UPDATED VERSION -- OS 1.1 COMPATIBLE * * ENTRY PEEKB byte wise PEEK -- aka BPEEK, PEEK * FORTRAN CALLING SEQUENCE: CALL PEEK(INT*4 address,variable[>=1 byte]) * * ENTRY PEEKW word wise PEEK * gets the word a byte at a time - avoiding ADDR TRAP if address specified * is odd * FORTRAN CALLING SEQUENCE: CALL PEEKW(INT*4 address,variable[>=2 byte]) * * ENTRY WPEEK WORD PEEK * masks out LSB of address to avoid ADDR TRAP * FORTRAN CALLING SEQUENCE: CALL WPEEK(INT*4 address,variable[>=2 byte]) * * ENTRY PEEKL LONG word PEEK * gets the long word a byte at a time - avoiding ADDR TRAP if address specified * is odd * FORTRAN CALLING SEQUENCE: CALL PEEKL(INT*4 address,variable[>=4 byte]) * * ENTRY LPEEK long word PEEK * masks out LSB of address to avoid ADDR TRAP * FORTRAN CALLING SEQUENCE: CALL LPEEK(INT*4 address,variable[>=4 byte]) * * ENTRY POKEB byte wise POKE -- aka POKE, BPOKE * FORTRAN CALLING SEQUENCE: CALL POKE(INT*4 address,variable) * * ENTRY POKEW word wise POKE - byte by byte * ENTRY WPOKE word wise POKE - addr mask * FORTRAN CALLING SEQUENCE: CALL WPOKE(INT*4 address,variable) * * ENTRY POKEL LONG word POKE -- byte by byte * ENTRY LPOKE LONG word POKE -- addr mask * FORTRAN CALLING SEQUENCE: CALL LPOKE(INT*4 address,variable) * * * XDEF SPOKEW,SWPOKE WORD size poke, done into SUPERVISOR mode * FORTRAN CALLING SEQUENCE: CALL SPOKEW(INT*4 address,variable) * * XDEF SLPOKE,SPOKEL LWORD poke, done in SUPERVISOR mode * FORTRAN CALLING SEQUENCE: CALL SLPOKE(INT*4 address,variable) * * XDEF SPOKE,SPOKEB,SBPOKE BYTE size poke, done in SUPERVISOR mode * FORTRAN CALLING SEQUENCE: CALL SPOKE(INT*4 address,variable) * * XDEF ALLOCS,ALLOC_S,KGR_NEWS,GTSTAK * I = ALLOCS(HOWMANY integer*4) will allocate HOWMANY bytes from STACK and * return pointer, or will return 0 if allocation fails [ALLOC_S, KGR_NEWS] * do the same but can be called from Pascal with longint argument * * XDEF RLSE_S,RLSES,LSSTAK * CALL RLSES will release allocated STACK, RLSE_S, LSSTAK do the same * * XDEF SETA7, SETA7_, SETD0, SETD0_ * force values into A7 (stack pointer) or D0 (val return register) * _ for PASCAL pass-by-value, others for FORTRAN, PASCAL pass-by-pointer * * BEGPK2 EQU * AMASK EQU $0FFFFFE * * FPEEKB EQU * FPEEK EQU * FBPEEK EQU * XDEF FPEEKB,FPEEK,FBPEEK byte wise PEEK MOVEA.L (A7)+,A0 PEA.L SCRLWRD MOVE.L A0,-(A7) * PEEKB EQU * PEEK EQU * BPEEK EQU * XDEF PEEKB,PEEK,BPEEK byte wise PEEK * FORTRAN CALLING SEQUENCE: CALL PEEK(INT*4 address,variable[>=1 byte]) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op

* FPEEKW

MOVEA.L MOVEA.L MOVEQ.L MOVE.B MOVE.L RSTREG FNRET

8(A5),A0 (A0),A0 #0,D0 (A0),D0 D0,(A1)

A0 loaded with address of first op First OP is ADDRESS, get it into A0 zero out D0 get the byte store the result in the second op

2

PEEKB return

EQU * ENTRY FPEEKW MOVEA.L (A7)+,A0 PEA SCRLWRD MOVE.L A0,-(A7) PEEKW EQU * ENTRY PEEKW * gets the word a byte at a * is odd * FORTRAN CALLING SEQUENCE: SAVREG MOVEA.L 4(A5),A1 MOVEA.L 8(A5),A0 MOVEA.L (A0),A0 MOVEQ.L #0,D0 MOVE.B (A0)+,D0 ROL.W #8,D0 MOVE.B (A0),D0 MOVE.L D0,(A1) RSTREG FNRET 2 * FWPEEK EQU * ENTRY FWPEEK MOVEA.L (A7)+,A0 PEA SCRLWRD MOVE.L A0,-(A7) WPEEK EQU * ENTRY WPEEK * FORTRAN CALLING SEQUENCE: SAVREG MOVEA.L 4(A5),A1 MOVEA.L 8(A5),A0 * MOVEA.L A0,A2 MOVE.L (A0),D0 AND.L ADRMASK,D0 MOVE.L D0,(A0) MOVEA.L D0,A0 MOVEQ.L #0,D0 MOVE.W (A0),D0 MOVE.L D0,(A1) MOVE.L D0,SCRLWRD RSTREG FNRET 2 * FPEEKL EQU * ENTRY FPEEKL MOVEA.L (A7)+,A0 PEA SCRLWRD MOVE.L A0,-(A7) PEEKL EQU * ENTRY PEEKL * gets the long word a byte * is odd * FORTRAN CALLING SEQUENCE: SAVREG MOVEA.L 4(A5),A1 MOVEA.L 8(A5),A0 MOVEA.L (A0),A0 MOVEQ.L #0,D0 MOVE.B (A0)+,D0 ROL.W #8,D0 MOVE.B (A0)+,D0 SWAP D0 MOVE.B (A0)+,D0 ROL.W #8,D0 MOVE.B (A0),D0 MOVE.L D0,(A1) RSTREG FNRET 2 FLPEEK EQU * ENTRY FLPEEK MOVEA.L (A7)+,A0 PEA SCRLWRD

word wise PEEK

word wise PEEK time - avoiding ADDR TRAP if address specified CALL PEEKW(INT*4 address,variable[>=2 byte]) A1 loaded with address of second op A0 loaded with address of first op First OP is ADDRESS, get it into A0 zero out D0 get the HIGH byte ROTATE it into the high byte position get the LOW byte store the result in the second op PEEKW return word wise PEEK

word wise PEEK CALL WPEEK(INT*4 address,variable[>=2 byte]) A1 loaded with address of second op A0 loaded with address of first op SAVE addr of first op First OP is ADDRESS, get it into D0 FORCE address to word boundary RETURN adjusted address GET the adjusted addr. into A0 zero out D0 get the word store the result in the second op store the result FOR FN RETURN WPEEK return LONG word PEEK

LONG word PEEK at a time - avoiding ADDR TRAP if address specified CALL PEEKL(INT*4 address,variable[>=4 byte]) A1 loaded with address of second op A0 loaded with address of first op First OP is ADDRESS, get it into A0 zero out D0 get the HIGH byte ROTATE it into the high byte position get the LOW byte SWAP it into the high WORD position get the HIGH byte of the SECOND word ROTATE it into the high byte position get the LOW byte of the SECOND word store the result in the second op PEEKL return long word PEEK

MOVE.L A0,-(A7) EQU * ENTRY LPEEK long word PEEK * FORTRAN CALLING SEQUENCE: CALL LPEEK(INT*4 address,variable[>=4 byte]) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op MOVEA.L 8(A5),A0 A0 loaded with address of first op * MOVEA.L A0,A2 SAVE addr of first op MOVE.L (A0),D0 First OP is ADDRESS, get it into D0 AND.L ADRMASK,D0 FORCE address to word boundary MOVE.L D0,(A0) RETURN adjusted address MOVEA.L D0,A0 GET the adjusted addr. into A0 MOVE.L (A0),D0 get the LONG word MOVE.L D0,(A1) store the result in the second op RSTREG FNRET 2 LPEEK return * POKEB EQU * POKE EQU * BPOKE EQU * XDEF POKEB,POKE,BPOKE byte wise POKE * FORTRAN CALLING SEQUENCE: CALL POKE(INT*4 address,variable) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op ADDQ.L #3,A1 A1 is ptr to LWORD, address lsBYTE MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVEA.L (A0),A0 First OP is ADDRESS, get it into A0 MOVE.B (A1),(A0) MOVE the byte RSTREG FNRET 2 POKEB return * POKEW EQU * ENTRY POKEW word wise POKE * FORTRAN CALLING SEQUENCE: CALL POKEW(INT*4 address,variable) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op ADDQ.L #2,A1 A1 is ptr to LWORD, get lsWORD MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVEA.L (A0),A0 First OP is ADDRESS, get it into A0 MOVE.B (A1)+,(A0)+ MOVE the FIRST byte MOVE.B (A1),(A0) MOVE the SECOND byte RSTREG FNRET 2 return WPOKE EQU * ENTRY WPOKE word wise POKE * FORTRAN CALLING SEQUENCE: CALL WPOKE(INT*4 address,variable) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op ADDQ.L #2,A1 A1 is ptr to LWORD, address lsWORD MOVEA.L 8(A5),A0 A0 loaded with address of first op * MOVEA.L A0,A2 SAVE addr of first op MOVE.L (A0),D0 First OP is ADDRESS, get it into D0 AND.L ADRMASK,D0 FORCE address to word boundary MOVE.L D0,(A0) RETURN adjusted address MOVEA.L D0,A0 GET the adjusted addr. into A0 MOVE.W (A1),(A0) MOVE the word RSTREG FNRET 2 WPOKE return * POKEL EQU * ENTRY POKEL LONG word POKE * FORTRAN CALLING SEQUENCE: CALL POKEL(INT*4 address,variable) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVEA.L (A0),A0 First OP is ADDRESS, get it into A0 MOVE.B (A1)+,(A0)+ MOVE the FIRST byte MOVE.B (A1)+,(A0)+ MOVE the NEXT byte MOVE.B (A1)+,(A0)+ MOVE the NEXT byte MOVE.B (A1),(A0) MOVE the LAST byte RSTREG FNRET 2 POKEL return LPOKE EQU * ENTRY LPOKE LONG word POKE * FORTRAN CALLING SEQUENCE: CALL LPOKE(INT*4 address,variable) SAVREG MOVEA.L 4(A5),A1 A1 loaded with address of second op MOVEA.L 8(A5),A0 A0 loaded with address of first op * MOVEA.L A0,A2 SAVE addr of first op MOVE.L (A0),D0 First OP is ADDRESS, get it into D0 AND.L ADRMASK,D0 FORCE address to word boundary MOVE.L D0,(A0) RETURN adjusted address LPEEK

* * AWPOKE

* WSPOKE SPOKEW SWPOKE

MOVEA.L D0,A0 MOVE.L (A1),(A0) RSTREG FNRET 2 EQU XDEF MOVE.L MOVE.L PEA.L PEA.L JSR RTS

* AWPOKE D0,SP0K3SRC A0,SP0K3ADDR SP0K3ADDR(PC) SP0K3SRC(PC) WSPOKE

GET the adjusted addr. into A0 MOVE the LONG word LPOKE return

SPOKESRC Loaded second op GET the adjusted addr.

EQU * EQU * EQU * XDEF SPOKEW,SWPOKE XDEF WSPOKE * FORTRAN CALLING SEQUENCE: CALL LPOKE(INT*4 address,variable) SAVREG MOVE.L 4(A5),SP0KESRC SPOKESRC Loaded w/ address of second op ADDQ.L #2,SP0KESRC MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVE.L (A0),D1 First OP is ADDRESS, get it into D1 AND.L ADRMASK,D1 FORCE address to word boundary MOVE.L D1,(A0) RETURN adjusted address MOVE.L D1,SP0KEADDR SAVE the adjusted addr. EXLT MOVEA.L SP0KEADDR,A3 Restore A3 MOVEA.L SP0KESRC,A1 Restore A1 MOVE.W (A1),(A3) MOVE the word HMBL RSTREG FNRET 2 SWPOKE return * * ALPOKE EQU * XDEF ALPOKE MOVE.L D0,SP0K3SRC SPOKESRC Loaded W/second op MOVE.L A0,SP0K3ADDR GET the adjusted addr. PEA.L SP0K3ADDR(PC) PEA.L SP0K3SRC(PC) JSR SLPOKE RTS * LSPOKE EQU * SPOKEL EQU * SLPOKE EQU * XDEF SLPOKE,SPOKEL XDEF LSPOKE * FORTRAN CALLING SEQUENCE: CALL LPOKE(INT*4 address,variable) SAVREG MOVE.L 4(A5),SP0KESRC SPOKESRC Loaded w/ address of second op MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVE.L (A0),D1 First OP is ADDRESS, get it into D1 AND.L ADRMASK,D1 FORCE address to word boundary MOVE.L D1,SP0KEADDR GET the adjusted addr. MOVE.L D1,(A0) RETURN adjusted address EXLT MOVEA.L SP0KEADDR,A3 Restore A3 MOVEA.L SP0KESRC,A1 Restore A1 MOVE.L (A1),(A3) MOVE the LONG word HMBL RSTREG FNRET 2 SLPOKE return * * SPOKEB EQU * SPOKE EQU * SBPOKE EQU * XDEF SPOKE,SPOKEB,SBPOKE * FORTRAN CALLING SEQUENCE: CALL POKE(INT*4 address,variable) MOVEA.L 4(A7),A1 A1 loaded with address of second op MOVE.B 3(A1),D0 MOVEA.L 8(A7),A0 A3 loaded with address of first op MOVEA.L (A0),A0 First OP is ADDRESS, SAVE IT JSR ABPOKE FNRET 2 SPOKE return * ABPOKE EQU *

* BSPOKE

XDEF SAVREG MOVE.B MOVE.L EXLT MOVEA.L MOVE.B HMBL RSTREG RTS

ABPOKE D0,SP0K3SRC A0,SP0K3ADDR SP0K3ADDR,A0 SP0K3SRC,(A0)

D0 saved TEMPORARY goto SUPERVISOR state Restore A3 MOVE IT Return to USER state

EQU * XDEF BSPOKE * FORTRAN CALLING SEQUENCE: CALL LPOKE(INT*4 address,variable) SAVREG MOVE.L 4(A5),SP0KESRC SPOKESRC Loaded w/ address of second op ADDQ.L #3,SP0KESRC MOVEA.L 8(A5),A0 A0 loaded with address of first op MOVE.L (A0),SP0KEADDR EXLT MOVEA.L SP0KEADDR,A3 Restore A3 MOVEA.L SP0KESRC,A1 Restore A1 MOVE.B (A1),(A3) MOVE the LONG word HMBL RSTREG FNRET 2 BSPOKE return * * IHIT1T EQU * XDEF IHIT1T MOVEA.L 12(A7),A0 MOVE.L (A0),D0 BRA.S INHIT1T HIT1T EQU * XDEF HIT1T MOVE.L 12(A7),D0 INHIT1T EQU * BEQ.S H1TNO0DST MOVEA.L D0,A0 MOVEA.L 8(A7),A1 MOVE.L (A1),D1 SUBQ.L #1,D1 BPL.S H1TOVER MOVEQ.L #1,D1 H1TOVER EQU * MOVEA.L 4(A7),A1 MOVE.L (A1),D2 FOR.L D0 = #0 TO D1 BY #1 DO.S MOVE.B D2,0(A0,D0.L) ENDF H1TNO0DST EQU * FNRET 3 * * IHIT2T EQU * XDEF IHIT2T MOVEA.L 12(A7),A0 MOVE.L (A0),D0 BRA.S INHIT2T HIT2T EQU * XDEF HIT2T MOVE.L 12(A7),D0 INHIT2T EQU * AND.L ADRMASK(PC),D0 BEQ.S H2TNO0DST MOVEA.L D0,A0 MOVEA.L 8(A7),A1 MOVE.L (A1),D1 AND.L ADRMASK(PC),D1 SUBQ.L #2,D1 BPL.S H2TOVER MOVEQ.L #24,D1 H2TOVER EQU * MOVEA.L 4(A7),A1 MOVE.L (A1),D2 FOR.L D0 = #0 TO D1 BY #2 DO.S MOVE.W D2,0(A0,D0.L) ENDF H2TNO0DST EQU * FNRET 3

* * SFUNPK

EQU * ENTRY SFUNPK SAVREG MOVEA.L 12(A5),A0 MOVE.L (A0),D5 MOVEA.L 8(A5),A6 MOVEA.L 4(A5),A0 PUSH.L A0 EOR.L D7,D7 TRAP #6 DC.W 6 BRA.L SFUNERR MOVEQ.L #0,D7 SFUNERR EQU * POP.L A0 MOVE.L D7,(A0) RSTREG FNRET 3 * * ALLOC_S EQU * KGR_NEWS EQU * MOVE.L 4(A7),D2 BRA.S ALLOC_MAIN ALLOCS EQU * GTSTAK EQU * XDEF ALLOCS,ALLOC_S,KGR_NEWS,GTSTAK MOVEA.L 4(A7),A1 MOVE.L (A1),D2 ALLOC_MAIN EQU * MOVE.L (A7)+,A0 LEA.L 4(A7),A7 BTST #0,D2 BEQ.S ALLOC_NO_ADD ADDQ.L #1,D2 ALLOC_NO_ADD MOVE.L $1C(A5),D1 ADDI.L #$200,D1 MOVE.L A7,D0 SUB.L D2,D0 CMP.L D0,D1 BGE.S ALLOC_BAD CMPI.L #0,D2 BEQ.S ALLOC_RET MOVE.L A7,D1 MOVEA.L D0,A7 PUSH.L D1 BRA.S ALLOC_RET ALLOC_BAD EQU * MOVEQ.L #0,D0 ALLOC_RET EQU * JMP (A0) * RLSE_S EQU * RLSES EQU * LSSTAK EQU * XDEF RLSE_S,RLSES,LSSTAK POP.L A0 POP.L D0 MOVEA.L D0,A7 JMP (A0) * SETA7 EQU * MOVEA.L 4(A7),A0 MOVE.L (A0),D0 BRA.S INSETA7 SETA7_ EQU * XDEF SETA7,SETA7_ MOVE.L 4(A7),D0 INSETA7 EQU * MOVEA.L (A7),A0 MOVEA.L D0,A7 JMP (A0) * SETD0 EQU * MOVEA.L 4(A7),A0 MOVE.L (A0),D0 BRA.S INSETD0 SETD0_ EQU * XDEF SETD0,SETD0_ MOVE.L 4(A7),D0

INSETD0 EQU * MOVEA.L (A7)+,A0 MOVE.L (A7)+,D1 JMP (A0) * * SPOKEADDR DS.L 1 SPOKESRC DS.L 1 SP0KEADDR DS.L 1 SP0KESRC DS.L 1 *MESS1 DC.B 'EXLT MESSAGE *MESS2 DC.B 'EXLT MESSAGE SPOK3ADDR DS.L 1 SPOK3SRC DS.L 1 SP0K3ADDR DS.L 1 SP0K3SRC DS.L 1 * *MESS3 DC.B 'HMBL MESSAGE *MESS4 DC.B 'HMBL MESSAGE * *Register SAVE area PAD1 DS.L 1 SAVEA EQU * SD0 DS.L 1 SD1 DS.L 1 SD2 DS.L 1 SD3 DS.L 1 SD4 DS.L 1 SD5 DS.L 1 SD6 DS.L 1 SD7 DS.L 1 SA0 DS.L 1 SA1 DS.L 1 SA2 DS.L 1 SA3 DS.L 1 SA4 DS.L 1 SA5 DS.L 1 SAV5ND EQU * SA6 DS.L 1 SA7 DS.L 1 SAVEND EQU * PAD2 DS.L 1 BASE DS.L 1 CMDLNADDR DS.L 1 PAD3 DS.L 1 ADRMASK DC.L AMASK RETADR DS.L 1 ARG1ADR DS.L 1 PAD4 DS.L 1 USPSAVE DS.L 1 USPTEMP DS.L 1 SSPSAVE DS.L 1 PAD5 DS.L 1 SCRLWRD DS.L 1 Q1STORAGE ENDPK2 EQU * ZZZZZ EQU * END

1111',4,13 222222222',4,13

3333333333333333',4,13 444444444444444444444444444',4,13