* M. R. Smith, University of Calgary, Alberta,

Slides:



Advertisements
Similar presentations
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
Advertisements

Assignment Overview Thermal oscillator One of the ENCM415 Laboratory 2 items Oscillator out GND +5V.
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
Systematic development of programs with parallel instructions SHARC ADSP2106X processor M. Smith, Electrical and Computer Engineering, University of Calgary,
Building a simple loop using Blackfin assembly code M. Smith, Electrical and Computer Engineering, University of Calgary, Canada.
Developing a bicycle speed-o-meter Part 2 A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
Process for changing “C-based” design to SHARC assembler ADDITIONAL EXAMPLE M. R. Smith, Electrical and Computer Engineering University of Calgary, Canada.
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
Generation of highly parallel code for TigerSHARC processors An introduction This presentation will probably involve audience discussion, which will create.
Developing a bicycle speed-o-meter A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
Understanding the Blackfin ADSP-BF5XX Assembly Code Format
Just enough information to program a Blackfin Familiarization assignment for the Analog Devices’ VisualDSP++ Integrated Development Environment.
Developing a bicycle speed-o-meter Midterm Review.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Systematic development of programs with parallel instructions SHARC ADSP21XXX processor M. Smith, Electrical and Computer Engineering, University of Calgary,
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
Developing a bicycle speed-o-meter
Subroutines … a 1st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
واشوقاه إلى رمضان مرحباً رمضان
Microcoded CCU (Central Control Unit)
Program Flow on ADSP2106X SHARC Pipeline issues
Overview of SHARC processor ADSP and ADSP-21065L
DMA example Video image manipulation
The planned and expected
Overview of SHARC processor ADSP Program Flow and other stuff
Generating a software loop with memory accesses
ENCM K Interrupts Theory and Practice
Comparing 68k (CISC) with 21k (Superscalar RISC DSP)
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
Comparing 68k (CISC) with 21k (Superscalar RISC DSP)
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
Assembly Language Review
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Assembly Language Review
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
* L. E. Turner and M. R. Smith, University of Calgary, Alberta, Canada
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Tutorial on Post Lab. 1 Quiz Practice for parallel operations
DMA example Video image manipulation
Developing a bicycle speed-o-meter
Overview of SHARC processor ADSP-2106X Compute Operations
Developing a bicycle speed-o-meter
Developing a bicycle speed-o-meter
Building a simple loop using Blackfin assembly code
Overview of SHARC processor ADSP-2106X Compute Operations
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
Overview of SHARC processor ADSP-2106X Memory Operations
Developing a bicycle speed-o-meter Part 2
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
A first attempt at learning about optimizing the TigerSHARC code
Blackfin Syntax Moves and Adds
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
ECE511: Digital System & Microprocessor
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
* M. R. Smith 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint.
Presentation transcript:

* M. R. Smith, University of Calgary, Alberta, 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during your presentation In Slide Show, click on the right mouse button Select “Meeting Minder” Select the “Action Items” tab Type in action items as they come up Click OK to dismiss this box This will automatically create an Action Item slide at the end of your presentation with your points entered. ENCM415 Review with New – Lec. 2 Compare 68K CISC and ADSP-BF533 DSP processor doing Lab. 1 (Exam Quality) M. R. Smith, University of Calgary, Alberta, *

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca To be tackled * 07/16/96 Programmers model Lab. 1 – main.c – examples 68K and BlackFin Reset(unsigned char *); FillCoffeePot(unsigned char *, unsigned short int); HeatCoffeePot(unsigned char *, unsigned char); MonitorTemp(unsigned char *, unsigned char *, unsigned char *, unsigned char * ); CorrectTemp(unsigned char *, unsigned short int *, unsigned char); WARNING – First time that the BlackFin processor has been taught – believe syntax is correct, but there might be some nasty PSP errors 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca *

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca Lab. 1 – main.c #define BASE1 (unsigned char *) 0x20000 #define BASE2 (unsigned char *) 0x30000 long int main(void) { Reset(BASE1); Reset(BASE2); FillCoffePot(BASE1, level); FillCoffePot(BASE2, level); HeatCoffeePot(BASE1, numpulses); HeatCoffeePot(BASE2, numpulses); MonitorTemp(BASE1, BASE2, array1, array2); CorrectTemp(array1, array3, change); } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

