Presentation is loading. Please wait.

Presentation is loading. Please wait.

Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps

Similar presentations


Presentation on theme: "Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps"— Presentation transcript:

1 Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
What we already know and have to remember to apply What we need to learn

2 Assembly code “stub” Each function written in assembly code has the same general look The necessary #include files and Section name Declaration of the function as “global” combined with labels for start and end of function Setting size of link operation and using LINK instruction to save the return address Unlink used with JUMP(P0) instruction to cause the function to return “to calling program” R0 used for return parameter Required code with Documentation of code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

3 Example 1 -- stub code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

4 Example 2 – Stub code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

5 Store/Write code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

6 Store/write error messages
8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

7 Load/read 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

8 Jump 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

9 If CC jump If !CC jump 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

10 Jump predicted taken (bp)
IF CC JUMP WHILE [--SP] = (R7:0); // Save to stack WHILE: R0 = R1; R2 = R3; CC = R1 < R4; IF CC JUMP WHILE; R6 = R7; R5 = R4; IF CC JUMP WHILE [--SP] = (R7:0); // Save to stack WHILE: R0 = R1; R2 = R3; CC = R1 < R4; IF CC JUMP WHILE (BP); R6 = R7; R5 = R4; 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

11 Processor fetches instructionS before execution
8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

12 UP to 10 instructions being executed in paraller
Processor fetches 9 new instructions before execution of 1st instruction is complete UP to 10 instructions being executed in paraller 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

13 Jump predicted taken (bp)
IF CC JUMP WHILE [--SP] = (R7:0); // Save to stack WHILE: R0 = R1; R2 = R3; CC = R1 < R4; IF CC JUMP WHILE; R6 = R7; R5 = R4; IF CC JUMP WHILE [--SP] = (R7:0); // Save to stack WHILE: R0 = R1; R2 = R3; CC = R1 < R4; IF CC JUMP WHILE (bp); R6 = R7; R5 = R4; 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

14 Jump example code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

15 Call instruction 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

16 void ExampleASM(void) {
C++ code void ExampleASM(void) { ConvertTempASM(100,200,1); // declared as extern “C” } Assembly code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

17 void Example2ASM(void) {
C++ code void Example2ASM(void) { CalculateTemperature(100,200,1); // C++ function } Assembly code 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

18 Move Register 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

19 Conditional move register
8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

20 Practice Exercise Translate in Blackfin Assembly Code
extern “C” unsigned long int WaitTillLow(void); extern “C” unsigned long int WaitTillHigh(void); unsigned short int MeasureTimeHigh_ASM(void) { unsigned long int value; WaitTillLow( ); WaitTillHigh( ); value = WaitTillLow( ); return value; } 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

21 Practice Exercise 2 Translate in Blackfin Assembly Code
extern “C” unsigned long int WaitTillLow(void); extern “C” unsigned long int WaitTillHigh(void); unsigned long int MeasureTimeHigh_ASM(void) { unsigned long int value1, value2; WaitTillLow( ); WaitTillHigh( ); value1 = WaitTillLow( ); value2 = WaitTillLow( ); return (value1 + value2); } 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada

22 Practice Exercise 3 Translate in Blackfin Assembly Code
extern “C” unsigned long int WaitTillLow(void); extern “C” unsigned long int WaitTillHigh(void); extern unsigned long int value1; extern unsigned long int value2; unsigned long int MeasureTimeHigh_ASM(void) { WaitTillLow( ); WaitTillHigh( ); value1 = WaitTillLow( ); value2 = WaitTillLow( ); return (value1 + value2); } 8/5/2019 Timer Control -- Lab.3, Copyright M. Smith, ECE, University of Calgary, Canada


Download ppt "Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps"

Similar presentations


Ads by Google