Hi, What about: movlw 66h ;If digits are > 9 then DC and/or C will be set addwf DataByte, W movlw 30h ;Default to digit being 0..9 btfsc STATUS, DC ;Is digit > 9? movlw 37h ;Yes, init with 'A'-10 movwf LSChar ;Least significant digit movlw 30h ;Default to digit being 0..9 btfsc STATUS, C ;Is digit > 9? movlw 37h ;Yes, init with 'A'-10 movwf MSChar ;Most significant digit movf DataByte, W andlw 0Fh ;Isolate lower digit addwf LSChar, F swapf DataByte, W andlw 0Fh ;Isolate upper digit addwf MSChar, F > > Okay, time to factor out the nibble to hex ASCII digit stuff into > > it's own subroutine ... > > > > hex ; convert nibble to ascii hex > > andlw 0x0f ; keep only the right bits > > movwf tmp1 ; save it for later > > sublw 0x09 ; subtract from nine > > movf tmp1,w ; bring it back (leave carry alone) > > btfsc status,c ; test result of subtraction > > ; (maybe it's btfss, not sure!) > > addlw 0x37 ; adjust to A-F > > return The above btfsc will only skip the addlw and still do the return. You will never get to hex_0 > > hex_0 > > addlw 0x30 ; adjust to 0-9 > > return > > > > byte > > movwf tmp2 ; save the byte for later > > swapf tmp2,w ; grab the high nibble back > > call hex ; encode high nibble as hex ascii > > call send ; send the byte in w to serial port > > movf tmp2,w ; fetch the byte again > > call hex ; encode low nibble > > call send ; send the byte in w to serial port > > return > > > > I've not tested that. > > It's probably wrong somewhere. > > I'm a beginner. > > Did it work? ;-) > > > > -- > > James Cameron (james.cameron@digital.com) > > Digital Equipment Corporation (Australia) Pty. Ltd. A.C.N. 000 446 800 > > > > Niki