ImageCraft Assembly Language Guide, Document # 001-44475 Rev. *B
43
M8C Instruction Set
4.6
Call Function
CALL
Adds the signed argument to the current
PC+2
value resulting in a new PC that determines the
address of the first byte of the next instruction. The current PC value is defined as the PC value that
corresponds to the ROM address of the first byte of the next instruction.
Two pushes are used to store the Program Counter (
PC+2
) on the stack. First, the upper 8 bits of the
PC (CPU_PC register) are placed on the stack followed by the lower 8 bits. The Stack Pointer is
post-incremented for each push. For devices with more than 256 bytes of RAM, the stack is confined
to a single designated stack page defined in the device data sheet. The M8C automatically selects
the stack page as the destination for the push during the
CALL
instruction. Therefore, a
CALL
instruction may be issued in any RAM page. After the
CALL
instruction has completed, user code will
be operating from the same RAM page as before the
CALL
instruction was executed.
This instruction has a 12-bit two’s-complement relative address that is added to the PC. The 12 bits
are packed into the two-byte instruction format by using the lower nibble of the opcode and the sec-
ond byte of the instruction format. Therefore, all opcodes with an upper nibble of 9 are
CALL
instruc-
tions. The “x” character is used in the table below to indicate that the first byte of a
CALL
instruction
can have one of 16 values (i.e., 0x90, 0x91, 0x92,..., 0x9F).
Instructions
Operation
Opcode
Cycles Bytes
Mnemonic
Argument
CALL
expr
0x9x
11
2
Conditional
Flags:
CF
ZF
Unaffected.
Unaffected.
Example:
0000
_main:
0000
40
nop
0001
90 E8
call SubFun
0003
40
nop
Note that the relative address for the CALL above is positive
(0xE8) and that the sum of that address and the PC value for
the first byte of the next instruction (0x0003) equals the
address of the SubFun label (0xE8 + 0x0003 = 0x00EB).
0004
9F FA
call _main
Note that the call to Main uses a negative address (0xFA).
0006
00EB
org 0x00EB
00EB
SubFun:
00EB
40
nop
00EC
7F
ret
PC
PC 2 k
2048
–
k 2047
+ +
Summary of Contents for PSoC DESIGNER ImageCraft M8C
Page 6: ...6 ImageCraft Assembly Language Guide Document 001 44475 Rev B Contents Feedback ...
Page 10: ...10 ImageCraft Assembly Language Guide Document 001 44475 Rev B Introduction Feedback ...
Page 24: ...24 ImageCraft Assembly Language Guide Document 001 44475 Rev B M8C Microprocessor Feedback ...
Page 95: ...ImageCraft Assembly Language Guide Document 001 44475 Rev B 95 Assembler Directives Feedback ...
Page 96: ...96 ImageCraft Assembly Language Guide Document 001 44475 Rev B Assembler Directives Feedback ...
Page 104: ...104 ImageCraft Assembly Language Guide Document 001 44475 Rev B Feedback ...
Page 108: ...108 ImageCraft Assembly Language Guide Document 001 44475 Rev B Index Feedback ...