Created
October 30, 2015 17:30
-
-
Save dinigo/a05c7369554c67a3ef91 to your computer and use it in GitHub Desktop.
Collection of usefull assembly loops and functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;=====================================================; | |
; This piece of code runs certain times depending on ; | |
; how many nested loops you create. Each loop can ; | |
; count up to 255. ; | |
; We declare a variable for each loop and preload ; | |
; them with the default value (maxium FFh or 255d ; | |
; For demonstration purposes we're using just 3 ; | |
; nested loops executing a total of 845.325 times ; | |
;=====================================================; | |
; Declare a variable for each nested loop | |
cblock 0x20 | |
COUNTER1 | |
COUNTER2 | |
COUNTER3 | |
endc | |
; Declare each preload | |
PRELOAD1 equ 255 | |
PRELOAD2 equ 255 | |
PRELOAD3 equ 13 | |
begin: | |
movlw PRELOAD1 | |
movwf COUNTER1 | |
loop1: | |
movlw PRELOAD2 | |
movwf COUNTER2 | |
bucle2: | |
movlw PRELOAD3 | |
movwf COUNTER3 | |
bucle3: | |
;=== INSTRUCTIONS HERE ===; | |
decfsz COUNTER3 | |
goto loop3 | |
decfsz COUNTER2 | |
goto loop2 | |
decfsz COUNTER1 | |
goto loop1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment