Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8xC196EA microcontroller user's manual.1998.pdf
Скачиваний:
52
Добавлен:
23.08.2013
Размер:
8.29 Mб
Скачать

MEMORY PARTITIONS

Table 4-8. Selecting a Window of the Upper Register File

Register RAM

WSR or WSR1 Value

WSR or WSR1 Value

WSR Value

Locations

for 32-byte Window

for 64-byte Window

for 128-byte Window

(Hex)

(00E0–00FFH or 0060–007FH)

(00C0–00FFH or 0040–007FH)

(0080–00FFH)

 

 

 

 

03E0–03FF

5FH

 

 

03C0–03DF

5EH

2FH

 

03A0–03BF

5DH

 

 

0380–039F

5CH

2EH

17H

0360–037F

5BH

 

 

0340–035F

5AH

2DH

 

0320–033F

59H

 

 

0300–031F

58H

2CH

16H

02E0–02FF

57H

 

 

02C0–02DF

56H

2BH

 

02A0–02BF

55H

 

 

0280–029F

54H

2AH

15H

0260–027F

53H

 

 

0240–025F

52H

29H

 

0220–023F

51H

 

 

0200–021F

50H

28H

14H

01E0–01FF

4FH

 

 

01C0–01DF

4EH

27H

 

01A0–01BF

4DH

 

 

0180–019F

4CH

26H

13H

0160–017F

4BH

 

 

0140–015F

4AH

25H

 

0120–013F

49H

 

 

0100–011F

48H

24H

12H

4.3.2Addressing a Location Through a Window

After you have selected the desired window, you need to know the direct address of the memory location (the address in the lower register file). For SFRs, refer to the WSR tables in Appendix

C.For register file locations, calculate the direct address as follows:

1.Subtract the base address of the area to be remapped (from Table 4-8) from the address of the desired location. This gives you the offset of that particular location.

2.Add the offset to the base address of the window (from Table 4-9). The result is the direct address.

4-21

8XC196EA USER’S MANUAL

Table 4-9. Windowed Base Addresses

Window Size

WSR Windowed Base Address

WSR1 Windowed Base Address

(Base Address in Lower Register File)

(Base Address in Lower Register File)

 

 

 

 

32-byte

00E0H

0060H

 

 

 

64-byte

00C0H

0040H

 

 

 

128-byte

0080H

 

 

 

Appendix C includes a table of the windowable SFRs with the window selection register values and direct addresses for each window size. The following examples explain how to determine the WSR value and direct address for any windowable location. An additional example shows how to set up a window by using the linker locator.

4.3.2.132-byte Windowing Example

Assume that you wish to access location 014BH (a location in the upper register file used for gen- eral-purpose register RAM) with direct addressing through a 32-byte window. Table 4-8 on page 4-21 shows that you need to write 4AH to the window selection register. It also shows that the base address of the 32-byte memory area is 0140H. To determine the offset, subtract that base address from the address to be accessed (014BH – 0140H = 000BH). Add the offset to the base address of the window in the lower register file (from Table 4-9). The direct address is 00EBH (000BH + 00E0H) for a WSR window or 006BH (000BH + 0060H) for a WSR1 window.

4.3.2.264-byte Windowing Example

Assume that you wish to access the SFR at location 1F8CH with direct addressing through a 64byte window. Table 4-8 on page 4-21 shows that you need to write 3EH to the window selection register. It also shows that the base address of the 64-byte memory area is 1F80H. To determine the offset, subtract that base address from the address to be accessed (1F8CH – 1F80H = 000CH). Add the offset to the base address of the window in the lower register file (from Table 4-9). The direct address is 00CCH (000CH + 00C0H) for a WSR window or 004CH (000CH + 0040H) for a WSR1 window.

4.3.2.3128-byte Windowing Example

