Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.64 KB | None | 0 0
  1. .text
  2. .global _start
  3.  
  4. _start:
  5.         LDR R8, =0xFF200050 //Store address of KEYS into R8
  6.         LDR R9, =0xFF200000 //Store address of LEDS into R9
  7.         LDR R10, =0xFFFEC600//Store address of timer into R10
  8.         LDR R11, =200000000 //Count value
  9.         MOV R12, #0b011     //Instruction codes for timer
  10.  
  11.         MOV R1, #0x1        //LED VALUES
  12.        
  13.         STR R11, [R10]      //Feed in count value of timer
  14.         STR R12, [R10, #8]  //Init timer to start
  15.        
  16. LEFT:
  17.         BL KEYPOLL
  18.         STR R1, [R9]        //Load value into LEDS
  19.         BL DELAY            //Delay until next
  20.         CMP R1, #0b1000000000   //Check if at edge
  21.         BEQ RIGHT           //Go to RIGHT if at edge
  22.         LSL R1, R1, #1      //Shift LEDS value to left by 1
  23.         B   LEFT
  24.        
  25. RIGHT:
  26.         BL KEYPOLL
  27.         STR R1, [R9]        //Load value into LEDS
  28.         BL DELAY                //Delay until next
  29.         CMP R1, #0b1        //See if at edge
  30.         BEQ LEFT            //Go to LEFT if at edge
  31.         LSR R1, R1, #1      //Shift LEDS value to right by 1
  32.         B   RIGHT
  33.  
  34. KEYPOLL:
  35.         LDR R0, [R8]        //Load KEYS state into R0
  36.         CMP R0, #0b1000     //See if KEY3 is activated
  37.         BEQ KEY3_LOOP       //If it isn't go to pause
  38.         MOV PC, LR
  39. KEY3_LOOP:
  40.         MOV R0, #0b010
  41.         STR R0, [R10, #8] // Sets Auto = 1, Enable = 0
  42.         LDR R0, [R8]
  43.         CMP R0, #0b1000
  44.         BEQ KEY3_LOOP
  45. KEY3_LOOP_CONT:
  46.         LDR R0, [R8]
  47.         CMP R0, #0b0000
  48.         BEQ KEY3_LOOP_CONT
  49. KEY3_LOOP_CONT2:
  50.         LDR R0, [R8]
  51.         CMP R0, #0b1000
  52.         BEQ KEY3_LOOP_CONT2
  53.         MOV R0, #0b011
  54.         STR R0, [R10, #8] // Sets Auto = 1, Enable = 1
  55.         MOV PC, LR
  56. DELAY:
  57.         LDR R0, [R10, #12]  //Load value of timer's F bit
  58.         CMP R0, #0          //See if F bit is 0
  59.         BEQ DELAY           //Continue delaying if it is
  60.         STR R0, [R10, #12]  //Restart timer
  61.         MOV PC, LR          //Return to sweeping loop
  62.        
  63. .end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement