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

PM0044

STM8 instruction set

 

 

JRxx

 

Conditional Jump

 

 

Relative Instruction

Syntax

JRxx dst

e.g. JRxx loop

Operation

PC = PC+lgth

 

 

PC <= PC + dst, if Condition is True

JRxx

Description Conditional relative jump. PC is updated by the signed addition of PC and dst, if the condition is true. Control, then passes to the statement addressed by the program counter. Else, the program continues normally.

Instruction overview

mnem

 

dst

 

 

 

 

 

 

 

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

 

 

I1

 

H

 

I0

 

 

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRxx

 

Mem

 

 

-

 

 

-

 

-

 

-

 

-

-

 

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instruction List

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

mnem

 

 

 

meaning

 

 

 

 

sym

 

 

 

Condition

 

 

Op-code (OC)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRC

 

 

 

Carry

 

 

 

 

 

 

 

 

 

 

 

 

C = 1

 

 

 

 

 

 

 

25

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JREQ

 

 

 

Equal

 

 

 

 

=

 

 

 

 

 

Z = 1

 

 

 

 

 

 

 

27

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRF

 

 

 

False

 

 

 

 

 

 

 

 

 

 

 

 

False

 

 

 

 

 

 

 

21

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRH

 

 

 

Half-Carry

 

 

 

 

 

 

 

 

 

 

 

 

H = 1

 

 

 

 

90

 

29

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRIH

 

 

 

Interrupt Line is High

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

90

 

2F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRIL

 

 

 

Interrupt Line is Low

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

90

 

2E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRM

 

 

 

Interrupt Mask

 

 

 

 

 

 

 

 

 

 

 

 

I = 1

 

 

 

 

90

 

2D

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRMI

 

 

 

Minus

 

 

 

 

< 0

 

 

 

 

 

N = 1

 

 

 

 

 

 

 

2B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRNC

 

 

 

Not Carry

 

 

 

 

 

 

 

 

 

 

 

 

C = 0

 

 

 

 

 

 

 

24

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRNE

 

 

 

Not Equal

 

 

 

 

<> 0

 

 

 

 

 

Z = 0

 

 

 

 

 

 

 

26

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRNH

 

 

 

Not Half-Carry

 

 

 

 

 

 

 

 

 

 

 

 

H = 0

 

 

 

 

90

 

28

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRNM

 

 

 

Not Interrupt Mask

 

 

 

 

 

 

 

 

 

 

 

 

I = 0

 

 

 

 

90

 

2C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRNV

 

 

 

Not Overflow

 

 

 

 

 

 

 

 

 

 

 

 

V = 0

 

 

 

 

 

 

 

28

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRPL

 

 

 

Plus

 

 

 

 

>= 0

 

 

 

 

 

N = 0

 

 

 

 

 

 

 

2A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRSGE

 

 

 

Signed Greater or Equal

 

 

 

 

>=

 

 

 

(N XOR V) = 0

 

 

 

 

2E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRSGT

 

 

 

Signed Greater Than

 

 

 

 

>

 

 

 

(Z OR (N XOR V)) = 0

 

 

 

 

2C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRSLE

 

 

 

Signed Lower or Equal

 

 

 

 

<=

 

 

 

(Z OR (N XOR V)) = 1

 

 

 

 

2D

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRSLT

 

 

 

Signed Lower Than

 

 

 

 

<

 

 

 

(N XOR V) = 1

 

 

 

 

2F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRT

 

 

 

True

 

 

 

 

 

 

 

 

 

 

 

 

True

 

 

 

 

 

 

 

20

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRUGE

 

 

 

Unsigned Greater or Equal

 

 

 

 

 

 

 

 

 

 

C = 0

 

 

 

 

 

 

 

24

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRUGT

 

 

 

Unsigned Greater Than

 

 

 

 

>

 

 

 

C = 0 and Z = 0

 

 

 

 

22

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRULE

 

 

 

Unsigned Lower or Equal

 

 

<=

 

 

 

 

C = 1 or Z = 1

 

 

 

 

23

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRC

 

 

 

Carry

 

 

 

 

 

 

 

 

 

 

 

 

C = 1

 

 

 

 

 

 

 

25

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRULT

 

 

 

Unsigned Lower Than

 

 

 

 

 

 

 

 

 

 

 

 

C = 1

 

 

 

 

 

 

 

25

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

JRV

 

 

 

Overflow

 

 

 

 

 

 

 

 

 

 

 

 

V = 1

 

 

 

 

 

 

 

29

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Detailed description

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

Asm

 

 

cy

lgth

 

 

 

 

 

Op-code(s)

 

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortoff

 

 

JRxx $15

 

 

1/2

2

 

 

 

 

 

 

Op-code

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortoff

 

 

JRxx $15

 

 

1/2

3

 

 

 

90

 

Op-code

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Doc ID 13590 Rev 3

113/162

STM8 instruction set

PM0044

 

 

LD

 

Load

LD

Syntax

LD dst,src

e.g. LD A,#$15

 

Operation

dst <= src

 

 

Description

Load the destination byte with the source byte. The dst and src can be a

 

register, a byte (low/high) of an index register or a memory/data byte. When

 

half of an index register is loaded, the other half remains unchanged.

 

Instruction overview

mnem

 

 

 

 

 

dst

 

 

 

 

 

 

 

 

src

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

I1

H

I0

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

 

 

Reg

 

 

 

 

 

 

 

 

Mem

-

-

-

-

N

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

 

 

Mem

 

 

 

 

 

 

 

 

Reg

-

-

-

-

N

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

 

 

Reg

 

 

 

 

 

 

 

 

Reg

-

-

-

-

-

 

-

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

N

R7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if bit 7 of the result is set (negative value), cleared otherwise.

 

 

Z

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R7.R6.R5.R4.R3.R2.R1.R0

 

 

 

 

 

 

 

 

 

Set if the result is zero (0x00), cleared otherwise.

 

 

 

 

 

 

Detailed description

dst

src

Asm

 

cy

lgth

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

#byte

LD A,#$55

 

1

2

 

 

A6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

shortmem

LD A,$50

 

1

2

 

 

B6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

longmem

LD A,$5000

 

1

3

 

 

C6

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(X)

LD A,(X)

 

1

1

 

 

F6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(shortoff,X)

LD A,($50,X)

 

1

2

 

 

E6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(longoff,X)

LD A,($5000,X)

 

1

3

 

 

D6

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(Y)

LD A,(Y)

 

1

2

 

90

F6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(shortoff,Y)

LD A,($50,Y)

 

1

3

 

90

E6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(longoff,Y)

LD A,($5000,Y)

 

1

4

 

90

D6

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

(shortoff,SP)

LD A,($50,SP)

 

1

2

 

 

7B

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

[shortptr.w]

LD A,[$50.w]

 

4

3

 

92

C6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

[longptr.w]

LD A,[$5000.w]

 

4

4

 

72

C6

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

([shortptr.w],X)

LD A,([$50.w],X)

 

4

3

 

92

D6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

([longptr.w],X)

LD A,([$5000.w],X)

 

4

4

 

72

D6

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

([shortptr.w],Y)

LD A,([$50.w],Y)

 

4

3

 

91

D6

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

114/162

Doc ID 13590 Rev 3

PM0044

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

STM8 instruction set

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD detailed description (Continued)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

src

 

Asm

 

 

cy

 

lgth

 

 

 

 

Op-code(s)

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortmem

A

LD $50,A

 

1

2

 

 

 

 

B7

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

A

LD $5000,A

 

1

3

 

 

 

 

C7

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(X)

A

LD (X),A

 

1

1

 

 

 

 

F7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,X)

A

LD ($50,X),A

 

1

2

 

 

 

 

E7

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,X)

A

LD ($5000,X),A

 

1

3

 

 

 

 

D7

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(Y)

A

LD (Y),A

 

1

2

 

90

 

F7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,Y)

A

LD ($50,Y),A

 

1

3

 

90

 

E7

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,Y)

A

LD ($5000,Y),A

 

1

4

 

90

 

D7

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,SP)

A

LD ($50,SP),A

 

1

2

 

 

 

 

6B

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[shortptr.w]

A

LD [$50.w],A

 

4

3

 

92

 

C7

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[longptr.w]

A

LD [$5000.w],A

 

4

4

 

72

 

C7

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],

A

LD ([$50.w],X),A

 

4

3

 

92

 

D7

 

XX

 

 

 

 

 

 

 

X)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([longptr.w],X)

A

LD

 

4

4

 

72

 

D7

 

MS

 

 

LS

 

 

 

 

([$5000.w],X),A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],

A

LD ([$50.w],Y),A

 

4

3

 

91

 

D7

 

XX

 

 

 

 

 

 

 

Y)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

src

 

Asm

 

 

cy

 

lgth

 

 

 

 

Op-code(s)

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

XL

 

A

 

LD XL,A

 

 

1

 

1

 

 

 

 

97

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

XL

 

LD A,XL

 

 

1

 

1

 

 

 

 

9F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

YL

 

A

 

LD YL,A

 

 

1

 

2

 

 

90

 

97

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

YL

 

LD A,YL

 

 

1

 

2

 

 

90

 

9F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

XH

 

A

 

LD XH,A

 

 

1

 

1

 

 

 

 

95

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

XH

 

LD A,XH

 

 

1

 

1

 

 

 

 

9E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

YH

 

A

 

LD YH,A

 

 

1

 

2

 

 

90

 

95

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

YH

 

LD A,YH

 

 

1

 

2

 

 

90

 

9E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: LDW, LDF, CLR

Doc ID 13590 Rev 3

115/162

STM8 instruction set

PM0044

 

 

LDF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Load Far

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LDF

Syntax

 

 

 

LDF dst,src

 

 

 

 

 

e.g. LDF A,($555555,X)

 

 

 

 

 

Operation

dst <= src

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Description

Load the destination byte with the source byte. The dst and src can be a

 

 

 

 

 

memory location or accumulator register.

 

 

 

 

 

 

 

 

 

 

 

 

Instruction overview

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

mnem

 

 

 

dst

 

 

 

 

 

 

 

 

src

 

 

 

 

 

 

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

 

I1

 

H

 

I0

 

 

 

N

 

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LDF

 

 

 

 

 

A

 

 

 

 

 

 

 

 

Mem

 

 

 

 

-

 

-

 

-

-

 

 

 

N

 

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LDF

 

 

 

Mem

 

 

 

 

 

 

 

 

 

A

 

 

 

 

-

 

-

 

-

-

 

 

 

N

 

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

N

 

 

 

 

R7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if bit 7 of the result is set (negative value), cleared otherwise.

 

Z

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R7.R6.R5.R4.R3.R2.R1.R0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if the result is zero (0x00), cleared otherwise.

 

 

 

 

 

 

 

 

 

 

Detailed description

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

src

 

 

 

 

 

 

 

 

 

Asm

 

cy

 

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

extmem

 

 

 

 

LDF A, $500000

1

 

4

 

 

 

 

BC

 

ExtB

 

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

(extoff,X)

 

 

 

 

LDF A,($500000,X)

1

 

4

 

 

 

 

 

AF

 

ExtB

 

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

(extoff,Y)

 

 

 

 

LDF A,($500000,Y)

1

 

5

 

90

 

 

AF

 

ExtB

 

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

([longptr.e],X)

 

LDF A,([$5000.e],X)

5

 

4

 

92

 

 

AF

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

([longptr.e],Y)

 

LDF A,([$5000.e],Y)

5

 

4

 

91

 

 

AF

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

 

[longptr.e]

 

LDF A,[$5000.e]

5

 

4

 

92

 

BC

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

src

 

 

 

 

 

 

 

 

Asm

 

 

cy

 

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

extmem

 

 

 

 

A

 

 

 

