Download presentation
Presentation is loading. Please wait.
1
Branching and Loops
2
Jumping Jump instruction causes a change in the program flow to any location within the addressable range of the processor. ORG $0200 AC LDAA #$AC E 02 0B JMP STORE F CLRA F CLRB F CLR $0200 020A ASRA 020B B STORE STAA $0250 020E 7E 02 0E END JMP END
3
Jump ORG $ AC LDAA #$AC E 02 0B JMP $020b F CLRA F CLRB F CLR $ A 47 ASRA 020B B STAA $ E 7E 02 0E JMP $020e
4
Branching and Relative Address Mode
Branch instructions differ from the jump instructions in that they do not supply the absolute address of the next instruction.
5
Branching and Relative Address Mode
BCC BCS BEQ BMI BNE BPL BVC BVS BHS BLO
6
Branching and Relative Address Mode
ORG $ AC LDAA $AC A 05 BPL POS 0204 B STAA $ BRA END 0209 B POS STAA $ C 20 FE END BRA END
7
Destination address calculation
Problem: Calculate the destination address (DA) for each of the following branch instructions. ADDRESS MACHINE CODE SOURCE CODE C BRA PAST O1F7 20D3 BRA LOOP 063A 20 9B BRA AGAIN
8
RELATIVE ADRESS (rr) CALCULATION
Calculate the relative address (rr) for each of the following branch instuctions a. ORG $ AC LDAA $AC A ?? BPL POS 0204 B STAA $ ?? BRA END 0209 B POS STAA $ C 20 ?? END BRA END
9
RELATIVE ADRESS (rr) CALCULATION
ORG $ AC LDAA $AC B AD ADDA $AD ?? BVS ERROR ?? BCS CARRY 0308 B STAA $ B 20 ?? BRA END 030D CARRY LDAA #$01 030F B STAA $ ?? BRA END 0314 CC FF FF ERROR LDD #$FFFF 0317 FD STD $ A 20 ?? END BRA END
10
Compare Instructions CMPA CMPB CPD CPX CPY CBA
11
Test Instructions TSTA TSTB TST
12
IF-THEN-ELSE ORG $0200 LDAA $03FA BPL PAST NEGA PAST STAA $03FA
13
WHILE AND UNTIL LOOPS
14
TIMING LOOPS $0200 LDX #100 LOOP DEX BNE LOOP
15
TIMING LOOPS LDAA #30 STAA $1000 LDAA #00 STAA $1001 BACK DEC $1001
ORG $0200 LDAA #30 STAA $1000 LDAA #00 STAA $1001 BACK DEC $1001 BNE BACK DEC $1000
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.