2 storing 16-bit data in memory, Storing 16-bit data in memory, Storing 16-bit operands – FUJITSU Semiconductor Controller MB89950/950A User Manual

Page 40: Storing 16-bit data on stack

Advertising
background image

26

CHAPTER 3 CPU

3.1.2

Storing 16-bit Data in Memory

For 16-bit data and the stack, store the upper data in the lower memory address value.

Storing 16-bit data in RAM

When writing 16-bit data to memory, store the upper byte at the lower address and the lower byte at the

next address. Handle reading of 16-bit data in the same way.

Figure 3.1-2 "Storing 16-bit data in memory" shows how 16-bit data is stored in memory.

Figure 3.1-2 Storing 16-bit data in memory

Storing 16-bit operands

The same byte order applies when specifying a 16-bit operand in an instruction. Store the upper byte at the

address following the operation code (instruction) and the lower byte at the next address.

The byte ordering applies to both 16-bit immediate data and operands that specify a memory address.

Figure 3.1-3 "Byte order of 16-bit data in an instruction" shows how 16-bit data is stored in an instruction.

Figure 3.1-3 Byte order of 16-bit data in an instruction

Storing 16-bit data on stack

The same byte order applies when saving 16-bit register data on the stack during an interrupt or similar.

The upper byte is stored in the lower address.

Before execution

1 2 3 4

H

0080

H

0081

H

0082

H

0083

H

A

0080

H

0081

H

0082

H

0083

H

After execution

1 2 3 4

H

12

H

34

H

Memory

Memory

MOVW 0081H,A

A

Before execution

1 2 3 4

H

0080

H

0081

H

0082

H

0083

H

A

0080

H

0081

H

0082

H

0083

H

After execution

1 2 3 4

H

12

H

34

H

Memory

Memory

MOVW 0081H,A

A

.
.
.

[Example]

MOV A,5678H

; Extended address

MOVW A,#1234H

; 16-bit immediate data

X X X 0

H

XX XX

X X X 2

H

60 56 78

; Extended address

X X X 5

H

E4 12 34

; 16-bit immediate data

X X X 8

H

XX

.
.
.

After assembly

Advertising