LDF $500000,A

 

1

 

 

4

 

 

 

 

 

BD

 

ExtB

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(extoff,X)

 

 

A

 

 

 

LDF ($500000,X),A

 

1

 

 

4

 

 

 

 

 

A7

 

ExtB

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(extoff,Y)

 

 

A

 

 

 

LDF ($500000,Y),A

 

1

 

 

5

 

 

90

 

A7

 

ExtB

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([longptr.e],X)

 

 

A

 

 

 

LDF ([$5000.e],X),A

 

4

 

 

4

 

 

92

 

A7

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([longptr.e],Y)

 

 

A

 

 

 

LDF ([$5000.e],Y),A

 

4

 

 

4

 

 

91

 

A7

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[longptr.e]

 

 

A

 

 

 

LDF [$5000.e],A

 

4

 

 

4

 

 

92

 

BD

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: LD, CALLF

116/162

Doc ID 13590 Rev 3

PM0044

STM8 instruction set

 

 

LDW

 

Load word

Syntax

LDW dst,src

e.g. LDW X,#$1500

Operation

dst <= src

 

LDW

Description Load the destination word (16-bit value) with the source word. The dst and src can be a 16-bit register (X, Y or SP) or a memory/data 16-bit value.

Instruction overview

mnem

 

 

dst

 

 

 

 

src

 

 

 

 

 

 

 

 

 

 

 

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

 

 

I1

 

 

H

 

 

 

I0

 

 

 

N

 

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

Reg

 

 

 

 

Mem

 

 

 

 

 

 

-

 

 

 

 

-

 

-

 

-

 

 

 

 

 

N

 

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

Mem

 

 

 

 

Reg

 

 

 

 

 

 

-

 

 

 

 

-

 

-

 

-

 

 

 

 

 

N

 

 

Z

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

Reg

 

 

 

 

Reg

 

 

 

 

 

 

-

 

 

 

 

-

 

-

 

-

 

 

 

 

 

-

 

 

 

 

-

 

 

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

SP

 

 

 

 

 

 

 

Reg

 

 

 

 

 

 

-

 

 

 

 

-

 

-

 

-

 

 

 

 

 

-

 

 

 

 

-

 

 

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LD

 

 

 

Reg

 

 

 

 

SP

 

 

 

 

 

 

-

 

 

 

 

-

 

-

 

-

 

 

 

 

 

-

 

 

 

 

-

 

 

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

N

 

 

 

R15

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if bit 7 of the result is set (negative value), cleared otherwise.

 

Z

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R15.R14.R13.R12.R11.R10.R9.R8.R7.R6.R5.R4.R3.R2.R1.R0

 

 

 

 

 

 

 

 

 

Set if the result is zero (0x0000), cleared otherwise.

 

 

 

 

 

 

 

 

 

Detailed description

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

src

 

 

 

 

 

Asm

 

 

 

cy

 

lgth

 

 

 

 

 

 

 

Op-code(s)

 

 

 

 

 

 

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

#word

 

 

 

LDW X,#$55AA

2

 

 

 

 

3

 

 

 

 

 

 

 

 

 

AE

 

 

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

shortmem

LDW X,$50

 

 

2

 

 

 

 

2

 

 

 

 

 

 

 

 

 

BE

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

longmem

 

 

 

LDW X,$5000

 

 

2

 

 

 

 

3

 

 

 

 

 

 

 

 

 

CE

 

 

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

(X)

 

 

 

LDW X,(X)

 

 

2

 

 

 

 

1

 

 

 

 

 

 

 

 

 

FE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

(shortoff,X)

LDW X,($50,X)

2

 

 

 

 

2

 

 

 

 

 

 

 

 

 

EE

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

(longoff,X)

LDW X,($5000,X)

2

 

 

 

 

3

 

 

 

 

 

 

 

 

 

DE

 

 

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

(shortoff,SP)

LDW X,($50,SP)

2

 

 

 

 

2

 

 

 

 

 

 

 

 

 

1E

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

