;; ;; $Id: hex.asm,v 1.3 2001/03/05 03:46:16 james Exp $ ;; ;; hex.asm, convert byte to ascii digits ;; Copyright (C) 2001 James Cameron (quozl@us.netrek.org) ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;; eb_hex ; ( byte -- lsn msn ) ; convert a byte to hex popw ; get the value to convert movwf r_ephemeral ; save for second nibble call eb_hex_digit ; convert least significant nibble swapf r_ephemeral,w ; get most significant nibble call eb_hex_digit ; convert most significant nibble return eb_hex_digit ; [ w -- ] ( -- nibble ) andlw 0x0f ; keep low nibble only pushw ; save to data stack movlw 0x0a ; test for greater than nine subwf indf,w ; by subtraction movlw 0x30 ; assume numeric btfsc status,c ; test result of subtraction movlw 0x37 ; alphabetic addwf indf,f ; offset to ASCII character return