Assume that you wish to access the SFR at location 1F82H with direct addressing through a 128byte window. Table 4-8 on page 4-21 shows that you need to write 1FH to the window selection register. It also shows that the base address of the 128-byte memory area is 1F80H. To determine the offset, subtract that base address from the address to be accessed (1F82H – 1F80H = 0002H). Add the offset to the base address of the window in the lower register file (from Table 4-9). The direct address is 0082H (0002H + 0080H).

4-22

MEMORY PARTITIONS

4.3.2.4Unsupported Locations Windowing Example

Assume that you wish to access location 1FE7H (the EP_PIN register, a memory-mapped SFR) with direct addressing through a 128-byte window. This location is in the range of addresses (1FE0–1FFFH) that cannot be accessed through windows. Although you could set up the window by writing 1FH to the WSR, reading this location through the window would return FFH (all ones) and writing to it would not change the contents. However, you could directly address the remaining SFRs in the range of 1F80–1FDFH.

4.3.2.5Using the Linker Locator to Set Up a Window

In this example, the linker locator is used to set up a window. The linker locator locates the window in the upper register file and determines the value to load in the WSR for access to that window. (Please consult the manual provided with the linker locator for details.)

*********

 

mod1

**************

mod1

module main

 

;Main module for linker

public function1

 

 

extrn

?WSR

 

;Must declare ?WSR as external

wsr

equ

 

14h:byte

 

sp

equ

 

18h:word

 

oseg

 

 

 

 

 

 

var1:

dsw

1

;Allocate variables in an overlayable segment

 

var2:

dsw

1

 

 

var3:

dsw

1

 

cseg

 

 

 

 

 

function1:

 

 

 

 

push

 

wsr

 

;Prolog code for wsr

 

ldb

 

wsr, #?WSR

;Prolog code for wsr

 

add

var1, var2, var3

;Use the variables as registers

 

;

 

 

 

 

 

;

 

 

 

 

 

;

 

 

 

 

 

ldb

 

wsr, [sp]

;Epilog code for wsr

 

add

sp, #2

 

;Epilog code for wsr

 

ret

 

 

 

 

end

 

 

 

 

 

********

 

mod2

**************

4-23

8XC196EA USER’S MANUAL

public function2 extrn ?WSR

wsr

equ

14h:byte

 

sp

equ

18h:word

 

oseg

 

 

 

 

 

var1:

dsw

1

 

 

var2:

dsw

1

 

 

var3:

dsw

1

 

cseg

 

 

 

 

function2:

 

 

 

 

push

wsr

 

;Prolog code for wsr

 

ldb

wsr, #?WSR

;Prolog code for wsr

 

add var1, var2, var3

 

 

;

 

 

 

 

;

 

 

 

 

;

 

 

 

 

ldb

wsr, [sp]

;Epilog code for wsr

 

add sp, #2

 

;Epilog code for wsr

 

ret

 

 

 

end

 

 

 

 

******************************

 

The following is an example of a linker invocation to link and locate the modules and to determine the proper windowing.

RL196 MOD1.OBJ, MOD2.OBJ registers(100h-03ffh) windowsize(32)

The above linker controls tell the linker to use registers 0100–03FFH for windowing and to use a window size of 32 bytes. (These two controls enable windowing.)

The following is the map listing for the resultant output module (MOD1 by default):

SEGMENT MAP FOR mod1(MOD1):

TYPE

BASE

LENGTH

ALIGNMENT

MODULE NAME

----

----

------

---------

-----------

**RESERVED*

0000H

001AH

 

 

STACK

001AH

0006H

WORD

 

*** GAP ***

0020H

00E0H

 

 

OVRLY

0100H

0006H

WORD

MOD2

OVRLY

0106H

0006H

WORD

MOD1

*** GAP ***

010CH

1F74H

 

 

CODE

2080H

0011H

BYTE

MOD2

CODE

2091H

0011H

BYTE

MOD1

*** GAP ***

20A2H

DF5EH

 

 

4-24

Соседние файлы в предмете Электротехника