SX Users Manual Rev. 3.1
© 2000 Scenix Semiconductor, Inc. All rights reserved.
Chapter 3 Instruction Set
top-of-stack = program counter + 1
PC(7:0) = addr8
program counter (8) = 0
program counter (11:9) = PA2:PA0
1001 kkkk kkkk
This instruction calls a subroutine. The full 12-bit address of the next program in-
struction is saved on the stack and the program counter is loaded with a new ad-
dress, which causes a jump to that program address.
Bits 7:0 come from the 8-bit constant value in the instruction, bit 8 is always 0, and
bits 11:9 come from the PA2:PA0 bits in the STATUS register. Therefore, the
subroutine must start in the bottom half of a 512-word page in the program memory
(000h to 0FFh, 200h to 2FFh, etc.).
The subroutine is terminated by any one of the return instructions, which restores
the saved address to the program counter. Execution proceeds from the instruction
following the call instruction.
2 in compatible mode (SX18/20/28AC and SX18/20/28AC75 only), or 3 in tur-
;set page of subroutine in STATUS reg.
;call subroutine addxy
;use addxy subroutine results
;more of program (not shown)
;subroutine address label
;subroutine instructions start here
;return from subroutine
The call instruction in this example calls a subroutine called addxy. When the
call instruction is executed, the address of the following instruction (the mov
$0C,W instruction) is pushed onto the stack and the program jumps to the addxy
routine. When the ret instruction is executed, the 12-bit program address saved
on the stack is popped and restored to the program counter, which causes the