From: Gernot.Fink <Ger...@mu...> - 2001-07-24 19:51:12
|
On Die, 24 Jul 2001, Matthias Wei=DFer wrote: >Hi all > >i'd like to write a funtion that adds 1 to a char variable. The result h= ave >to be a BCD-Code. So after the instruction there have to be a "da A" I w= rote >the funktion: > I use this verry dirty code which is extremly depends the Compiler . But = what other can i do on a small at89c2051. unsigned char addbcd(unsigned char c) { _asm mov a,_DPL add a,#1 da a mov _DPL,a _endasm; return c; } =20 It generates this: 8129 996 _addbcd: 997 ; tmp.c 123 =20 998 ; tmp.c 121 8129 E5 82 999 mov a,_DPL 812B 24 01 1000 add a,#1 812D D4 1001 da a 812E F5 82 1002 mov _DPL,a 1003 ; tmp.c 123 8130 1004 00101$: 0130 1005 C$tmp.c$124$1$1 =3D=3D. 0130 1006 XG$addbcd$0$0 =3D=3D. 8130 22 1007 ret =20 - MFG Gernot |