[shortptr.w]

LDW X,[$50.w]

5

 

 

 

 

3

 

 

 

 

92

 

 

 

CE

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

[longptr.w]

LDW X,[$5000.w]

5

 

 

 

 

4

 

 

 

 

72

 

 

 

CE

 

 

 

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

([shortptr.w],X)

LDW X,([$50.w],X)

5

 

 

 

 

3

 

 

 

 

92

 

 

 

DE

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

([longptr.w],X)

LDW

 

 

5

 

 

 

 

4

 

 

 

 

72

 

 

 

DE

 

 

 

MS

LS

 

 

 

 

 

 

 

X,([$5000.w],X)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

src

 

 

 

Asm

 

 

 

cy

 

lgth

 

 

 

 

 

 

 

Op-code(s)

 

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortmem

 

X

 

LDW $50,X

 

 

 

2

 

 

2

 

 

 

 

 

 

 

 

 

BF

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

 

X

 

LDW $5000,X

 

 

 

2

 

 

3

 

 

 

 

 

 

 

 

 

CF

 

 

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(X)

 

 

 

Y

 

LDW (X),Y

 

 

 

2

 

 

1

 

 

 

 

 

 

 

 

 

FF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,X)

 

Y

 

LDW ($50,X),Y

 

 

 

2

 

 

2

 

 

 

 

 

 

 

 

 

EF

 

 

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,X)

 

Y

 

LDW ($5000,X),Y

 

2

 

 

3

 

 

 

 

 

 

 

 

 

DF

 

 

 

MS

 

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Doc ID 13590 Rev 3

117/162

STM8 instruction set

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PM0044

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LDW detailed description (Continued)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

src

 

 

Asm

 

 

 

cy

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,SP)

X

LDW ($50,SP),X

 

 

2

 

2

 

 

 

 

1F

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[shortptr.w]

X

LDW [$50.w],X

 

 

5

 

3

 

 

92

CF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[longptr.w]

X

LDW [$5000.w],X

 

 

5

 

4

 

 

72

CF

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],X)

Y

LDW ([$50.w],X),Y

 

 

5

 

3

 

 

92

DF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([longptr.w],X)

Y

LDW ([$5000.w],X),Y

 

 

5

 

4

 

 

72

DF

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

src

 

 

Asm

 

 

 

cy

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

#word

 

 

LDW Y,#$55AA

 

 

2

 

4

 

 

90

AE

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

shortmem

 

LDW Y,$50

 

 

2

 

3

 

 

90

BE

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

longmem

 

LDW Y,$5000

 

 

2

 

4

 

 

90

CE

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

(Y)

 

 

LDW Y,(Y)

 

 

2

 

2

 

 

90

FE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

(shortoff,Y)

 

LDW Y,($50,Y)

 

 

2

 

3

 

 

90

EE

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

(longoff,Y)

 

LDW Y,($5000,Y)

 

 

2

 

4

 

 

90

DE

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

(shortoff,SP)

 

LDW Y,($50,SP)

 

 

2

 

2

 

 

 

 

16

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

[shortptr.w]

 

LDW Y,[$50.w]

 

 

5

 

3

 

 

91

CE

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

([shortptr.w],Y)

 

LDW Y,([$50.w],Y)

 

 

5

 

3

 

 

91

DE

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

src

 

 

Asm

 

 

 

cy

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortmem

Y

 

 

LDW $50,Y

 

 

 

2

 

3

 

 

 

90

BF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

Y

 

 

LDW $5000,Y

 

 

 

2

 

4

 

 

 

90

CF

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(Y)

 

 

X

 

 

LDW (Y),X

 

 

 

2

 

2

 

 

 

90

FF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,Y)

X

 

 

LDW ($50,Y),X

 

 

 

2

 

3

 

 

 

90

EF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,Y)

X

 

 

LDW ($5000,Y),X

 

 

 

2

 

4

 

 

 

90

DF

MS

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,SP)

Y

 

 

LDW ($50,SP),Y

 

 

 

2

 

2

 

 

 

 

17

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[shortptr.w]

Y

 

 

LDW [$50.w],Y

 

 

 

5

 

3

 

 

 

91

CF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],Y)

X

 

 

LDW ([$50.w],Y),X

 

 

 

5

 

3

 

 

 

91

DF

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

src

 

 

 

 

 

 

 

cy

 

lgth

 

 

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

 

X

 

 

LDW Y,X

 

 

1

 

2

 

 

 

90

93

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

 

Y

 

 

LDW X,Y

 

 

1

 

1

 

 

 

 

93

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

 

 

SP

 

 

LDW X,SP

 

 

1

 

1

 

 

 

 

96

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SP

 

 

X

 

 

LDW SP,X

 

 

1

 

1

 

 

 

 

94

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

 

 

SP

 

 

LDW Y,SP

 

 

1

 

2

 

 

 

90

96

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SP

 

 

Y

 

 

LDW SP,Y

 

 

1

 

2

 

 

 

90

94

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note:

LDW Y,[longptr.w] and LDW [longptr.w],Y are not implemented. They can be emulated using

 

EXGW X,Y.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: LD, CLRW

118/162

Doc ID 13590 Rev 3

PM0044 STM8 instruction set

MOV

 

Move

MOV

Syntax

MOV dst,src

e.g.

MOV $80,#$AA

Operation

dst<= src

 

 

Description

Moves a byte of data from a source address to a destination address. Data

 

is examined as it is moved. The accumulator is not affected.

 

There are 3 addressing modes for the MOV instruction:

An immediate byte to a direct memory location

A direct memory location to another direct memory location (from $00 to $FF)

A direct memory location to another direct memory location (from

$0000 to $FFFF)

Instruction overview

mnem

 

dst

 

src

 

 

 

 

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

I1

 

H

 

I0

 

 

N

 

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MOV

 

Mem

 

Imm

 

 

-

 

 

-

-

-

 

 

-

 

 

-

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MOV

 

Mem

 

Mem

 

 

-

 

 

-

-

-

 

 

-

 

 

-

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Detailed description

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

src

 

Asm

 

 

cy

lgth

 

 

 

 

 

Op-code(s)

 

 

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

 

#byte

MOV $8000, #$AA

 

 

1

4

 

 

 

35

 

XX

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortmem

shortmem

 

MOV $80,$10

 

 

1

3

 

 

 

45

 

XX2

 

XX1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

longmem

 

MOV

 

 

1

5

 

 

 

55

 

MS2

 

LS2

 

MS1

 

LS1

 

 

$8000,$1000

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: LD, EXG

Doc ID 13590 Rev 3

119/162

STM8 instruction set

PM0044

 

 

MUL

Multiply (unsigned)

MUL

Syntax

MUL dst,src

e.g. MUL X,A

 

Operation

dst:src <= dst x src

 

 

Description

Multiplies the 8-bit value in index register, low byte, (XL or YL) by the 8-bit

 

value in the accumulator to obtain a 16-bit unsigned result in the index

 

register. After the operation, index register contains the 16-bit result. The

 

accumulator remains unchanged. The initial value of the high byte of the

 

index register (XH or YH) is ignored.

 

Instruction overview

mnem

dst

src

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

V

I1

 

H

I0

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MUL

X

XL,A

-

-

 

0

-

-

 

-

0

 

 

 

 

 

 

 

 

 

 

 

 

MUL

Y

YL,A

-

-

 

0

-

-

 

-

0

 

 

 

 

 

 

 

 

 

 

 

 

C: 0

Cleared.

Detailed description

dst

src

Asm

 

cy

lgth

 

 

Op-code(s)

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

X

A

MUL X,A

 

4

1

 

 

42

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y

A

MUL Y,A

 

4

2

 

90

42

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: ADD, ADC, SUB, SBC

120/162

Doc ID 13590 Rev 3

PM0044 STM8 instruction set

NEG

 

 

 

 

 

 

Negate (Logical 2’s complement)

 

 

 

 

