INTERNAL MEMORY ALLOCATION The 8031 has 128 bytes of internal memory, occupying locations 00-7F. The first 48 locations have special functions as follows. 00-07 Register bank 0 08-0F Register bank 1 10-17 Register bank 2 18-1F Register bank 3 20-2F Bit addressable I always use register bank 0 for non-interrupt code, and register bank 1 for interrupt code. The 8031 can only use internal memory as stack. Writing large complex programs means having as much stack as possible, so I always assign all the non-special internal memory as stack. This leaves very few internal memory locations: 10-1F: 16 bytes not bit addressable 20-2F: 16 bytes bit adressable Since the 8031 instruction set is very efficient with internal memory and very inefficient with external memory, it pays to use these internal locations wisely. EXTERNAL MEMORY External memory is only accessible through the MOVX instruction. The address may be supplied either by DPTR, or by P2/R0 or by P2/R1. There is an INC DPTR instruction but no DEC DPTR instruction. So it pays to align any table you have to move up and down in on a 256-byte page boundary. That way you can get by with just DEC DPL if the table is smaller than one page. Still use INC DPTR though; it's only one byte whereas INC DPL is two. If PSEN* and RD* are or-ed together you can use the MOVC instruction for table lookups in both code and data space.