Ic Samsung s3f9454
Ic Samsung s3f9454
Ic Samsung s3f9454
OVERVIEW
The SAM88RCRI instruction set is designed to support the large register file. It includes a full complement of
8-bit arithmetic and logic operations. There are 41 instructions. No special I/O instructions are necessary because
I/O control and data registers are mapped directly into the register file. Flexible instructions for bit addressing,
rotate, and shift operations complete the powerful data manipulation capabilities of the SAM88RCRI instruction
set.
REGISTER ADDRESSING
To access an individual register, an 8-bit address in the range 0-255 or the 4-bit address of a working register is
specified. Paired registers can be used to construct 13-bit program memory or data memory addresses. For
detailed information about register addressing, please refer to Chapter 2, "Address Spaces".
ADDRESSING MODES
There are six addressing modes: Register (R), Indirect Register (IR), Indexed (X), Direct (DA), Relative (RA), and
Immediate (IM). For detailed descriptions of these addressing modes, please refer to Chapter 3, "Addressing
Modes".
6-1
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Load Instructions
Arithmetic Instructions
Logic Instructions
6-2
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
6-3
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
The flags register FLAGS contains eight bits that describe the current status of CPU operations. Four of these
bits, FLAGS.4–FLAGS.7, can be tested and used with conditional jump instructions;
FLAGS register can be set or reset by instructions as long as its outcome does not affect the flags, such as, Load
instruction. Logical and Arithmetic instructions such as, AND, OR, XOR, ADD, and SUB can affect the Flags
register. For example, the AND instruction updates the Zero, Sign and Overflow flags based on the outcome of
the AND instruction. If the AND instruction uses the Flags register as the destination, then simultaneously, two
write will occur to the Flags register producing an unpredictable result.
MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB
FLAG DESCRIPTIONS
6-4
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
6-5
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
RR Register pair or working register pair reg or RRp (reg = 0–254, even number only, where
p = 0, 2, ..., 14)
IR Indirect register or indirect working register @Rn or @reg (reg = 0–255, n = 0–15)
IRR Indirect register pair or indirect working @RRp or @reg (reg = 0–254, even only, where
register pair p = 0, 2, ..., 14)
XS Indexed (short offset) addressing mode #addr[RRp] (addr = range – 128 to + 127, where
p = 0, 2, ..., 14)
XL Indexed (long offset) addressing mode #addr [RRp] (addr = range 0–8191, where
p = 0, 2, ..., 14)
RA Relative addressing mode addr (addr = number in the range + 127 to – 128 that
is an offset relative to the address of the next
instruction)
6-6
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
OPCODE MAP
– 0 1 2 3 4 5 6 7
R 4 OR OR OR OR OR
r1,r2 r1,Ir2 R2,R1 IR2,R1 R1,IM
I 7 PUSH PUSH TM TM TM TM TM
R2 IR2 r1,r2 r1,Ir2 R2,R1 IR2,R1 R1,IM
B 8 LD
r1, x, r2
B 9 RL RL LD
R1 IR1 r2, x, r1
L A CP CP CP CP CP LDC
r1,r2 r1,Ir2 R2,R1 IR2,R1 R1,IM r1, Irr2, xL
6-7
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
OPCODE MAP
– 8 9 A B C D E F
U 0 LD LD JR LD JP INC
r1,R2 r2,R1 cc,RA r1,IM cc,DA r1
P 1 ↓ ↓ ↓ ↓ ↓ ↓
P 2
E 3
R 4
N 6 IDLE
I 7 ↓ ↓ ↓ ↓ ↓ ↓ STOP
B 8 DI
B 9 EI
L A RET
E B IRET
C RCF
H D ↓ ↓ ↓ ↓ ↓ ↓ SCF
E E CCF
X F LD LD JR LD JP INC NOP
r1,R2 r2,R1 cc,RA r1,IM cc,DA r1
6-8
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
CONDITION CODES
The opcode of a conditional jump always contains a 4-bit field called the condition code (cc). This specifies under
which conditions it is to execute the jump. For example, a conditional jump with the condition code for "equal"
after a compare operation only jumps if the two operands are equal. Condition codes are listed in Table 6-6.
The carry (C), zero (Z), sign (S), and overflow (V) flags are used to control the operation of conditional jump
instructions.
NOTES:
1. It indicates condition codes that are related to two different mnemonics but which test the same flag.
For example, Z and EQ are both true if the zero flag (Z) is set, but after an ADD instruction, Z would probably be used;
after a CP instruction, however, EQ would probably be used.
2. For operations involving unsigned numbers, the special condition codes UGE, ULT, UGT, and ULE must be used.
6-9
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
INSTRUCTION DESCRIPTIONS
This section contains detailed information and programming examples for each instruction in the SAM87Ri
instruction set. Information is arranged in a consistent format for improved readability and for fast referencing. The
following information is included in each instruction description:
6-10
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Flags: C: Set if there is a carry from the most significant bit of the result; cleared otherwise.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result is negative; cleared otherwise.
V: Set if arithmetic overflow occurs, that is, if both operands are of the same sign and the
result is of the opposite sign; cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 12 r r
6 13 r lr
Examples: Given: R1 = 10H, R2 = 03H, C flag = "1", register 01H = 20H, register 02H = 03H, and
register 03H = 0AH:
In the first example, destination register R1 contains the value 10H, the carry flag is set to "1", and
the source working register R2 contains the value 03H. The statement "ADC R1,R2" adds 03H
and the carry flag value ("1") to the destination value 10H, leaving 14H in register R1.
6-11
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
ADD — Add
ADD dst,src
Flags: C: Set if there is a carry from the most significant bit of the result; cleared otherwise.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result is negative; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, if both operands are of the same sign and the result is
of the opposite sign; cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 02 r r
6 03 r lr
Examples: Given: R1 = 12H, R2 = 03H, register 01H = 21H, register 02H = 03H, register 03H = 0AH:
In the first example, destination working register R1 contains 12H and the source working register
R2 contains 03H. The statement "ADD R1,R2" adds 03H to 12H, leaving the value 15H in
register R1.
6-12
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always cleared to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 52 r r
6 53 r lr
Examples: Given: R1 = 12H, R2 = 03H, register 01H = 21H, register 02H = 03H, register 03H = 0AH:
In the first example, destination working register R1 contains the value 12H and the source
working register R2 contains 03H. The statement "AND R1,R2" logically ANDs the source
operand 03H with the destination operand value 12H, leaving the value 02H in register R1.
6-13
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Operation: SP ← SP – 1
@SP ← PCL
SP ← SP –1
@SP ← PCH
PC ← dst
The current contents of the program counter are pushed onto the top of the stack. The program
counter value used is the address of the first instruction following the CALL instruction. The
specified destination address is then loaded into the program counter and points to the first
instruction of a procedure. At the end of the procedure the return instruction (RET) can be used to
return to the original program flow. RET pops the top of the stack back into the program counter.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 3 14 F6 DA
In the first example, if the program counter value is 1A47H and the stack pointer contains the
value 0B2H, the statement "CALL 1521H" pushes the current PC value onto the top of the stack.
The stack pointer now points to memory location 00H. The PC is then loaded with the value
1521H, the address of the first instruction in the program sequence to be executed.
If the contents of the program counter and stack pointer are the same as in the first example, the
statement "CALL @RR0" produces the same result except that the 49H is stored in stack
location 01H (because the two-byte instruction format was used). The PC is then loaded with the
value 1521H, the address of the first instruction in the program sequence to be executed.
6-14
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Operation: C ← NOT C
The carry flag (C) is complemented. If C = "1", the value of the carry flag is changed to logic
zero; if C = "0", the value of the carry flag is changed to logic one.
Flags: C: Complemented.
No other flags are affected.
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 EF
CCF
If the carry flag = "0", the CCF instruction complements it in the FLAGS register (0D5H),
changing its value from logic zero to logic one.
6-15
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
CLR — Clear
CLR dst
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 B0 R
4 B1 IR
Examples: Given: Register 00H = 4FH, register 01H = 02H, and register 02H = 5EH:
In Register (R) addressing mode, the statement "CLR 00H" clears the destination register 00H
value to 00H. In the second example, the statement "CLR @01H" uses Indirect Register (IR)
addressing mode to clear the 02H register value to 00H.
6-16
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
COM — Complement
COM dst
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always reset to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 60 R
4 61 IR
COM R1 → R1 = 0F8H
COM @R1 → R1 = 07H, register 07H = 0EH
In the first example, destination working register R1 contains the value 07H (00000111B). The
statement "COM R1" complements all the bits in R1: all logic ones are changed to logic zeros,
and vice-versa, leaving the value 0F8H (11111000B).
In the second example, Indirect Register (IR) addressing mode is used to complement the value
of destination register 07H (11110001B), leaving the new value 0EH (00001110B).
6-17
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
CP — Compare
CP dst,src
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 A2 r r
6 A3 r lr
Destination working register R1 contains the value 02H and source register R2 contains the
value 03H. The statement "CP R1,R2" subtracts the R2 value (source/subtrahend) from the
R1 value (destination/minuend). Because a "borrow" occurs and the difference is negative,
C and S are "1".
In this example, destination working register R1 contains the value 05H which is less than the
contents of the source working register R2 (0AH). The statement "CP R1,R2" generates C =
"1" and the JP instruction does not jump to the SKIP location. After the statement "LD R3,R1"
executes, the value 06H remains in working register R3.
6-18
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
DEC — Decrement
DEC dst
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if result is negative; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, dst value is – 128 (80H) and result value is
+ 127 (7FH); cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 00 R
4 01 IR
DEC R1 → R1 = 02H
DEC @R1 → Register 03H = 0FH
In the first example, if working register R1 contains the value 03H, the statement "DEC R1"
decrements the hexadecimal value by one, leaving the value 02H. In the second example, the
statement "DEC @R1" decrements the value 10H contained in the destination register 03H by
one, leaving the value 0FH.
6-19
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
DI — Disable Interrupts
DI
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 8F
DI
If the value of the SYM register is 04H, the statement "DI" leaves the new value 00H in the
register and clears SYM.2 to "0", disabling interrupt processing.
6-20
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
EI — Enable Interrupts
EI
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 9F
EI
If the SYM register contains the value 00H, that is, if interrupts are currently disabled, the
statement "EI" sets the SYM register to 04H, enabling all interrupts. (SYM.2 is the enable bit for
global interrupt processing.)
6-21
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Operation:
The IDLE instruction stops the CPU clock while allowing system clock oscillation to continue. Idle
mode can be released by an interrupt request (IRQ) or an external reset operation.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc 1 4 6F – –
IDLE
NOP
NOP
NOP
6-22
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
INC — Increment
INC dst
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result is negative; cleared otherwise.
V: Set if arithmetic overflow occurred, that is dst value is + 127 (7FH) and result is – 128 (80H);
cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
dst | opc 1 4 rE r
r = 0 to F
opc dst 2 4 20 R
4 21 IR
Examples: Given: R0 = 1BH, register 00H = 0CH, and register 1BH = 0FH:
INC R0 → R0 = 1CH
INC 00H → Register 00H = 0DH
INC @R0 → R0 = 1BH, register 01H = 10H
In the first example, if destination working register R0 contains the value 1BH, the statement "INC
R0" leaves the value 1CH in that same register.
The next example shows the effect an INC instruction has on register 00H, assuming that it
contains the value 0CH.
In the third example, INC is used in Indirect Register (IR) addressing mode to increment the value
of register 1BH from 0FH to 10H.
6-23
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Flags: All flags are restored to their original settings (that is, the settings before the interrupt occurred).
Format:
IRET Bytes Cycles Opcode
(Normal) (Hex)
opc 1 10 BF
12
6-24
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
JP — Jump
JP cc,dst (Conditional)
JP dst (Unconditional)
Format: (1)
Bytes Cycles Opcode Addr Mode
(2) (Hex) dst
cc | opc dst 3 8 ccD DA
cc = 0 to F
NOTES:
1. The 3-byte format is used for a conditional jump and the 2-byte format for an unconditional jump.
2. In the first byte of the three-byte instruction format (conditional jump), the condition code and the
op code are both four bits.
Examples: Given: The carry flag (C) = "1", register 00 = 01H, and register 01 = 20H:
The first example shows a conditional JP. Assuming that the carry flag is set to "1", the statement
"JP C,LABEL_W" replaces the contents of the PC with the value 1000H and transfers control to
that location. Had the carry flag not been set, control would then have passed to the statement
immediately following the JP instruction.
The second example shows an unconditional JP. The statement "JP @00" replaces the contents
of the PC with the contents of the register pair 00H and 01H, leaving the value 0120H.
6-25
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
JR — Jump Relative
JR cc,dst
The range of the relative address is + 127, – 128, and the original value of the program counter is
taken to be the address of the first instruction byte following the JR statement.
Format:
Bytes Cycles Opcode Addr Mode
(note) (Hex) dst
cc | opc dst 2 6 ccB RA
cc = 0 to F
NOTE: In the first byte of the two-byte instruction format, the condition code and the op code are each
four bits.
JR C,LABEL_X → PC = 1FF7H
If the carry flag is set (that is, if the condition code is true), the statement "JR C,LABEL_X" will
pass control to the statement whose address is now in the PC. Otherwise, the program instruction
following the JR would be executed.
6-26
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
LD — Load
LD dst,src
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
dst | opc src 2 4 rC r IM
4 r8 r R
6-27
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
LD — Load
LD (Continued)
Examples: Given: R0 = 01H, R1 = 0AH, register 00H = 01H, register 01H = 20H,
register 02H = 02H, LOOP = 30H, and register 3AH = 0FFH:
LD R0,#10H → R0 = 10H
LD R0,01H → R0 = 20H, register 01H = 20H
LD 01H,R0 → Register 01H = 01H, R0 = 01H
LD R1,@R0 → R1 = 20H, R0 = 01H
LD @R0,R1 → R0 = 01H, R1 = 0AH, register 01H = 0AH
LD 00H,01H → Register 00H = 20H, register 01H = 20H
LD 02H,@00H → Register 02H = 20H, register 00H = 01H
LD 00H,#0AH → Register 00H = 0AH
LD @00H,#10H → Register 00H = 01H, register 01H = 10H
LD @00H,02H → Register 00H = 01H, register 01H = 02, register 02H = 02H
LD R0,#LOOP[R1] → R0 = 0FFH, R1 = 0AH
LD #LOOP[R0],R1 → Register 31H = 0AH, R0 = 01H, R1 = 0AH
6-28
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
1. opc dst | src 2 10 C3 r Irr
NOTES:
1. The source (src) or working register pair [rr] for formats 5 and 6 cannot use register pair 0–1.
2. For formats 3 and 4, the destination address "XS [rr]" and the source address "XS [rr]" are each one
byte.
3. For formats 5 and 6, the destination address "XL [rr]" and the source address "XL [rr]" are each two
bytes.
4. The DA and r source values for formats 7 and 8 are used to address program memory; the second set
of values, used in formats 9 and 10, are used to address data memory.
6-29
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
LDC (note) @RR2,R0 ; 11H (contents of R0) is loaded into program memory
; location 0104H (RR2),
; working registers R0, R2, R3 → no change
LDE @RR2,R0 ; 11H (contents of R0) is loaded into external data memory
; location 0104H (RR2),
; working registers R0, R2, R3 → no change
LDC (note) #01H[RR4],R0 ; 11H (contents of R0) is loaded into program memory location
; 0061H (01H + 0060H)
LDE #01H[RR4],R0 ; 11H (contents of R0) is loaded into external data memory
; location 0061H (01H + 0060H)
LDC (note) 1105H,R0 ; 11H (contents of R0) is loaded into program memory location
; 1105H, (1105H) ← 11H
LDE 1105H,R0 ; 11H (contents of R0) is loaded into external data memory
; location 1105H, (1105H) ← 11H
NOTE: These instructions are not supported by masked ROM type devices.
6-30
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
LDCD references program memory and LDED references external data memory. The assembler
makes "Irr" an even number for program memory and an odd number for data memory.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 10 E2 r Irr
Examples: Given: R6 = 10H, R7 = 33H, R8 = 12H, program memory location 1033H = 0CDH, and
external data memory location 1033H = 0DDH:
6-31
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
LDCI refers to program memory and LDEI refers to external data memory. The assembler makes
"Irr" even for program memory and odd for data memory.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 10 E3 r Irr
Examples: Given: R6 = 10H, R7 = 33H, R8 = 12H, program memory locations 1033H = 0CDH and
1034H = 0C5H; external data memory locations 1033H = 0DDH and 1034H = 0D5H:
6-32
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
NOP — No Operation
NOP
Operation: No action is performed when the CPU executes this instruction. Typically, one or more NOPs are
executed in sequence in order to effect a timing delay of variable duration.
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 FF
NOP
6-33
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
OR — Logical OR
OR dst,src
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always cleared to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 42 r r
6 43 r lr
Examples: Given: R0 = 15H, R1 = 2AH, R2 = 01H, register 00H = 08H, register 01H = 37H, and
register 08H = 8AH:
In the first example, if working register R0 contains the value 15H and register R1 the value 2AH,
the statement "OR R0,R1" logical-ORs the R0 and R1 register contents and stores the result
(3FH) in destination register R0.
The other examples show the use of the logical OR instruction with the various addressing modes
and formats.
6-34
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 8 50 R
8 51 IR
Examples: Given: Register 00H = 01H, register 01H = 1BH, SP (0D9H) = 0BBH, and stack register
0BBH = 55H:
In the first example, general register 00H contains the value 01H. The statement "POP 00H"
loads the contents of location 0BBH (55H) into destination register 00H and then increments the
stack pointer by one. Register 00H then contains the value 55H and the SP points to location
0BCH.
6-35
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Operation: SP ← SP – 1
@SP ← src
A PUSH instruction decrements the stack pointer value and loads the contents of the source (src)
into the location addressed by the decremented stack pointer. The operation then adds the new
value to the top of the stack.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc src 2 8 70 R
8 71 IR
PUSH @40H → Register 40H = 4FH, register 4FH = 0AAH, stack register
0BFH = 0AAH, SP = 0BFH
In the first example, if the stack pointer contains the value 0C0H, and general register 40H the
value 4FH, the statement "PUSH 40H" decrements the stack pointer from 0C0 to 0BFH. It then
loads the contents of register 40H into location 0BFH. Register 0BFH then contains the value 4FH
and SP points to location 0BFH.
6-36
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Operation: C ← 0
The carry flag is cleared to logic zero, regardless of its previous value.
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 CF
The instruction RCF clears the carry flag (C) to logic zero.
6-37
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
RET — Return
RET
Operation: PC ← @SP
SP ← SP + 2
The RET instruction is normally used to return to the previously executing procedure at the end of
a procedure entered by a CALL instruction. The contents of the location addressed by the stack
pointer are popped into the program counter. The next statement that is executed is the one that
is addressed by the new program counter value.
Format:
Bytes Cycles Opcode
(Hex)
opc 1 8 AF
10
The statement "RET" pops the contents of stack pointer location 0BCH (10H) into the high byte of
the program counter. The stack pointer then pops the value in location 0BDH (1AH) into the PC's
low byte and the instruction at location 101AH is executed. The stack pointer now points to
memory location 0BEH.
6-38
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
RL — Rotate Left
RL dst
7 0
C
Flags: C: Set if the bit rotated from the most significant bit position (bit 7) was "1".
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation;
cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 90 R
4 91 IR
Examples: Given: Register 00H = 0AAH, register 01H = 02H and register 02H = 17H:
In the first example, if general register 00H contains the value 0AAH (10101010B), the statement
"RL 00H" rotates the 0AAH value left one bit position, leaving the new value 55H (01010101B)
and setting the carry and overflow flags.
6-39
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
7 0
C
Flags: C: Set if the bit rotated from the most significant bit position (bit 7) was "1".
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation;
cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 10 R
4 11 IR
Examples: Given: Register 00H = 0AAH, register 01H = 02H, and register 02H = 17H, C = "0":
In the first example, if general register 00H has the value 0AAH (10101010B), the statement "RLC
00H" rotates 0AAH one bit position to the left. The initial value of bit 7 sets the carry flag and the
initial value of the C flag replaces bit zero of register 00H, leaving the value 55H (01010101B).
The MSB of register 00H resets the carry flag to "1" and sets the overflow flag.
6-40
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
RR — Rotate Right
RR dst
7 0
C
Flags: C: Set if the bit rotated from the least significant bit position (bit zero) was "1".
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation;
cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 E0 R
4 E1 IR
Examples: Given: Register 00H = 31H, register 01H = 02H, and register 02H = 17H:
In the first example, if general register 00H contains the value 31H (00110001B), the statement
"RR 00H" rotates this value one bit position to the right. The initial value of bit zero is moved to
bit 7, leaving the new value 98H (10011000B) in the destination register. The initial bit zero also
resets the C flag to "1" and the sign flag and overflow flag are also set to "1".
6-41
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
7 0
C
Flags: C: Set if the bit rotated from the least significant bit position (bit zero) was "1".
Z: Set if the result is "0" cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation;
cleared otherwise.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 C0 R
4 C1 IR
Examples: Given: Register 00H = 55H, register 01H = 02H, register 02H = 17H, and C = "0":
In the first example, if general register 00H contains the value 55H (01010101B), the statement
"RRC 00H" rotates this value one bit position to the right. The initial value of bit zero ("1")
replaces the carry flag and the initial value of the C flag ("1") replaces bit 7. This leaves the new
value 2AH (00101010B) in destination register 00H. The sign flag and overflow flag are both
cleared to "0".
6-42
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 32 r r
6 33 r lr
Examples: Given: R1 = 10H, R2 = 03H, C = "1", register 01H = 20H, register 02H = 03H, and register
03H = 0AH:
In the first example, if working register R1 contains the value 10H and register R2 the value 03H,
the statement "SBC R1,R2" subtracts the source value (03H) and the C flag value ("1") from the
destination (10H) and then stores the result (0CH) in register R1.
6-43
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Operation: C ← 1
The carry flag (C) is set to logic one, regardless of its previous value.
Format:
Bytes Cycles Opcode
(Hex)
opc 1 4 DF
SCF
6-44
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
7 6 0
C
Flags: C: Set if the bit shifted from the LSB position (bit zero) was "1".
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result is negative; cleared otherwise.
V: Always cleared to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst
opc dst 2 4 D0 R
4 D1 IR
Examples: Given: Register 00H = 9AH, register 02H = 03H, register 03H = 0BCH, and C = "1":
In the first example, if general register 00H contains the value 9AH (10011010B), the statement
"SRA 00H" shifts the bit values in register 00H right one bit position. Bit zero ("0") clears the C
flag and bit 7 ("1") is then shifted into the bit 6 position (bit 7 remains unchanged). This leaves the
value 0CDH (11001101B) in destination register 00H.
6-45
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Operation: The STOP instruction stops the both the CPU clock and system clock and causes the
microcontroller to enter Stop mode. During Stop mode, the contents of on-chip CPU registers,
peripheral registers, and I/O port control and data registers are retained. Stop mode can be
released by an external reset operation or External interrupt input. For the reset operation, the
pin must be held to Low level until the required oscillation stabilization interval has elapsed.
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc 1 4 7F – –
halts all microcontroller operations. When STOPCON register is not #0A5H value, if you use
STOP instruction, PC is changed to reset address.
6-46
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
SUB — Subtract
SUB dst,src
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 22 r r
6 23 r lr
Examples: Given: R1 = 12H, R2 = 03H, register 01H = 21H, register 02H = 03H, register 03H = 0AH:
In the first example, if working register R1 contains the value 12H and if register R2 contains the
value 03H, the statement "SUB R1,R2" subtracts the source value (03H) from the destination
value (12H) and stores the result (0FH) in destination register R1.
6-47
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
TCM dst,src
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always cleared to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 62 r r
6 63 r lr
Examples: Given: R0 = 0C7H, R1 = 02H, R2 = 12H, register 00H = 2BH, register 01H = 02H, and
register 02H = 23H:
In the first example, if working register R0 contains the value 0C7H (11000111B) and register R1
the value 02H (00000010B), the statement "TCM R0,R1" tests bit one in the destination register
for a "1" value. Because the mask value corresponds to the test bit, the Z flag is set to logic one
and can be tested to determine the result of the TCM operation.
6-48
S3C9442/C9444/F9444/C9452/C9454/F9454 SAM88RCRI INSTRUCTION SET
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always reset to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 72 r r
6 73 r lr
Examples: Given: R0 = 0C7H, R1 = 02H, R2 = 18H, register 00H = 2BH, register 01H = 02H, and
register 02H = 23H:
In the first example, if working register R0 contains the value 0C7H (11000111B) and register R1
the value 02H (00000010B), the statement "TM R0,R1" tests bit one in the destination register for
a "0" value. Because the mask value does not match the test bit, the Z flag is cleared to logic zero
and can be tested to determine the result of the TM operation.
6-49
SAM88RCRI INSTRUCTION SET S3C9442/C9444/F9444/C9452/C9454/F9454
Flags: C: Unaffected.
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result bit 7 is set; cleared otherwise.
V: Always reset to "0".
Format:
Bytes Cycles Opcode Addr Mode
(Hex) dst src
opc dst | src 2 4 B2 r r
6 B3 r lr
Examples: Given: R0 = 0C7H, R1 = 02H, R2 = 18H, register 00H = 2BH, register 01H = 02H, and
register 02H = 23H:
In the first example, if working register R0 contains the value 0C7H and if register R1 contains the
value 02H, the statement "XOR R0,R1" logically exclusive-ORs the R1 value with the R0 value
and stores the result (0C5H) in the destination register R0.
6-50