NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

__MAIN

; The following lines are similar to Lab-1 but use a defined address to make it easier.
; They just turn off all LEDs
LDR R10, =LED_BASE_ADR ; R10 is a permenant pointer to the base address for the LEDs, offset of 0x20 and 0x40 for the ports

MOV R3, #0xB0000000 ; Turn off three LEDs on port 1
STR R3, [r10, #0x20]
MOV R3, #0x0000007C
STR R3, [R10, #0x40] ; Turn off five LEDs on port 2

; This line is very important in your main program
; Initializes R11 to a 16-bit non-zero value and NOTHING else can write to R11 !!
MOV R11, #0xABCD ; Init the random number generator with a non-zero number
loop BL RandomNum

BL COUNTER
B loop

;
; Display the number in R3 onto the 8 LEDs
DISPLAY_NUM STMFD R13!,{R1, R2, R4, R5, R14}

EOR R3, #0xFFFFFFFF ; flip everything

MOV R4, R3
AND R4, R4, #0x1F ; extract last 5 bits
RBIT R4, R4 ; reverse
LSR R4, R4, #25 ; shift off all 0s so now it's only the 5 bits
STR R4, [R10, #0x40] ; store into pin 2-6

MOV R4, R3
AND R4, R4, #0x20 ; extract 6th bit
LSL R4, #26 ; move into MSB part

MOV R5, R3
AND R5, R5, #0xC0 ; extract bits 7 and 8
RBIT R5, R5 ; reverse
LSL R5, R5, #4 ; put them in MSB 4th and 5th

ADD R4, R5, R4 ; add bits 6 and 7 and 8
STR R4, [R10, #0x20] ;

LDMFD R13!,{R1, R2, R15}

;
; R11 holds a 16-bit random number via a pseudo-random sequence as per the Linear feedback shift register (Fibonacci) on WikiPedia
; R11 holds a non-zero 16-bit number. If a zero is fed in the pseudo-random sequence will stay stuck at 0
; Take as many bits of R11 as you need. If you take the lowest 4 bits then you get a number between 1 and 15.
; If you take bits 5..1 you'll get a number between 0 and 15 (assuming you right shift by 1 bit).
;
; R11 MUST be initialized to a non-zero 16-bit value at the start of the program OR ELSE!
; R11 can be read anywhere in the code but must only be written to by this subroutine
RandomNum STMFD R13!,{R1, R2, R3, R14}

AND R1, R11, #0x8000
AND R2, R11, #0x2000
LSL R2, #2
EOR R3, R1, R2
AND R1, R11, #0x1000
LSL R1, #3
EOR R3, R3, R1
AND R1, R11, #0x0400
LSL R1, #5
EOR R3, R3, R1 ; the new bit to go into the LSB is present
LSR R3, #15
LSL R11, #1
ORR R11, R11, R3

LDMFD R13!,{R1, R2, R3, R15}

;
; Delay 0.1ms (100us) * R0 times
; aim for better than 10% accuracy
; The formula to determine the number of loop cycles is equal to Clock speed x Delay time / (#clock cycles)
; where clock speed = 4MHz and if you use the BNE or other conditional branch command, the #clock cycles =
; 2 if you take the branch, and 1 if you don't.

DELAY STMFD R13!,{R2, R14}

TEQ R0, #0
BEQ exitDelay

MultiplierLoop
MOV R2, #0x85

Loop
SUBS R2, #1
BNE Loop

SUBS R0, #1
BNE MultiplierLoop

exitDelay LDMFD R13!,{R2, R15}


COUNTER STMFD R13!, {R0-R2, R14}

MOV R0, #1000
MOV R2, #256
MOV R3, #0

LoopCount
BL DISPLAY_NUM
BL DELAY
ADD R3, R3, #1
TEQ R2, R3
BEQ LoopCount

LDMFD R13!, {R0-R2, R15}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.