Chapter 4: Relative Branching/Skips/Subroutines Flashcards

1
Q

What are relative Branches?

A

Relative Branches use an offset to adjust the PC. Most branches are local so that only small offsets are required, thus making the operand smaller. This offset can be negative so that they can be used to create loops.

In this case the offset reduces the programme counter to allow a set of instructions to be repeated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The advantages of relative branches?

A

The advantage of relative branches is that the code can then be relocatable, i.e. it can be moved to a different part of the memory and still work. This is important when the absolute address is not known at the time when the assembly code is compiled, e.g. an app running under an Operating System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are skips used for?

A

Another way of avoiding using large target addresses in a branch instruction is to use skips.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What occurs during a skip?

A

, the programme counter increments in the usual way, one instruction at a time. However, the skip instruction forces the next operation to not be executed depending on whether a condition is met. Whilst this can be described as jumping over the next instruction, in fact the programme counter is not affected. It actually just overwrites the next fetched instruction with a NOP (No Operation).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Examples of skip operations?

A

Example: In the PIC16F84A instruction set the BTFSC (Bit Test F, Skip if Clear) and BTFSS (Bit Test F, Skip if Set) are conditional skip operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are subroutines?

A

High level languages make extensive use of subroutines (or functions). The same can be done in assembly code by using jumps which remember where they have come from, with the idea that once the subroutine has finished, the programme would return to the instruction following the subroutine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

commands used to control subroutines?

A

PIC16F84A example:

CALL – Branch and put the return address on the stack

RETURN – restore the return address from the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly