Texas Instruments MSC1210 User Manual

Page 39

Advertising
background image

Referencing SFRs

3-3

Special Function Registers (SFRs)

3.2

Referencing SFRs

When writing code in assembly language, SFRs may be referenced either by
their name or their address.

For example, the SBUF0 SFR is at address 99

H

(see Table 3−1). In order to

write the value 24

H

to the SBUF SFR in assembly language, it would be written

in code as:

MOV 99h,#24h

This instruction moves the value 24

H

into address 99

H

. The value 99

H

is in the

range of 80

H

to FF

H

, and, therefore, refers to an SFR. Furthermore, because

99

H

refers to the SBUF0 SFR, this instruction will accomplish the goal of writing

the value 24

H

to the SBUF0 SFR.

Although the above instruction certainly works, it is not necessarily easy to re-
member the address of each SFR when writing software. Thus, all 8052 as-
semblers allow the name of the SFR to be used in code rather than its numeric
address. The above instruction would more commonly be written as:

MOV SBUF0,#24h

The instruction is much easier to read because it is obvious the SBUF0 SFR
is being accessed. The assembler will automatically convert this to its numeric
address at assemble time.

Note:

Many of the SFRs that the MSC1210 uses are MSC1210-specific; only 26
are recognized by the original 8052. It is usually necessary to include a head-
er file or an include file in your program to define the additional SFRs sup-
ported by the MSC1210. Failing to do so may result in the assembler or com-
piler reporting compile errors. Please refer to the documentation for the com-
piler or assembler to discover how new SFRs of the MSC1210 must be de-
fined in the development platform to be used.

3.2.1

Referencing Bits of SFRs

Individual bits of SFRs are referenced in one of two ways. The general conven-
tion is to name the SFR followed by a period and the bit number. For example,
SCON0.0 refers to bit 0 (the least significant bit) of the SCON0 SFR. SCON0.7
refers to bit 7 (the most significant bit) of SCON0.

These bits also have names: SCON0.0 is RI and SCON0.7 is SM0_0. It is also
acceptable to refer to the bits by their name, although in this document they
will usually be referred to in the SCON0.0 format, because that defines which
bit is in which SFR.

Advertising