Design Ideas: October 26,, 1995
The assembly programs use a suitable 8051-family assembler to generate object code in Intelhex format. You can call the assembly routines from within Basic using the CALL address instruction. The address is the absolute memory address of the start of the assembly routine. The 8052-Basic chip has a variable called MTOP that indicates the last address of the external RAM. All Basic programs reside within the limit MTOP imposes. Upon RESET, Basic-52 sizes all the available RAM and assigns the last memory address to MTOP. Consequently, to load assembly programs, you should reduce the MTOP value to make space for assembly routines. Otherwise, the program might overwrite the assembly routines. (DI #1776)
| Listing8052-Basic assembly-loading routine |
|---|
1 PRINT "Program to load Assembly routine in EXTERNAL RAM" 2 PRINT "This memory must also be accessible as CODE Memory" 3 PRINT "MTOP value must be less than the address of memory" 4 PRINT "locations where an Assembly program is being loaded" 5 PRINT: PRINT "D.V. GADRE @ IUCAA": PRINT 6 PRINT "Ready to accept Intehex files from the host... " 8 MTOP=41FFH 9 REM Get a Character from the host 10 A=GET : IF A=0 THEN 10 19 REM Check if the character is a : 20 IF A<> 58 THEN 10 29 REM If yes, continue, else ignore it 30 PRINT CHR(A), 34 REM CSUM variable contains the checksum 35 CSUM=0 40 GOSUB 1000 50 LL=A : IF A=0 THEN 230 55 CSUM=CSUM+LL 60 GOSUB 1000 70 ADDR=256*A 75 CSUM=CSUM+A 80 GOSUB 1000 90 ADDR=A+ADDR 100 CSUM=CSUM+A 110 GOSUB 1000: IF A<> 0 THEN 230 130 FOR T=1 TO LL 140 GOSUB 1000 150 CSUM=CSUM+A 159 REM Store the byte in the external RAM 160 XBY(ADDR)=A 165 D=CBY(ADDR): IF A<>D THEN PRINT "ERROR" 170 ADDR=ADDR+1 180 NEXT T 190 GOSUB 1000 200 CSUM=CSUM+A : CSUM=CSUM .AND. 00FFH 210 IF CSUM<>0 THEN PRINT "....CHECKSUM ERROR...ABORTING": GOTO 230 220 PRINT : GOTO 10 230 END 240 REM 990 REM Routine to get a byte from the console 995 REM & convert it to binary 1000 A=GET: IF A=0 THEN 1000 1010 PRINT CHR(A),:IF A<58 THEN A=A-48: GOTO 1030 1020 A=A-55 1030 C=A 1040 A=GET: IF A=0 THEN 1040 1050 PRINT CHR(A),:IF A<58 THEN A=A-48: GOTO 1070 1060 A=A-55 1070 A=16*C+A 1080 RETURN |