Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
50
Добавлен:
14.04.2015
Размер:
1.37 Mб
Скачать

216

Chapter 8. Library Reference

 

 

PBYTE

The PBYTE macro allows you to access individual bytes in one page of the external data memory of the 8051. You may use this macro in your programs as follows:

rval = PBYTE [0x0002]; PBYTE [0x0002] = 38;

to read or write the contents of the byte in pdata memory at address 0002h.

PWORD

The PWORD macro allows you to access individual words in one page of the external data memory of the 8051. You may use this macro in your programs as follows:

rval = PWORD [0x0002]; PWORD [0x0002] = 57;

to read or write the contents of the word in pdata memory at address 0004h (2 × sizeof (unsigned int) = 4).

NOTE

The index used with this macro does not represent the memory address of the integer value. To obtain the memory address, you must multiply the index by the size of an integer (2 bytes).

8

C51 Compiler

217

 

 

XBYTE

The XBYTE macro allows you to access individual bytes in the external data memory of the 8051. You may use this macro in your programs as follows:

rval = XBYTE [0x0002]; XBYTE [0x0002] = 57;

to read or write the contents of the byte in external data memory at address 0002h.

XWORD

The XWORD macro allows you to access individual words in the external data memory of the 8051. You may use this macro in your programs as follows:

rval = XWORD [2]; XWORD [2] = 57;

to read or write the contents of the word in external data memory at address 0004h (2 × sizeof (unsigned int) = 4).

NOTE

The index used with this macro does not represent the memory address of the integer value. To obtain the memory address, you must multiply the index by the size of an integer (2 bytes).

8

Соседние файлы в папке HLP