; File: BANK1LOG.A51 Date: 09/03/93 ; ; /* (c) Copyright BLUE EARTH RESEARCH, MANKATO, MN 1993. */ ; /* All rights reserved. */ ; $ DATE (09-03-93) $ PW(107) PL(60) $ ERRORPRINT DEBUG XREF ; NOTES: ; When running a BASIC program from RAM Bank0 of the Micro-485, the user ; cannot switch to RAM Bank1 and continue execution of the program. ; This routine will allow the user to write/read data to/from almost any ; location in Bank1. From BASIC, the user loads the upper and lower ; bytes of the target location into internal memory locations 19H and 18H, ; respectively. Location 1AH is either loaded with data to be written or ; contains data that was read. After loading the appropriate locations, the ; BASIC program should then CALL location 0FBC0H to read data, or CALL ; location 0FBC4H to write data. Using this program allows the user to log ; data in RAM Bank1 from location 0-0FBBFH (0-64,447). ; ********************* IMPORTANT NOTE ************************ ; THE ASSEMBLY ROUTINE MUST BE LOADED INTO BOTH BANK0 AND BANK1 ; ************************************************************* ; The following sample BASIC program demonstrates loading the value 99H into ; RAM Bank1 location 5000H. It then reads back the contents of that location. ; 1 REM SAMPLE PROGRAM TO USE BANK1LOG.A51 ; 10 ADDR_LO=18H : ADDR_HI=19H : DAT=1AH : DP=5FFEH ; 30 A=5000H : REM Pick arbitrary location for this example ; REM Store data pointer in Bank0 memory ; 40 XBY(DP)=INT(A/256) : XBY(DP+1)=A.AND.255 ; REM Lines 50-60 demonstrate how to load the value 99H into the ; REM location in Bank1 pointed to by DP and DP+1. ; 50 DBY(ADDR_HI)=XBY(DP) : DBY(ADDR_LO)=XBY(DP+1) : DBY(DAT)=99H ; 60 CALL 0FBC4H : REM Call routine to log data to Bank1 ; REM Lines 70-80 demonstrate how to read a value in Bank1 which is ; REM pointed to by DP and DP+1 ; 70 DBY(ADDR_HI)=XBY(DP) : DBY(ADDR_LO)=XBY(DP+1) ; 80 CALL 0FBC0H : REM Call routine to read data from Bank1 ; 90 PRINT DBY(DAT) : REM Print data $ EJECT DSEG AT 18H ADDR_LO: DS 1 ADDR_HI: DS 1 DATA_LOG: DS 1 RD_WR BIT 0 START EQU 0FBC0H ; Beginning Code address BANK0 CODE 0FD00H ; Address to select Bank 0 BANK1 CODE 0FE00H ; Address to select Bank 1 CSEG AT START RD_DATA: SETB RD_WR ; CALL here to read data SJMP START1 WR_DATA: CLR RD_WR ; CALL here to write data START1: PUSH DPH PUSH DPL PUSH ACC PUSH PSW PUSH IE CLR EA ; No Interrupts while in Bank1. MOV DPTR,#BANK1 ; Switch to Bank1 MOVC A,@A+DPTR MOV DPL,ADDR_LO ; Point to location MOV DPH,ADDR_HI ; specified by user. JB RD_WR,READ ; Read data if set else write data. MOV A,DATA_LOG ; Get the byte to be stored and MOVX @DPTR,A ; write it to memory in Bank1 SJMP BOTTOM READ: MOVX A,@DPTR ; Read the data from Bank1 MOV DATA_LOG,A ; and save the byte. BOTTOM: MOV DPTR,#BANK0 ; Now jump back to Bank 0 and MOVC A,@A+DPTR ; return to BASIC. POP IE POP PSW POP ACC POP DPL POP DPH RET ; Return to BASIC. END ; Following is the HEX file derived from the assembled source ; file. This can be used for directly loading the program via ; MONITOR-51 and almost any terminal program. ; IMPORTANT: THIS HEX FILE MUST BE LOADED INTO BOTH BANK0 AND BANK1 :10FBC000D2008002C200C083C082C0E0C0D0C0A802 :10FBD000C2AF90FE0093851882851983200005E549 :10FBE0001AF08003E0F51A90FD0093D0A8D0D0D091 :06FBF000E0D082D0832268 :00000001FF