7 stack and stack pointer, 1 stack, Toshiba – Toshiba TMP87CP24AF User Manual

Page 14: 7 stack and stack pointer 1.7.1 stack, 219a

Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

Advertising
background image

TOSHIBA

TMP87CM24A/P24A

Example: BCD operation

(The A becomes 4?H after executing the following program when A =

19

h

,

B =

28

h

)

ADD

A, B

; A<-41

h

, HF<-1,CF<-0

DAA

A

;

A

41H + 06

h

= 4?H (decimal-adjust)

(4) Jump status flag (JF)

Zero or carry information is set to the JF after operation (e. g. INC, ADD, CMP, TEST).

The

JF

provides

the

jump

condition

for

conditional

jump

instructions

[JRS

T/F,

$-F2-hd],

[JR

T/F,

$ -F 2 -hd] (T or F is a condition code). Jump is performed if the JF is "1" for a true condition (T), or the

JF is "0" for a false condition (F).

The

JF

is

set

to

"1"

after

executing

the

load/exchange/swap/nibble

rotate/jump

instruction,

so

that

[JRS T, $

-F

2

-F

d] and [JR T, $

-

f

2

-

f

d] can be regarded as an unconditional jump instruction.

Example : Jump status flag and conditional jump instruction

; Jump when a carry is caused by the immediately

preceding operation instruction.

; JF is set to "1" by the immediately preceding

instruction, making it an unconditional jump

instruction.

INC

A

JRS

T, SLABLE1

LD

A,(HL)

JRS

T, SLABLE2

Example

:

The

accumulator

and

flags

become

as

shown

below

after

executing

the

following

instructions

when the WA register pair, the HL register pair, the data memory at address OOCS

h

, the carry flag

and the half carry flag contents being

"219A

h

",

"OOCS

h

",

"D7

h

",

"1" and "0", respectively.

Instruction

Acc. after

execution

Flag after execution

JF

ZF

CF

HF

ADDC

A, (HL)

72

1

0

1

1

SUBB

A, (HL)

C2

1

0

1

0

CMP

A, (HL)

9A

0

0

1

0

AND

A, (HL)

92

0

0

1

0

LD

A, (HL)

D7

1

0

1

0

ADD

A, 66H

00

1

1

1

1

Instruction

Acc. after

execution

Flag after execution

JF

ZF

CF

HF

INC A

9B

0

0

1

0

ROLC A

35

1

0

1

0

RORC A

CD

0

0

0

0

ADD WA,0F508H

16A2

1

0

1

0

MUL W, A

13DA

0

0

1

0

SET A.5

BA

1

1

1

0

1.7

Stack and Stack Pointer

1.7.1 Stack

The

stack

provides

the

area

in

which

the

return

address

or

status,

etc.

are

saved

before

a

jump

is

performed

to

the

processing

routine

during

the

execution

of

a

subroutine

call

instruction

or

the

acceptance

of

an

interrupt.

On

a

subroutine

call

instruction

[CALL

a]/[CALLP

n]/[CALLV

n],

the

contents

of

the PC (the return address) is saved; on an interrupt acceptance, the contents of the PC and the PSW are

saved

(the

PSW

is

pushed

first,

followed

by

PC

h

and

PC

l

).

Therefore,

a

subroutine call

occupies

two bytes

on the stack; an interrupt occupies three bytes.

When

returning

from

the

processing

routine,

executing

a

subroutine

return

instruction

[RET]

restores

the

contents

to

the

PC

from

the

stack;

executing

an

interrupt

return

instruction

[RETI]/[RETN]

restores

the

contents to the PC and the PSW (the PC

l

is popped first, followed by PC

h

and PSW).

The

stack

can

be

located

anywhere

within

the

data

memory

space

except

the

register

bank

area,

therefore the stack depth is limited only by the free data memory size.

3

-

24-14

2002

-

10-03

Advertising
This manual is related to the following products: