1 / 30

Blackfin Array Handling Part 1

Blackfin Array Handling Part 1. Making an array of Zeros void MakeZeroASM(int foo[ ], int N);. 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”

wade-hooper
Télécharger la présentation

Blackfin Array Handling Part 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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 Array handling -- part 1 -- M. Smith

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

  4. “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 statementRTS = ReTurn from Subroutine Array handling -- part 1 -- M. Smith

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

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

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

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

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

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

  11. Set first value in array to 0Will 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 Array handling -- part 1 -- M. Smith

  12. 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 ILLEGAL TO STORE A VALUEDIRECTLY TO MEMORY Double click on the errorjumps you to the errorin the “source” code Array handling -- part 1 -- M. Smith

  13. MIPs has “general” registersBlackfin has “data” and “pointer” registers ILLEGAL TO STORE A VALUE DIRECTLY TO MEMORY Place in register, store register value 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 ILLEGAL TO USE [R0] TO ACCESS MEMORY Why not useR1 = 0; Rather than R2 = 0; Array handling -- part 1 -- M. Smith

  14. “address” parameter passed in “data” register R0. Move R0 to “pointer” P0 ILLEGAL TO STORE A VALUE DIRECTLY TO MEMORY Place in register, store register value 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 Array handling -- part 1 -- M. Smith

  15. 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 Array handling -- part 1 -- M. Smith

  16. Note that one more test has now passed E-TDD GUIdeactivatedso “click” to find error no longer works Right click toshow “line”numbers Array handling -- part 1 -- M. Smith

  17. 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 Array handling -- part 1 -- M. Smith

  18. 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 Array handling -- part 1 -- M. Smith

  19. “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 Array handling -- part 1 -- M. Smith

  20. Add new tests for 10 points NOTE COMPILER ERROR MESSAGE Fix code by tellingcompiler that thechange is not a defect Array handling -- part 1 -- M. Smith

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

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

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

  24. 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” Array handling -- part 1 -- M. Smith

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

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

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

  28. LOOP Is a keyword for the Blackfinassembly codeas the processorcan do “highlyefficient”hardware loops Array handling -- part 1 -- M. Smith

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

  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 Array handling -- part 1 -- M. Smith

More Related