Electronics
Btrieve
Motorcycling
Software

CHAPTER 13

Mapping User Code Memory


You might have noticed by now that some of external code memory locations that MCS BASIC-52 calls and uses are located around 2000H and some of the locations are located around 4000H. Specifically, they are as follows:
 
 
LOCATION FUNCTION
2001H On reset, MCS BASIC-52 looks for a 0AAH in this location, if present, calls location 2090H.
2002H MCS BASIC-52 examines this location to see if the user wants to implement the command/statement extension option. A 05AH is to be placed in this location to evoke the command/statement extension option.
2048H MCS BASIC-52 calls the location if the user wants to implement the command/statement extension option. The user will usually set bit 45 (bit 2DH = 25.5H) then return.
2070H MCS BASIC-52 calls this location to get the user vector table address when the command/statement extension option is evoked. The address of the vector table is put in the DPTR by the user.
2078H MCS BASIC-52 calls this location to get the user lookup table address when the command/statement extension option is evoked. The address of the lookup table is put in the DPTR by the user.
2090H MCS BASIC-52 calls this location when the user evokes the assembly language reset option.
4003H External interrupt 0
400BH Timer 0 interrupt
4013H External interrupt 1
401BH Timer 1 interrupt
4023H Serial port interrupt
402BH Timer 2 interrupt
4030H User console output
4033H User console input
4036H User console status
403CH User PRINT@ or LIST@ vector
4100H to 41FFH User calls from 0 to 7FH

Other vectors between 2040H and 2090H also exist, but they are mainly for testing purposes, but for your information they are:
 
 
LOCATION FUNCTION
2040H Trap location for external interrupt 0 if bit 26H of internal RAM is set and the DMA option is evoked. PSW is not pushed onto stack. Interrupts of course, must be enabled. Also, this location will be called for console output if bit 2CH of internal RAM is set.
2050H Trap location for serial port interrupt if bit 1FH of internal RAM is set. PSW is pushed onto the stack.
2060H Called for console input if bit 32H of internal RAM is set.
2068H Called for console status check if bit 32H of internal RAM is set.
2088H Timer 1 interrupt trap if bit 1AH of internal RAM is set. PSW is pushed onto the stack.

Contrary to popular belief, these vectors were not chosen to force the user to buy bigger EPROMS. They are chosen so that addresses 2000H and 4000H can be overlayed and create no conflicts. The overlayed addresses would appear as...
 
LOCATION FUNCTION
2001H On reset, call to 2090H if 0AAH present.
2002H If 05AH present then command/statement extensions exist
4003H External interrupt 0
400BH Timer 0 interrupt
4013H External interrupt 1
401BH Timer 1 interrupt
4023H Serial port interrupt
402BH Timer 2 interrupt
4030H User console output
4033H User console input
4036H User console status
403CH User PRINT@ and LIST@ vector
2040H External interrupt 0 when DMA option used and bit 26H (internal RAM) is set
2048H Called for command/statement extensions. Set bit 2DH to enable.
2050H Serial port interrupt if bit 1FH (internal RAM) is set
2060H Called for console input if bit 32H (internal RAM) is set
2068H Called for console status check if bit 32H (internal RAM) is set
2070H Called to put vector table address (for command/statement extensions) into DPTR
2078H Called to put table address (for command/statement extensions) into DPTR
2088H Timer 1 interrupt if bit 1AH (internal RAM) is set
2090H Called on reset if 2001H = 0AAH
4100H to 41FFH User CALLs (from BASIC)

By using overlapping addresses, the user can implement all MCS BASIC-52 user expansion options with only a few hundred bytes of EPROM.

The reason this type of addressing scheme was chosen is that it permits the designer to offer custom versions of MCS BASIC-52, by using the vector locations in the 2000H region. And give the designers OEM the ability to take advantage of the I/O vectors located in the 4000H region.

As an added note, the MCS-51 instruction set is object relocatable on 2K boundaries if no LCALL or LJMP instructions are used. This means that it is possible for the designer to ORG a program for 2000H and actually execute the program at 2800H, 3000H, 3800H, etc. If the user does not use the LCALL or LJMP instructions.

Copyright © Madis Kaal 2000-