Académique Documents
Professionnel Documents
Culture Documents
Quito, Ecuador
davidldu34@gmail.com
A branch is an instruction in a computer program that Some jump instruction are showed next:
can cause a computer to begin executing a different
instruction sequence and thus deviate from its default Jumps directly and unconditionally:
behavior of executing instructions in order. Branch may JMP – Jump
also refer to the act of switching execution to a different Jump to an address within the entire 4Megas.
instruction sequence because of executing a branch Syntax: JMP k
instruction. A branch instruction can be either an Program Counter: PC k
unconditional branch, which always results in branching, 32 – bit Opcode:
or a conditional branch, which may or may not cause 1001 010k kkkk 110k
branching, depending on some condition. Branch kkkk kkkk kkkk kkkk
instructions are used to implement control flow in program
loops and conditional. RJMP – Relative Jump
Relative jump to an address within PC – 2k+1 and
PC + 2k (-2048….2047). This instruction can
address the entire memory from every address
.
location.
Syntax: RJMP k
Program Counter: PC PC + k + 1 Program Counter:
16 – bit Opcode: PC PC + 1, condition false – no skip
1100 kkkk kkkk kkkk PC PC + 2, skip a one word instruction
PC PC + 3, skip a two word instruction
Jumps indirectly and unconditionally: 16 – bit Opcode:
IJMP – Indirect Jump 0001 00rd dddd rrrr
Indirect jump to the address pointed to by the Z
(16 bits) Pointer Register in the Register File. The
Z-pointer Register is 16 bits wide and allows jump
You can look it up in the next flow diagram how CPSE
within the lowest 64k words (128K bytes) section
works:
of Program Memory.
Syntax: IJMP
Program Counter: PC Z
16 – bit Opcode:
1001 0100 0000 1001 Rd = Rr YES
NO
Compare and omit if they are the same: Next instruction
CPSE – Compare skip if Equal
This instruction performs a compare between two
register Rd and Rr, and skips the next instruction
if Rd = Rr.
Syntax: CPSE Rd, Rr
Fig. 2 SBRC Flow diagram
SBRS – Skip if bit in Register is Set SBIS – Skip if bit in I/O Register is Set
This instruction tests a single bit in a Register and This instruction tests a single bit in an I/O
skip the next instruction if the bit is set. Register and skip the next instruction if the bit is
Syntax: SBRS Rr, b set.
Program Counter: Syntax: SBIS A, b
PC PC + 1, condition false – no skip Program Counter:
PC PC + 2, skip a one word instruction PC PC + 1, condition false – no skip
PC PC + 3, skip a two word instruction PC PC + 2, skip a one word instruction
16 – bit Opcode: PC PC + 3, skip a two word instruction
1111 111r rrrr 0bbb 16 – bit Opcode:
1001 1011 AAAA Abbb
Rr(b) = 1 YES
A(b) = 1 YES
NO
NO
Next instruction
Next instruction
SREG(s) = 0 YES
A(b) = 0 YES
Jump
NO destination
NO
Next instruction
Next instruction