 
;
; Just check out MPLAB

		.include "p24Hxxxx.inc"

            .global  __reset          ;The label for the first line of code.   

            .bss            ;unitialized data section
binNum:     .space   2
hexChar:    .space   2


;..............................................................................
;Code Section in Program Memory
;..............................................................................

            .text
__reset:
            mov      #__SP_init, w15       ;Initalize the Stack Pointer
            mov      #__SPLIM_init,W0   
            mov      W0, SPLIM             ;Initialize the stack limit register

		    .equ     numinit, 13           ; give a name for initial value

		; uint16_t binNum=13
            mov      #numinit, w0   ; store 13 in w0       
            mov      wreg,binNum    ; store 13 in binNum 
      
		; if(binNum >= 10) 
            sub      #10, w0       ; w0 = binNum -10, sets status register bits
            bra      ge,useLet     ; go to if-body if binNum >= 10 

		; the else-body:  hexChar = binNum + '0' 
            mov      binNum,wreg    ; w0 = binNum              
            add      #48, w0        ; w0 = w0 + 48 = binNum + '0'             
		goto    storeChar       ; skip the if-body

            ; the if-body:  hexChar = binNum + ('A' - 10)     
useLet:     mov      binNum,wreg    ; w0 = binNum
            add      #55, w0        ; w0 = w0 + 55 = binNum + 'A' - 10    

            ; store the contents of w0, the calculated value, in hexChar
storeChar:  mov      wreg,hexChar          

done:
            goto     done

            .end       ;End of program code in this file
