Advertisement
Code_Dispensarat0r

Baking_Pi_DN_OK01

Nov 27th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.21 KB | None | 0 0
  1. .section .init          /*Creates a section called init */
  2.  .globl _start          /*Ensures the code within this section runs first*/
  3.  _start:                /*Between this section and the next section label*/
  4.  
  5.  /*we shall assume that the format for ops is z,y,x in that order. For example, add s0,r0,r1 would be add z,y,x, effectively adding x and y to get z. */
  6.  
  7. ldr r0,=0x20200000      /*LOAD REGISTER: a MNEMONIC that stores the hexadecimal number in register 0*/
  8.                         /*The hex number is a memory address. 20200000 base 16 is the GPIO controller's arbitrary location. */
  9.  
  10.          /*ENABLING OUTPUT TO THE 16TH PIN*/
  11. mov r1,#1               /*THE OK LED is wired to the 16th pin, so we need to enable the 16th pin. * mov (MOVE) is faster than ldr, since mov doesn't use memory for its op. */
  12.                         /*It moves the hex number 1 into the r1 address.  */
  13. lsl r1,#18              /*LOGICAL SHIFT LEFT: shifts binary representation of first argument, i.e. r1 by second argument, i.e. 18 places. */
  14.                         /*Ergo, from 1 base 2 to 1,000,000,000,000,000,000 base 2 which is 1 with 18 zeros. */
  15.  
  16. str r1,[r0,#4]          /*STORE REGISTER: adds 4 to the value of register 0, in which we placed the GPIO controller's address, and stores it in register 1. */
  17.  
  18. /*The 16th pin, the GPIO pin, is now ready, willing, and able. Now we can send the message to turn on. */
  19. /*The funny thing is, we turn off the pin, to turn ON the pin! Silly OS designers! */
  20.  
  21. mov r1,#1               /*Places a "1" into r1*/
  22. lsl r1,#16              /*Shifts binary representation of 1 and does a logical shift left by 16 places. */
  23. str r1,[r0,#40]         /*The "magic" number, this is the address at GPIO Controller + 40 base 10, effectively writing to the GPIO pin.*/
  24.                         /*The opposite "magic" number to turn the pin ON, and the LED effectively off, */
  25. loop$:                  /*scoobydoo: labels the next line as scoobydoo. This means the next line is labelled as loop. */
  26. b loop$                /*BRANCH: causes the current line, labelled as "loop". And again, and again. */
  27.  
  28. /*GNU toolchain expects a new line at the EOF (end of file). Failure to do so results in a whiny assembler.*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement