2012-10-22 03:14 AM
hello,
please is there a sort of stm8s assembly language available who convert a 16 bit binary to 5 bcd code many thanks marc debruyne2012-10-22 05:24 AM
Marc,
here is the code I use to compute the ASCII representation of an unsigned 16 bit quantity: .PrintU16 PUSHW X LDW Y,#10000 DIVW X,Y LD A,XL ADD A,#'0' LDW X,Y LDW Y,#1000 DIVW X,Y SWAPW X LDW (1,SP),X LDW X,Y LDW Y,#100 DIVW X,Y ADDW X,(1,SP) ADDW X,#'00' LDW (1,SP),X LDW X,Y LDW Y,#10 DIVW X,Y PUSH A LD A,XL LD YH,A POP A ADDW Y,#'00' POPW X RET The caller must store in the X register the quantity to convert, while on exit the registers {A,X,Y} contain its ASCII representation. I hope you'll find it useful. Regards EtaPhi2012-10-22 05:42 AM
https://sites.google.com/site/klaasdc/stm8s-projects/16bit-to-bcd-conversion
It can probably be done better, but it's what I needed at the time. Maybe it's useful for you.2012-10-22 12:19 PM
hello sir,
many thanks, i have just try the program and its working very well; i must you wish ,youre a clever man. i could not find it, have search a lot, and tryed to convert from different processors, but with no result.so i have tryed the last chance to come to this forum. congratulations