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

PM0044

STM8 addressing modes

 

 

6.12Relative Direct addressing mode

Table 35.

Overview of Relative Direct addressing mode instructions

Addressing mode

Syntax

EA formula

Ptr Adr

Ptr Size

Dest adr

 

 

 

 

 

 

 

Direct

Relative

off

PC = PC + off

op + 1

---

PC +127/-128

 

 

 

 

 

 

 

This addressing mode is used to modify the PC register value, by adding an 8-bit signed offset to it. The offset added to the PC register value is relative to the start of the next instruction.

Table 36. Available Relative Direct instructions

Instructions

Functions

 

 

JRxx

Conditional Jump

 

 

JRA

Jump Relative Always

 

 

CALLR

Call Relative

 

 

The offset follows the op-code.

Example:

 

 

 

04A7

2717

jreq

skip

04A9

9D

nop

 

04AA

9D

nop

 

04C0

20FE

skip jra*

; Infinite loop

Action:

if (Z == 1)then PC = PC + $17 = $04A9 + $17 = $04C0 elsePC = PC= $04A9

Doc ID 13590 Rev 3

55/162

STM8 addressing modes

PM0044

 

 

Figure 21. Relative Direct addressing mode example

 

 

 

Before completion

 

 

 

CC

 

 

 

Z

JREQ SKIP

27

04A7

PC

 

 

 

 

17

04A8

04A7

 

 

 

 

 

04A9

02

 

 

 

04A7

 

 

 

Adder

 

 

 

04A9

 

 

 

EA

 

 

After completion

 

 

 

(Branch taken)

 

 

 

CC

 

 

 

 

 

 

 

 

Z = 1

 

 

 

 

 

 

 

 

 

PC

JREQ SKIP

27

04A7

 

 

 

04A9

1704A8

04A9

17

Adder

SKIP :

04C0

04C0

 

New PC

04C0

 

 

 

 

 

After completion

 

 

 

 

 

(No branch taken)

 

 

 

 

 

 

 

 

CC

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Z = 0

JREQ SKIP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

27

04A7

 

 

 

New PC

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

17

04A8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

04A9

 

 

 

04A9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Steps to Determine

Effective Address

PC = 04A7

PC = PC + 1 = 04A8 TEMP = (PC) = 17 PC = PC +1 = 04A9 Stop here if there

is no Branch; i.e., Z = 0 EA = PC + TEMP

=04A9 + 17

=04C0

New PC = EA if Branch is taken

Instruction Complete

New PC = EA = 04C0

04A9

EA

Instruction Complete

New PC = EA = 04A9

56/162

Doc ID 13590 Rev 3

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