Skip to content

Instantly share code, notes, and snippets.

@dinigo
Created October 30, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinigo/a05c7369554c67a3ef91 to your computer and use it in GitHub Desktop.
Save dinigo/a05c7369554c67a3ef91 to your computer and use it in GitHub Desktop.
Collection of usefull assembly loops and functions
;=====================================================;
; 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