68K -- Programmer’s model 8 data registers (D0 – D7) 32-bit 2’s complement number representation 9 address registers (A0 to A6 + USP, SSP) 32 bit A6 often used as a FP (frame pointer) 16-bit Data bus 1 memory read gets 16 bits at a time 24-bit Address bus (although 32 bit registers) 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void ResetCoffeePot(unsigned char *) .include “coffdev.i” .section instruction_rom .EXPORT _ResetCoffeePot INPAR_pt SET 4 ; R.A. SET 0 _ResetCoffeePot: MOVE.L INPAR_pt(SP), A0 MOVE.L #RESET_VALUE, CONTROL_REG(A0) RTS WHY IS MOVE.L #RESET_VALUE, (A0) A POOR ANSWER? #include “coffdev.h” void ResetCoffeePot( unsigned char* pt) { unsigned long *temp_A0; temp_A0 = (unsigned long *) pt; temp_A0 = temp_A0 + CONTROL_REG; *temp_A0 = RESET_VALUE; } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Blackfin -- Programmer’s Model 8 DATA REGISTERS (R0 -- R7) 32 bit -- accessible as 8, 16, 32 bits Access very similar to 68K – 2 @ 16 bits in each register R0.H and R0.L 1.15 Format (signed fractional – integer with floating point features) – also 2’s complement 6 ADDRESS REGISTERS (P0 – P5) 32 bit in size although address bus size is smaller 1 FRAME POINTER (FP (P6?)) 1 STACK POINTER (SP (P7?)) 16 DSP DAG REGISTERS (I0-3, B0-3, L0-3, M0-3) 2 HIGH PRECISION MATHEMATICAL ACCUMULATORS (ACC0 – ACC1) 1 PROGRAM COUNTER PC 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void ResetCoffeePot(unsigned char *) .include “coffdev.i” .section instruction_rom .EXPORT _ResetCoffeePot INPAR_pt SET 4 ; R.A. SET 0 _ResetCoffeePot: MOVE.L INPAR_pt(SP), A0 MOVE.L #RESET_VALUE, CONTROL_REG(A0) RTS #include “coffdev.i” .section program; .GLOBAL _ResetCoffeePot; // INPAR_pt is R0 // R.A. in RETS _ResetCoffeePot: P0 = R0; R1.L = RESET_VALUE & 0xFFFF; R1.H = (RESET_VALUE >> 16) & 0xFFFF; [P0 + CONTROL_REG] = R1; RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca Lab. 1 – main.c #define BASE1 (unsigned char *) 0x20000 #define BASE2 (unsigned char *) 0x30000 long int main(void) { Reset(BASE1); Reset(BASE2); FillCoffePot(BASE1, level); FillCoffePot(BASE2, level); HeatCoffeePot(BASE1, numpulses); HeatCoffeePot(BASE2, numpulses); MonitorTemp(BASE1, BASE2, array1, array2); CorrectTemp(array1, array3, change); } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Fill(unsigned char *, unsigned short int)) .section instruction_rom .EXPORT _Fill INPAR_level SET 8 INPAR_pt SET 4 ; R.A. SET 0 _FILL: MOVE.L INPAR_pt(SP), A0 MOVE.L INPAR_level(SP), D1 ; AND.L #0x0000FFFF, D1 WHILE: MOVE.W watergauge(A0), D0 CMP.W D1, D0 BHS END_WHILE MOVE.B #ON, valve(A0) BRA WHILE END_WHILE: MOVE.B #OFF, valve(A0) RTS void Fill( unsigned char* pt, unsigned short int level) { while (watergauge < level) water on; water off } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Fill(unsigned char *, unsigned short int)) .section instruction_rom .EXPORT _Fill INPAR_level SET 8 INPAR_pt SET 4 ; R.A. SET 0 _FILL: MOVE.L INPAR_pt(SP), A0 MOVE.L INPAR_level(SP), D1 ; AND.L #0x0000FFFF, D1 WHILE: MOVE.W watergauge(A0), D0 CMP.W D1, D0 BHS END_WHILE MOVE.B #ON, valve(A0) BRA WHILE END_WHILE: MOVE.B #OFF, valve(A0) RTS .section program; .GLOBAL _Fill; // INPAR_level is R1 // INPAR_pt is R0 // R.A. is RETS _FILL: P0 = R0; WHILE: // Re-use R0 R0 = W[P0 + watergauge] (Z); CC = R1 <= R0 (IU);  Unsigned IF CC JUMP END_WHILE; R3 = ON; B[P0 + valve] = R3; JUMP WHILE; END_WHILE: R3 = OFF; RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca Lab. 1 – main.c #define BASE1 (unsigned char *) 0x20000 #define BASE2 (unsigned char *) 0x30000 long int main(void) { Reset(BASE1); Reset(BASE2); FillCoffePot(BASE1, level); FillCoffePot(BASE2, level); HeatCoffeePot(BASE1, numpulses); HeatCoffeePot(BASE2, numpulses); MonitorTemp(BASE1, BASE2, array1, array2); CorrectTemp(array1, array3, change); } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Heat(unsigned char *, unsigned char)) .section instruction_rom .EXPORT _Heat INPAR_pulses SET 8 INPAR_pt SET 4 ; R.A. SET 0 _HEAT: MOVE.L INPAR_pt(SP), A0 MOVE.L INPAR_pulses(SP), D1 ; AND.L #0x000000FF, D1 MOVE.B #0, D0 FOR: CMP.B D1, D0 BHS END_FOR MOVE.B #30, heat(A0) ADD.B #1, D0 BRA FOR END_FOR: RTS void Heat( unsigned char* pt, unsigned char pulses) { unsigned char count; for (count = 0; count < pulses; count++) { *((cast)pt + heat) = 30; } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Heat(unsigned char *, unsigned char)) .section instruction_rom .EXPORT _Heat INPAR_pulses SET 8 INPAR_pt SET 4 ; R.A. SET 0 _Heat: MOVE.L INPAR_pt(SP), A0 MOVE.L INPAR_pulses(SP), D1 ; AND.L #0x000000FF, D1 MOVE.B #0, D0 FOR: CMP.B D1, D0 BHS END_FOR MOVE.B #30, heat(A0) ADD.B #1, D0 BRA FOR END_FOR: RTS .section program; .GLOBAL _Heat; // INPAR_pulses is R1 // INPAR_pt is R0 // R.A. is RETS _Heat: P0 = R0; R0.L = 0x00FF (Z); // R0 = 0xFF R1 = R1 & R0; Use 32 bits for char R0 = 0; FOR: CC = R1 <= R0 (IU); IF CC JUMP END_FOR; R3 = 30 ; B[P0 + heat] = R3; R0 += 1; JUMP FOR; END_FOR: RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca Lab. 1 – main.c #define BASE1 (unsigned char *) 0x20000 #define BASE2 (unsigned char *) 0x30000 long int main(void) { Reset(BASE1); Reset(BASE2); FillCoffePot(BASE1, level); FillCoffePot(BASE2, level); HeatCoffeePot(BASE1, numpulses); HeatCoffeePot(BASE2, numpulses); MonitorTemp(BASE1, BASE2, array1, array2); CorrectTemp(array1, array3, change); } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 1 – Part 1 .section instruction_rom .EXPORT _Monitor INPAR_array2 SET (16 + FRAME_SIZE) INPAR_array1 SET (12 + FRAME_SIZE) INPAR_pt2 SET (8 + FRAME_SIZE) INPAR_pt1 SET (4 + FRAME_SIZE) ; R.A. SET 0 + FRAME_SIZE OLDA3 SET 8 OLDA2 SET 4 OLDD2 SET 0 _Monitor: FRAMESIZE SET 12 ; PROLOGUE SUB.L #FRAMESIZE, SP MOVEM.L D2/A2-A3, OLDD2(SP) FOR LOOP HERE ; EPILOGUE MOVEM.L OLDD2(SP), D2/A2-A3 ADD.L #FRAMESIZE, SP RTS void Monitor(unsigned char* pt1, unsigned char* pt2, unsigned char *array1_pt, unsigned char *array2+pt,) { unsigned char count; for (count = 0; count < 144; count++) { *array1_pt = *(pt1 + heat); array1_pt++; *array2_pt = *(pt2 + heat); array2_pt++’ } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 1 – Part 2 INPAR_array2 SET (16 + FRAME_SIZE) INPAR_array1 SET (12 + FRAME_SIZE) INPAR_pt2 SET (8 + FRAME_SIZE) INPAR_pt1 SET (4 + FRAME_SIZE) _Monitor: PROLOGUE HERE MOVE.L INPAR_pt1(SP), A0 MOVE.L INPAR_pt2(SP), A2 MOVE.L INPAR_array1(SP), A1 MOVE.L INPAR_array2(SP), A3 MOVE.B #0, D2 FOR: CMP. B #144, D2 BHS END_FOR MOVE.B temp(A0), (A1)+ MOVE.B temp(A2), (A3)+ ADDQ.B #1, D2 JMP FOR END_FOR EPILOGUE HERE RTS void Monitor(unsigned char* pt1, unsigned char* pt2, unsigned char *array1_pt, unsigned char *array2+pt,) { unsigned char count; for (count = 0; count < 144; count++) { *array1_pt = *(pt1 + heat); array1_pt++; *array2_pt = *(pt2 + heat); array2_pt++’ } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 2 – Part 1 .section instruction_rom .EXPORT _Monitor INPAR_array2 SET 20  FRAMESIZE INPAR_array1 SET 16  INDEPENDENT INPAR_pt2 SET 12 INPAR_pt1 SET 8 ; R.A. SET 0 + FRAME_SIZE OLDA3 SET 8 OLDA2 SET 4 OLDD2 SET 0 _Monitor: FRAMESIZE SET 12 ; PROLOGUE LINK A6, #-FRAMESIZE MOVEM.L D2/A2-A3, OLDD2(SP) FOR LOOP HERE ; EPILOGUE MOVEM.L OLDD2(SP), D2/A2-A3 UNLINK A6 RTS void Monitor(unsigned char* pt1, unsigned char* pt2, unsigned char *array1_pt, unsigned char *array2+pt,) { unsigned char count; for (count = 0; count < 144; count++) { *array1_pt = *(pt1 + heat); array1_pt++; *array2_pt = *(pt2 + heat); array2_pt++’ } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 2 – Part 2 INPAR_array2 SET 20  FRAMESIZE INPAR_array1 SET 16  INDEPENDENT INPAR_pt2 SET 12 INPAR_pt1 SET 8 _Monitor: PROLOGUE HERE MOVE.L INPAR_pt1(A6), A0 MOVE.L INPAR_pt2(A6), A2 MOVE.L INPAR_array1(A6), A1 MOVE.L INPAR_array2(A6), A3 MOVE.B #0, D2 FOR: CMP. B #144, D2 BHS END_FOR MOVE.B temp(A0), (A1)+ MOVE.B temp(A2), (A3)+ ADDQ.B #1, D2 JMP FOR END_FOR EPILOGUE HERE RTS void Monitor(unsigned char* pt1, unsigned char* pt2, unsigned char *array1_pt, unsigned char *array2+pt,) { unsigned char count; for (count = 0; count < 144; count++) { *array1_pt = *(pt1 + heat); array1_pt++; *array2_pt = *(pt2 + heat); array2_pt++’ } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 2 -- Part 1 .section instruction_rom .EXPORT _Monitor INPAR_array2 SET 20  FRAMESIZE INPAR_array1 SET 16  INDEPENDENT INPAR_pt2 SET 12 INPAR_pt1 SET 8 ; R.A. SET 4 OLDA3 SET 8 OLDA2 SET 4 OLDD2 SET 0 _Monitor: FRAMESIZE SET 12 ; PROLOGUE LINK A6, #-FRAMESIZE MOVEM.L D2/A2-A3, OLDD2(SP) FOR LOOP HERE ; EPILOGUE MOVEM.L OLDD2(SP), D2/A2-A3 UNLINK A6 RTS .section program .GLOBAL _Monitor; #define INPAR_array2 20 // INPAR_array1 is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 // R.A. Is RETS #define OLDP3 0 _Monitor: FRAMESIZE SET 4 ; PROLOGUE LINK FRAMESIZE; [SP + OLDP3] = P3; FOR LOOP HERE ; EPILOGUE P3 = [SP + OLDP3]; UNLINK; RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 2 -- Part 2 #define INPAR_array2 20 // INPAR_array1 is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 _Monitor: PROLOGUE HERE P0 = R0; P2 = R1; P1 = R2; P3 = [FP + INPAR_array2]; R2 = 0; R3 = 144; FOR: CC = R3 <= R2 (IU); IF CC JUMP END_FOR; R0 = B[P0]; B[P1++] = R0; R1 = B[P2]; B[P3++] = R1; R2++; JUMP FOR END_FOR EPILOGUE HERE RTS INPAR_array2 SET 20  FRAMESIZE INPAR_array1 SET 16  INDEPENDENT INPAR_pt2 SET 12 INPAR_pt1 SET 8 _Monitor: PROLOGUE HERE MOVE.L INPAR_pt1(A6), A0 MOVE.L INPAR_pt2(A6), A2 MOVE.L INPAR_array1(A6), A1 MOVE.L INPAR_array2(A6), A3 MOVE.B #0, D2 FOR: CMP. B #144, D2 BHS END_FOR MOVE.B temp(A0), (A1)+ MOVE.B temp(A2), (A3)+ ADDQ.B #1, D2 JMP FOR END_FOR EPILOGUE HERE RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 3.1 -- Part 2 #define INPAR_array2 20 // INPAR_array1 is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 _Monitor: PROLOGUE HERE P0 = R0; P2 = R1; P1 = R2; P3 = [FP + INPAR_array2]; R2 = 0; R3.L = 144 (Z);  FOR: CC = R3 <= R2 (IU); IF CC JUMP END_FOR; R0 = B[P0]; B[P1++] = R0; R1 = B[P2]; B[P3++] = R1; R2++; JUMP FOR END_FOR EPILOGUE HERE RTS Blackfin also has the ability to do zero overhead loops (Max of 2 nested) P0.L = 144 (Z); LOOP FOR_LOOP LC0 = P0; P0 = R0; P2 = R1; P1 = R2; P3 = [FP + INPAR_array2]; LOOP_BEGIN FOR_LOOP; R0 = B[P0]; B[P1++] = R0; R1 = B[P2]; B[P3++] = R1; LOOP_END FOR_LOOP; 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

void Monitor( …)) – VERSION 3.2 -- Part 2 #define INPAR_array2 20 // INPAR_array1 is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 _Monitor: PROLOGUE HERE P0 = R0; P2 = R1; P1 = R2; P3 = [FP + INPAR_array2]; R2 = 0; R3.L = 144; FOR: CC = R3 <= R2 (IU); IF CC JUMP END_FOR; R0 = B[P0]; B[P1++] = R0; R1 = B[P2]; B[P3++] = R1; R2++; JUMP FOR END_FOR EPILOGUE HERE RTS Blackfin also has the ability to do zero overhead loops P0.L = 144 (Z); LSETUP(FOR, END_FOR) LC0 = P0; P0 = R0; P2 = R1; P1 = R2; P3 = [FP + INPAR_array2]; FOR: // No more than 30 bytes away R0 = B[P0]; B[P1++] = R0; R1 = B[P2]; B[P3++] = R1; END_FOR: QUERY – should END_FOR label be one past the end of the loop or the last line in the loop? 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca Lab. 1 – main.c #define BASE1 (unsigned char *) 0x20000 #define BASE2 (unsigned char *) 0x30000 long int main(void) { Reset(BASE1); Reset(BASE2); FillCoffePot(BASE1, level); FillCoffePot(BASE2, level); HeatCoffeePot(BASE1, numpulses); HeatCoffeePot(BASE2, numpulses); MonitorTemp(BASE1, BASE2, array1, array2); CorrectTemp(array1, array3, change); } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

CorrectTemp(array1, array3, change); .section instruction_rom .EXPORT _Correct INPAR_change SET 16  INPAR_pt2 SET 12 INPAR_pt1 SET 8 ; R.A. SET 4 OLDD2 SET 0 _Correct: FRAMESIZE EQU 4 PROLOGUE LINK A6, #-FRAMESIZE MOVE.L D2, OLDD2(SP) FOR LOOP ; EPILOGUE MOVE.L OLDD2(SP), D2 UNLINK A6 RTS void Correct(unsigned char* pt1, signed short int * pt2, unsigned char change) { unsigned char count; short int value; for (count = 0; count < 144; count++) { value = *pt1; // implied // value = (short int) *pt1; *pt2 = value – change; // implied // *pt2 = value – (short int) change; } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

CorrectTemp(array1, array3, change); INPAR_change SET 16 INPAR_pt2 SET 12 INPAR_pt1 SET 8 _Correct: PROLOGUE MOVE.L INPAR_pt1(SP), A0 MOVE.L INPAR_pt2(SP), A1 MOVE.L INPAR_change(SP), D0 AND.W #0x00FF,D0 MOVE.B #0, D1 FOR: CMP.B #144, D1 BHS END_FOR MOVE.B (A0)+, D2 AND.W #0x00FF, D2 SUB.W D0, D2 MOVE.W D2, (A0)+ ADDQ.W #1, D1 JMP FOR END_LOOP: EPILOGUE void Correct(unsigned char* pt1, signed short int * pt2, unsigned char change) { unsigned char count; short int value; for (count = 0; count < 144; count++) { value = *pt1; // implied // value = (short int) *pt1; *pt2 = value – change; // implied // *pt2 = value – (short int) change; } 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

CorrectTemp(array1, array3, change); .section instruction_rom .EXPORT _Correct INPAR_change SET 16  INPAR_pt2 SET 12 INPAR_pt1 SET 8 ; R.A. SET 4 OLDD2 SET 0 _Correct: FRAMESIZE EQU 4 PROLOGUE LINK A6, #-FRAMESIZE MOVE.L D2, OLDD2(SP) FOR LOOP ; EPILOGUE MOVE.L OLDD2(SP), D2 UNLINK A6 RTS .section program .GLOBAL _Correct // INPAR_change is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 // R.A. Is RETS _Correct: // R3 is still available FOR LOOP RTS 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

CorrectTemp(array1, array3, change); INPAR_change SET 16 INPAR_pt2 SET 12 INPAR_pt1 SET 8 _Correct: PROLOGUE MOVE.L INPAR_pt1(SP), A0 MOVE.L INPAR_pt2(SP), A1 MOVE.L INPAR_change(SP), D0 AND.W #0x00FF,D0 MOVE.B #0, D1 FOR: CMP.B #144, D1 BHS END_FOR MOVE.B (A0)+, D2 AND.W #0x00FF, D2 SUB.W D0, D2 MOVE.W D2, (A0)+ ADDQ.W #1, D1 JMP FOR END_LOOP: EPILOGUE // INPAR_change is R2 // INPAR_pt2 is R1 // INPAR_pt1 is R0 _Correct: P0 = R0; P1 = R1; R3.L = 0x00FF (Z); R2 = R2 & R3; P2.L = 144 (Z); LSETUP(FOR, END_LOOP) LC0 = P2; FOR: R0 = B[P0++] (Z); R0 = R0 – R2; END_LOOP: W[P1++] = R0; 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca BlackFin Syntax // R0 = imm7; // sign extended (2’s complement R0 = 0x7F; // R0 = 0x7F R0 = -63 // R0 = 0xFFFFFFFF // R0.L = imm16; // only R0.L changed // R0.L = imm16 (X) // signed extended // R0.L = imm16 (Z) // zero extended Memory access examples R0 = B[P0] (X); R0 = B[P0] (Z); R0 = W[P0] (X); R0 = W[P0] (Z); R0 = [P0]; R0 = [P0 + value]; R0 = [P0 + P1]; R0 = [P0 ++]; R0 = [P0 ++ P1]; 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca

Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca BlackFin Loop Syntax R0.L = value (Z); R1 = 0; FOR: CC = R0 < R1; IF CC JUMP END_FOR; LOOP ITSELF R1++; JUMP FOR; END_FOR:; P0.L = value (Z); LSetUp(FOR, ENDFOR) LC0 = P0 FOR:; LOOP ITSELF END_FOR:; Maximum of two hardware loops using Loop counters LC) and LC1 12/6/2018 Comparing Blackfin and 68K Copyright M. Smith smithmr@ucalgary.ca