Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .init /*Creates a section called init */
- .globl _start /*Ensures the code within this section runs first*/
- _start: /*Between this section and the next section label*/
- /*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. */
- ldr r0,=0x20200000 /*LOAD REGISTER: a MNEMONIC that stores the hexadecimal number in register 0*/
- /*The hex number is a memory address. 20200000 base 16 is the GPIO controller's arbitrary location. */
- /*ENABLING OUTPUT TO THE 16TH PIN*/
- 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. */
- /*It moves the hex number 1 into the r1 address. */
- lsl r1,#18 /*LOGICAL SHIFT LEFT: shifts binary representation of first argument, i.e. r1 by second argument, i.e. 18 places. */
- /*Ergo, from 1 base 2 to 1,000,000,000,000,000,000 base 2 which is 1 with 18 zeros. */
- 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. */
- /*The 16th pin, the GPIO pin, is now ready, willing, and able. Now we can send the message to turn on. */
- /*The funny thing is, we turn off the pin, to turn ON the pin! Silly OS designers! */
- mov r1,#1 /*Places a "1" into r1*/
- lsl r1,#16 /*Shifts binary representation of 1 and does a logical shift left by 16 places. */
- str r1,[r0,#40] /*The "magic" number, this is the address at GPIO Controller + 40 base 10, effectively writing to the GPIO pin.*/
- /*The opposite "magic" number to turn the pin ON, and the LED effectively off, */
- loop$: /*scoobydoo: labels the next line as scoobydoo. This means the next line is labelled as loop. */
- b loop$ /*BRANCH: causes the current line, labelled as "loop". And again, and again. */
- /*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