2 MEMORY AND OPERATIONS

The difference between CALL and CALZ is shown in Figure 2.1.7.2.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CALL with PSET

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bank 0

 

Bank 0

Page 15

 

Bank 1

 

 

Bank 1

Page 15

 

 

 

 

 

 

 

 

 

 

can go anywhere

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bank

0

Page 14

 

 

within a bank

 

 

 

Bank

1

Page 14

 

 

 

 

 

 

 

 

 

 

 

Step

0

 

 

 

 

 

 

 

Step

0

 

 

 

 

 

 

 

 

 

 

 

 

 

Step

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CALL

 

 

 

 

 

 

 

 

 

 

 

 

 

PSET

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bank 0

Page 3

 

 

 

 

 

 

 

 

 

 

Bank 1

Page 3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CALL

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bank 0

 

Page 1

 

CALZ

 

 

 

 

 

 

 

 

 

Bank 1

 

Page 1

 

 

 

 

Step

254

 

 

 

 

Bank

0

Page

0

 

 

 

 

255

 

 

 

 

 

Bank

1

Page

0

 

 

 

 

 

Step 255

 

 

 

 

Step

0

 

 

 

 

 

 

 

 

 

 

 

 

Step

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step

1

 

 

 

 

 

CALZ

 

 

 

 

CALL without PSET

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CALL and CALZ

 

 

 

 

 

 

 

 

 

 

 

 

 

can go anywhere

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

in a page

 

 

 

 

 

 

 

 

 

 

cannot go

 

 

 

 

 

 

 

 

 

 

 

 

 

Step

 

 

254

 

 

 

 

 

 

Step

 

 

254

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

between banks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 255

 

 

 

 

 

 

 

 

 

Step 255

 

 

 

 

 

 

 

CALZ can only go to page 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

of the current bank
Fig. 2.1.7.2 The difference between CALL and CALZ instructions

2.1.8 RET and RETS instructions

The RET instruction causes a return from a subroutine to the address immediately following the address from where that subroutine was called. The RETS instruction causes a return to the address following this address. Proper use of RET and RETS allows simple conditional exits subroutines back to the main routine. See Figure 2.1.8.1.

 

 

 

 

 

Bank 0

Page 0

 

 

 

 

 

 

 

Program memory

 

 

 

 

 

 

 

 

PSET 0AH

 

 

 

 

 

 

 

 

CALL DDD

 

 

 

 

 

 

 

 

 

 

 

LD

A,0

 

 

 

 

 

Bank 0 Page

 

10

 

 

 

 

 

 

LD

B,0

 

 

 

 

 

Program memory

 

 

 

 

 

 

 

 

 

 

 

 

DDD....................

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

RET

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

RETS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fig. 2.1.8.1 Difference between RET and RETS instructions

2.1.9 Stack considerations for call instructions

When a subroutine is called, the return address is loaded into the stack and retrieved when control is returned to the calling program. Nesting allows efficient usage of the stack area.

As the stack area resides in the data memory, care should be taken to ensure that the stack area is not corrupted by other data.

S1C6200/6200A CORE CPU MANUAL

EPSON

7