NEG

 

Syntax

 

NEG dst

 

 

 

 

 

 

 

 

 

 

 

e.g. NEG (X)

 

 

 

 

 

 

 

Operation

 

dst <= (dst XOR FF) + 1, or 00 - dst

 

 

 

 

 

 

 

 

 

 

 

 

Description

 

The destination byte is read, then each bit is toggled (inverted), and the

 

 

 

result is incremented before it is written at the destination byte. The

 

 

 

 

 

destination is either a memory byte or a register. The Carry is cleared if the

 

 

 

result is zero. This instruction is used to negate signed values. This

 

 

 

 

 

instruction is compact, and does not affect any register when used with

 

 

 

RAM variables.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instruction overview

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

mnem

 

 

 

 

 

dst

 

 

 

 

 

 

 

 

 

 

 

 

 

Affected condition flags

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

 

I1

 

H

 

 

I0

 

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NEG

 

 

 

 

Mem

 

 

 

 

 

 

V

 

-

 

 

-

 

-

 

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NEG

 

 

 

 

 

A

 

 

 

 

 

 

V

 

-

 

 

-

 

-

 

N

 

Z

C

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R7.R6.R5.R4.R3.R2.R1.R0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if there is an arithmetic overflow on the 8-bit representation of the

 

 

 

result. The V bit will set when the content of "dst" was $80 (-128) prior to

 

 

 

the NEG operation, cleared otherwise.

 

 

 

 

 

 

 

 

 

 

 

 

N

 

R7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if bit 7 of the result is set (negative value), cleared otherwise.

 

 

 

Z

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

R7.R6.R5.R4.R3.R2.R1.R0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if the result is zero (0x00), cleared otherwise.

 

 

 

 

 

 

 

C

 

R7+R6+R5+R4+R3+R2+R1+R0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Set if a borrow in the implied subtraction from zero, cleared otherwise. The

 

 

 

C bit will be set in all cases except when the contents of "dst" was $00 prior

 

 

 

to the NEG operation.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Detailed description

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dst

 

 

 

Asm

 

 

 

cy

 

 

 

lgth

 

 

 

 

 

 

Op-code(s)

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

NEG A

 

 

1

 

1

 

 

 

 

 

40

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

shortmem

NEG $F5

 

 

1

 

2

 

 

 

 

 

30

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

longmem

NEG $F5C2

 

 

1

 

4

 

 

72

 

50

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(X)

NEG(X)

 

 

1

 

1

 

 

 

 

 

70

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,X)

NEG($F5,X)

 

 

1

 

2

 

 

 

 

 

60

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,X)

NEG($F5C2,X)

 

 

1

 

4

 

 

72

 

40

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(Y)

NEG(Y)

 

 

1

 

2

 

 

90

 

70

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,Y)

NEG($F5,Y)

 

 

1

 

3

 

 

90

 

60

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(longoff,Y)

NEG($F5C2,Y)

 

 

1

 

4

 

 

90

 

40

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(shortoff,SP)

NEG($F5,SP)

 

 

1

 

2

 

 

 

 

 

00

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[shortptr.w]

NEG($F5)

 

 

4

 

3

 

 

92

 

30

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Doc ID 13590 Rev 3

121/162

STM8 instruction set

 

 

 

 

 

 

 

 

 

 

 

PM0044

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NEG detailed description (continued)

 

 

 

 

 

 

 

 

 

 

 

 

dst

Asm

 

cy

lgth

 

 

 

Op-code(s)

 

 

ST7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[longptr.w]

NEG($F5C2.w)

 

4

4

 

72

30

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],X)

NEG([$F5],X)

 

4

3

 

92

60

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([longptr.w],X)

NEG([$F5C2.w],X)

 

4

4

 

72

60

 

MS

 

LS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

([shortptr.w],Y)

NEG([$F5],Y)

 

4

3

 

91

60

 

XX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also: NEGW, CPL, AND, OR, XOR

122/162

Doc ID 13590 Rev 3

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