; ; ; 25-05-2008 ; ; Filename: "Dice.s" ; ;****************************************************************************** .equ __24FJ16GA002, 1 .include "p24FJ16GA002.inc" ;.............................................................................. ;Global Declarations: ;.............................................................................. .global __reset ;The label for the first line of code. ;.............................................................................. ; Code Section in Program Memory ;.............................................................................. ; ; .text ;Start of Code section __reset: MOV #__SP_init, W15 ;Initalize the Stack Pointer MOV #0x0FFE, W0 ;Initialize the Stack Pointer Limit Register MOV W0, SPLIM NOP ;Add NOP to follow SPLIM initialization CALL _wreg_init ;Call _wreg_init subroutine ; ; initialize ; MOV #0xFFFF,W1 MOV W1,AD1PCFG ; turn off the Analog nature of Port A pins MOV #0xFFEC, W1 ; set PORTA as input, RA0, RA1, RA4 = output MOV W1,TRISA MOV #0x0000,W1 MOV W1,PORTA MOV #0xFFC3, W1 ; set PORTB as input, RB2, RB3, RB4, RB5 = output MOV W1,TRISB MOV #0x0000,W1 MOV W1,PORTB llx: call display_1 call wait_long call display_2 call wait_long call display_3 call wait_long call display_4 call wait_long call display_5 call wait_long call display_6 call wait_long BRA llx ;-------------- ; Check: XX: MOV PORTB,W1 MOV #0x0040,W2 AND W1,W2,W1 BRA Z,XX RETURN ;--------------- display_1: MOV #0x00FF,W1 MOV W1,PORTA MOV #0x00F7,W1 MOV W1,PORTB RETURN display_2: MOV #0x00FE,W1 MOV W1,PORTA MOV #0x00DF,W1 MOV W1,PORTB RETURN display_3: MOV #0x00ED,W1 MOV W1,PORTA MOV #0x00F7,W1 MOV W1,PORTB RETURN display_4: MOV #0x00EC,W1 MOV W1,PORTA MOV #0x00DF,W1 MOV W1,PORTB RETURN display_5: MOV #0x00EC,W1 MOV W1,PORTA MOV #0x00D7,W1 MOV W1,PORTB RETURN display_6: MOV #0x00EC,W1 MOV W1,PORTA MOV #0x00CB,W1 MOV W1,PORTB RETURN wait_long: MOV #100,W1 wait_L: DEC W1,W1 BRA NZ,wait_L call Check RETURN ;--------------------------------------------------------------- done: BRA done ;Place holder for last line of executed code ;.............................................................................. ;Subroutine: Initialization of W registers to 0x0000 ;.............................................................................. _wreg_init: CLR W0 MOV W0, W14 REPEAT #12 MOV W0, [++W14] CLR W14 RETURN ;--------End of All Code Sections --------------------------------------------- .end ;End of program code in this file