Presentation is loading. Please wait.

Presentation is loading. Please wait.

Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);

Similar presentations


Presentation on theme: "Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);"— Presentation transcript:

1 Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);

2 Array handling -- part 1 -- M. Smith 2 of 30 To be tackled – Array handling Setting test environment – part of Lab.0 Setting up the tests Writing “enough” assembly code so you can “call the code, and return without crashing” Setting one value in an array Moving through an array – Hard coding and auto-increment addressing modes – Software loops – Hardware loops will be covered in a later lecture

3 Array handling -- part 1 -- M. Smith 3 of 30 The test Initialize the test array Check (some) initial values Call the assembly code routine Check (some) final values

4 Array handling -- part 1 -- M. Smith 4 of 30 “Just enough code” to safely return after call Tell “linker” which “section” is needed to place the code – program memory section NOT data Tell “linker” that this is available for all to use (global and not private function) Start label – need colon : End label with RTS statement RTS = ReTurn from Subroutine

5 Array handling -- part 1 -- M. Smith 5 of 30 Build the project (F7)

6 Array handling -- part 1 -- M. Smith 6 of 30 Build the project (F7) also loads “.dxe” if successful

7 Array handling -- part 1 -- M. Smith 7 of 30 Run the code “F5”

8 Array handling -- part 1 -- M. Smith 8 of 30 BEST INDICATION that code “ran to completion” DISASSEMBLY WINDOW SHOWS “BLUE LINE” AT __lib_prog_term – library program terminate function

9 Array handling -- part 1 -- M. Smith 9 of 30 indication that code “ran to completion” ALL expected tests ran and the assert statistics are shown

10 Array handling -- part 1 -- M. Smith 10 of 30 IF E-TDD GUI is active then “double click” on the error takes you to the test We “expect” the test to fail as we only have “stub” being used to check “linkage”

11 Array handling -- part 1 -- M. Smith 11 of 30 Set first value in array to 0 Will pass the first test if correctly done Blackfin is like MIPS, passes parameters into functions using registers and the stack R0 – first parameter R1 – second parameter R2 – third parameter Fourth parameter passed on the stack

12 Array handling -- part 1 -- M. Smith 12 of 30 Like MIPs, Blackfin has “load” and “store” architecture Blackfin is like MIPS – it has load and store architecture This means you can’t put values directly into memory You must load value into a register and then store register to memory Double click on the error jumps you to the error in the “source” code ILLEGAL TO STORE A VALUE DIRECTLY TO MEMORY

13 Array handling -- part 1 -- M. Smith 13 of 30 MIPs has “general” registers Blackfin has “data” and “pointer” registers Blackfin (like Motorola 68K) has “data” and “pointer” registers “data” registers store data values “pointer” registers store addresses and can be used to access memory Why not use R1 = 0; Rather than R2 = 0; ILLEGAL TO STORE A VALUE DIRECTLY TO MEMORY Place in register, store register value ILLEGAL TO USE [R0] TO ACCESS MEMORY

14 Array handling -- part 1 -- M. Smith 14 of 30 “address” parameter passed in “data” register R0. Move R0 to “pointer” P0 Blackfin (like Motorola 68K) has “data” and “pointer” registers P0 = R0; transfer “parameter” (R0) into a pointer register (P0) [P0] = R2; Use “pointer” register to access memory ILLEGAL TO STORE A VALUE DIRECTLY TO MEMORY Place in register, store register value

15 Array handling -- part 1 -- M. Smith 15 of 30 Assembler “warns” you about inefficiencies in your code -- WAIL You set P0 and then immediately use P0 This causes the processor “instruction pipeline” to stall

16 Array handling -- part 1 -- M. Smith 16 of 30 Note that one more test has now passed E-TDD GUI deactivated so “click” to find error no longer works Right click to show “line” numbers

17 Array handling -- part 1 -- M. Smith 17 of 30 Make first 5 values of array = 0 through “hard-coding” (straight line coding) Weird error messages [P0 + 0] and [P0 + 4] are legal [P0 + 1], [P0 + 2], [P0 + 3] are illegal Reason – we are using “ints” – 32-bit values 4 bytes for each memory location

18 Array handling -- part 1 -- M. Smith 18 of 30 Increment pointer register by 4 when accessing “int” arrays Get correct result when increment by 4 Avoid this common addressing error by allowing the processor to do the calculation

19 Array handling -- part 1 -- M. Smith 19 of 30 “AUTO”Increment pointer register by 4 when accessing “int” arrays Get correct result when increment by 4 Avoid this common addressing error by allowing the processor to do the calculation

20 Array handling -- part 1 -- M. Smith 20 of 30 Add new tests for 10 points NOTE COMPILER ERROR MESSAGE Fix code by telling compiler that the change is not a defect

21 Array handling -- part 1 -- M. Smith 21 of 30 #undef N #define N 10 – stops error messages

22 Array handling -- part 1 -- M. Smith 22 of 30 As expected – code fails the new test

23 Array handling -- part 1 -- M. Smith 23 of 30 REFACTOR the code to make it more readable REFACTORING does not fix errors Define the incoming parameters

24 Array handling -- part 1 -- M. Smith 24 of 30 REFACTOR the code to make it more readable REFACTORING does not fix errors Define the local variables called “registering” the variables An “optimization” as “C++” would place these on the “local stack”

25 Array handling -- part 1 -- M. Smith 25 of 30 REFACTOR the code to make it more readable REFACTORING does not fix errors This FORMATTING is this “course” REQUIRED convention for coding as makes it easier to understand by you, TA’s and me

26 Array handling -- part 1 -- M. Smith 26 of 30 Attempt 1 at doing “software for-loop” Set count = 0 Check count Loop content Increment count jump to loop start BUT GET ERROR MESSAGE

27 Array handling -- part 1 -- M. Smith 27 of 30 Hint at what is wrong LOOP is in blue Blue means “keyword” in Blackfin assembly Only works (turns BLUE) if using VDSP editor

28 Array handling -- part 1 -- M. Smith 28 of 30 LOOP Is a keyword for the Blackfin assembly code as the processor can do “highly efficient” hardware loops

29 Array handling -- part 1 -- M. Smith 29 of 30 Will do “hardware loops” in another class ZERO OVER-HEAD LOOPS HARDWARE DOES count++ and check for count >= N

30 Array handling -- part 1 -- M. Smith 30 of 30 Tackled – Basic Array handling Setting test environment – part of Lab.0 Setting up the tests Writing “enough” assembly code so you can “call the code, and return without crashing” Setting one value in an array Moving through an array – Hard coding and auto-increment addressing modes – Software loops – Hardware loops will be covered in a later lecture


Download ppt "Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);"

Similar presentations


Ads by Google