Internal Registers


You can manipulate the register values directly from BASIC.
They are also reserved words. The internal registers are :

BIT addressable registers

TCON Timer/counter control
P1 Port 0 latch
SCON Serial port control
IE Interrupt enable
P3 Port 3 latch
IP Interrupt priority control
PSW Program status word
ACC Accumulator
B B register
BYTE addressable register

SP Stack pointer
DPL Data pointer low word
DPH Data pointer high word
PCON Power control
TMOD Timer/counter mode control
TL0 Timer/counter 0 low byte
TL1 Timer/counter 1 low byte
TH0 Timer/counter 0 high byte
TH1 Timer/counter 1 high byte
SBUF Serial data port
P1 Port 1 latch
P3 Port 3 latch
The registers and their addresses are defined in the REG51.DAT file which
is placed in the BASCOM application directory.
You can use an other file for other uPs.

Take care when you are directly manipulating registers!
The ACC and B register are frequently used by BASCOM.
Also the SP register is better to be left alone.
Altering SP will certainly crash your application!

Bit addressable registers can be used with the SET/RESET statements and as bit-variables.
Byte addressable registers can be used as byte variables.
P1 = 40 will place a value of 40 into port 40.

Please note that internal registers are reserved words.
This means that they can't be dimensioned as BASCOM variables!

So you can't use the statement DIM B as Byte because B is an internal register.
You can however manipulate the register with the B = value statement.

Making your own register file is very simple:

· copy the 8052.DAT file to a new DAT file for example myproc.DAT
DOS c:\bascom copy 8052.dat myproc.dat
· edit the register file with BASCOM

A register file has a few sections. The following example shows only a few items under each section.
The [BIT] section contains all SRFs which are bit addressable. A bit addressable SFR ends with 0 or 8.
After the SFR name you can write the hexadecimal address.
An optional initial value for the simulator can also be specified. Separate the values by a comma.
Acc = E0 , 00

The [BYTE] section contains all the other SRFs.

The [MISC] section has a few items:

· up : here you can enter a short name for the uP.
· IRAM : the amount of available internal memory (128 or 256 bytes)
· org : the hexadecimal address where the code can start. This is 3 bytes after the last interrupt entry address, because the last interrupt will have a LJMP to an ISR and a LJMP needs 3 bytes.
· I_xxx : where xxx is the name of the additional interrupt. The name must be no longer than 6 characters. As you can see in the example below the last interrupt T2 has an entry address of 73 (hex). So the org is set to 73+3 = 76 (hex)

You only need to specify the additional interrupts. The interrupts for INT0,INT1, TIMER0, TIMER1 and SERIAL are already handled by the compiler.

·CLOCKDIV : The division factor of the oscillator. By default this is 12 and when you don't specify it, 12 will be used. Some micro processors have a division factor of 6 or 4.


ACC = E0
B = F0


up = 80552
I_CT0 = 33
I_CT1 = 3B
I_CT2 = 43
I_CT3 = 4B
I_ADC = 53
I_CM0 = 5B
I_CM1 = 63
I_CM2 = 6B
I_T2 = 73
org = 76
IRAM = 256