cancel
Showing results for 
Search instead for 
Did you mean: 

bcd to bin

debruyne.marc
Associate II
Posted on April 30, 2013 at 09:19

hello,

please can help me someone one with an assembly language  who convert a 5digit BCD to BIN

many thanks

2 REPLIES 2
fggnrc2
Associate II
Posted on April 30, 2013 at 15:45

.ScanU16
; Save ASCII Input
PUSHW Y
PUSHW X
; U16 Result = 0;
CLRW X
; Loop counter initialization
LDW Y,#5
ScanU16Loop
; Result = Result * 10;
SLLW X
; Temporary word allocation
PUSHW X
SLLW X
SLLW X
ADDW X,(1,SP)
; (1,SP) = value of A
CP A,#'0'
JRMI BadDigitValue
CP A,#'9'
JRUGT BadDigitValue
SUB A,#'0'
LD (2,SP),A
CLR (1,SP) ; High Byte is always 0
; Result = Result + Value_of_Digit;
ADDW X,(1,SP)
BadDigitValue
; Temporary word deallocation
ADDW SP,#2
; Process next digit
POP A
DECW Y
JRNE ScanU16Loop
SUBW SP,#1
RET

Marc, the above function returns in X the value of the five ASCII digits which are stored in {A,X,Y}. This function is the inverse of the one I send you here

/f57b93c7

EtaPhi
debruyne.marc
Associate II
Posted on May 02, 2013 at 21:12

hello sir,

i thank you very mutch for the program you have prepared.

it works very well

i like too the stm8s ,pity there is not many information on it

but any way, thanks for the help

marc debruyne