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

PM0044

STM8 addressing modes

 

 

6.14Bit Direct (Long) Relative addressing mode

Table 39.

Overview of Bit Direct (Long) Relative addressing mode

 

Addressing mode

Syntax

EA formula

Ptr Adr

Ptr Size

Dest adr

 

 

 

 

 

 

 

 

 

 

Long

 

 

(longmem)

op + 1..2

Word

0000..FFFF

Bit

Relative

longmem, #pos, off

 

 

 

 

 

 

 

PC +127/-

Direct

PC = PC + off

op + 3

Byte

 

 

 

 

 

 

128

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This addressing mode is a combination between the Bit Direct addressing mode (for data addressing) and Relative Direct mode (for PC computation).

The data byte required for the operation is found by its memory address, which follows the op-code. The bit used for the test operation is selected by the bit selector which is encoded in the instruction op-code. Following the logical test operation, the PC register value can be modified, by adding an 8-bit signed offset to it.

Table 40. Available Bit Direct Relative instructions

Instructions

Functions

 

 

BTJT, BTJF

Bit Test and Jump

 

 

The data address is a word, thus allowing 0000 to FFFF addressing space (requires 2 bytes after the op-code). The bit selector #n (n=0 to 7) selects the nth bit from the byte pointed to by the address. The offset follows the op-code and data address.

Example:

 

 

 

 

104B

00

 

DRA

dc.b

$00 ; Port A data

 

 

 

 

 

register (input

 

 

 

 

 

value)

 

 

 

bit0

equ

$0 ; data bit 0

04A7

7201104BFB wait_1

BTJF

DRA, bit0, wait_1

 

04AC

....

cont_0

 

 

 

Action:

Test = select_bit(0, ($4B)) = select_bit(0, DRA)

if (Test /= 1)

then

PC = PC + $FB

=

$0004AC - $05 =

 

 

 

$0004A7

 

else

PC = PC

=

$0004AC

Doc ID 13590 Rev 3

59/162

STM8 addressing modes

PM0044

 

 

Figure 23. Bit Long Direct Relative addressing mode example

DRA .byte

DRA

b0

DRA.b0 =? 0

PC

 

 

104C

 

 

04A7

 

 

 

 

 

 

05

 

 

 

04A7

wait_1

72

04A7

Adder

BTJF DRA, #0, wait_1

 

 

01

04A8

 

 

10

04A9

04AC

 

 

 

4B

04AA

EA

 

 

 

FB

04AB

 

 

 

 

 

 

 

 

 

 

After completion

 

 

 

 

 

 

 

(Branch taken)

 

 

 

 

 

 

 

 

 

 

(EA)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

b0 = 0

 

 

wait_1

 

 

04A7

 

 

 

 

 

 

 

 

72

 

 

 

 

 

 

 

PC

BTJF DRA, #0, wait_1

 

 

04A7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

01

 

04A8

New PC

 

 

04AC

 

10

 

04A9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4B

 

04AA

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FB

 

 

 

 

 

 

 

 

 

 

 

 

 

04AB

 

 

FB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Adder

Steps to Determine

Effective Address

PC = 04A7

PC = PC + 2 = 04A9

EA = (PC):(PC+1) = 104B Test = (EA).b0

PC = PC + 2 = 04AB

TEMP = (PC) = FC

PC = PC +1 = 04AC Stop here if there

is no Branch; i.e., Test = TRUE (1) EA = PC + TEMP

=04AA + FD

=04A7

New PC = EA if Branch is taken

Instruction Complete

New PC = EA = 04A7

04AC

wait_1

BTJF DRA, #0, wait_1

04A7

EA

 

 

After completion

 

 

(No branch taken)

 

 

 

 

 

 

(EA)

 

 

 

 

 

 

b0 = 1

Instruction Complete

72

04A7

 

 

 

 

 

New PC = EA = 04AC

 

 

 

 

 

 

 

 

 

 

 

 

01

04A8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

10

04A9

 

 

 

 

 

 

4B

04AA

 

 

 

 

 

 

 

 

 

 

 

 

 

FB

04AB

 

 

 

New PC

 

 

 

 

 

 

 

 

 

04AC

 

 

 

 

 

 

 

 

 

 

04AC

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

60/162

Doc ID 13590 Rev 3

Соседние файлы в папке Минимум документации STM8