Advertisement
Guest User

Untitled

a guest
May 18th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.67 KB | None | 0 0
  1. .syntax unified
  2. .global main
  3.  
  4. .type main, %function
  5.  
  6. main:
  7.  
  8.  
  9.   @Red Clock (port B) Clock for Ports
  10.   ldr r1, =0x40021000
  11.   ldr r2, [r1, 0x4C]
  12.   orr r2, 2
  13.  
  14.   @Green Clock (port E)
  15.   orr r2, 16 @measured in binary (2^5 because 5th port)
  16.   str r2, [r1, 0x4C]
  17.  
  18.   @Setting pin port B and output mode (red light pin)
  19.   ldr r1, =0x48000400
  20.   ldr r2, [r1, 0]
  21.   orr r2, 16 @(2^4 on, set bit 4)
  22.   bic r2, 32  @(2^5 off, clear set bit 5)
  23.   str r2, [r1, 0]
  24.  
  25.   @same thing, port E with (Green Light Pin)
  26.   ldr r1, =0x48001000 @look up manual
  27.   ldr r2, [r1, 0]
  28.   orr r2, 65536 @(2^17 on)
  29.   bic r2, 131072  @(2^18 off)
  30.   str r2, [r1, 0]
  31.  
  32.   @Turning Red light on
  33.   ldr r1, =0x48000400
  34.   ldr r2, [r1, 0x14]
  35.   orr r2, 4
  36.   str r2, [r1, 0x14]
  37.  
  38.   @Turning Green light on
  39.   ldr r1, =0x48001000
  40.   ldr r2, [r1, 0x14]
  41.   orr r2, 256
  42.   str r2, [r1, 0x14]
  43.  
  44.  
  45.  
  46.  
  47.   @ ldr r0, =0xcafe0000
  48.   @ ldr r1, =0xffff
  49.  
  50.   @ orr r3 , r0,r1
  51.   @ lsr r4, r0, 16
  52.  
  53.   @ lsr r5, r4, 4
  54.   @ lsl r5, r5, 20
  55.   @ lsr r6, r1, 12
  56.   @ lsl r6, r6, 16
  57.   @ orr r5, r6
  58.  
  59.   @ lsl r6, r4, 24
  60.   @ lsr r6, r6, 8
  61.  
  62.   @ @ ldr r3, =0xcafeffff
  63.   @ @ ldr r4, =0xcafe
  64.   @ @ ldr r5, =0xcaff0000
  65.   @ @ ldr r6, =0xc0fe0000
  66.  
  67.   @ ldr r1, =main
  68.  
  69.   @ cope:
  70.   @   .ascii "COPE"
  71.  
  72.   @   @ load "COPE" into r1
  73.   @   ldr r0, cope
  74.   @ @ your code goes here
  75.  
  76. @   ldr r1, =storage
  77. @   @ your code starts here
  78.  
  79. @   ldr r2, [r1 ,+12]
  80.  
  81. @   add r2, 1
  82.  
  83. @   str r2, [r1 ,+12]
  84. @ .data
  85. @   storage:
  86. @     .word 2, 3, 0, 0 @ don't change this line
  87. @   @ Adressed in bytes, a word is 32 bits and a byte is 8 bits.
  88.  
  89. @ @ when it's all done, spin in an infinite loop
  90. @ .text
  91. @ loop:
  92. @   nop
  93. @   b loop
  94. .size main, .-main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement