beautypg.com

Stack pointer – sp – Rainbow Electronics AT90S2313 User Manual

Page 17

background image

17

AT90S2313

0839I–AVR–06/02

• Bit 5 – H: Half-carry Flag

The Half-carry Flag H indicates a Half-carry in some arithmetic operations. See the
Instruction Set description for detailed information.

• Bit 4 – S: Sign Bit, S = N

V

The S-bit is always an exclusive or between the Negative Flag N and the Two’s Comple-
ment Overflow Flag V. See the Instruction Set description for detailed information.

• Bit 3 – V: Two’s Complement Overflow Flag

The Two’s Complement Overflow Flag V supports two’s complement arithmetics. See
the Instruction Set description for detailed information.

• Bit 2 – N: Negative Flag

The Negative Flag N indicates a negative result after the different arithmetic and logic
operations. See the Instruction Set description for detailed information.

• Bit 1 – Z: Zero Flag

The Zero Flag Z indicates a zero result after the different arithmetic and logic opera-
tions. See the Instruction Set description for detailed information.

• Bit 0 – C: Carry Flag

The Carry Flag C indicates a Carry in an arithmetic or logic operation. See the Instruc-
tion Set description for detailed information.

Note that the Status Register is not automatically stored when entering an interrupt rou-
tine and restored when returning from an interrupt routine. This must be handled by
software.

Stack Pointer – SP

An 8-bit register at I/O address $3D ($5D) forms the Stack Pointer of the AT90S2313. 8
bits are used to address the 128 bytes of SRAM in locations $60 - $DF.

The Stack Pointer points to the data SRAM stack area where the Subroutine and Inter-
rupt Stacks are located. This stack space in the data SRAM must be defined by the
program before any subroutine calls are executed or interrupts are enabled. The Stack
Pointer must be set to point above $60. The Stack Pointer is decremented by 1 when
data is pushed onto the stack with the PUSH instruction, and it is decremented by 2
when an address is pushed onto the stack with subroutine calls and interrupts. The
Stack Pointer is incremented by 1 when data is popped from the stack with the POP
instruction, and it is incremented by 2 when an address is popped from the stack with
return from subroutine RET or return from interrupt RETI.

Bit

7

6

5

4

3

2

1

0

$3D ($5D)

SP7

SP6

SP5

SP4

SP3

SP2

SP1

SP0

SPL

Read/Write

R/W

R/W

R/W

R/W

R/W

R/W

R/W

R/W

Initial value

0

0

0

0

0

0

0

0