--===============0546935663== Content-type: text/plain; charset=x-user-defined Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by pch.mit.edu id k1NL9wgS025051 Dmitriy Kiryashov wrote: >=20 > Two straighforward approached conversions. > ( both out of head, not tested though ) >=20 > Might try to optimize it later :) >=20 > ; byte/10 : x is original number > ; y is result, w is remain >=20 > clrf y > movfw x >=20 > addlw -D'160' ;getting two bits of hundreds I accidentially left comment from next ( actually previous ) one. Ignore it. > rlf y,F > btfss y,0 > addlw D'160' >=20 > addlw -D'80' > rlf y,F > btfss y,0 > addlw D'80' >=20 > addlw -D'40' > rlf y,F > btfss y,0 > addlw D'40' >=20 > addlw -D'20' > rlf y,F > btfss y,0 > addlw D'20' >=20 > addlw -D'10' > rlf y,F > btfss y,0 > addlw D'10' >=20 > ; hex2bcd : x is original number > ; y has hunds and tens, W has ones left >=20 > clrf y > movfw x >=20 > addlw -D'200' ;getting two bits of hundreds > rlf y,F > btfss y,0 > addlw D'200' >=20 > addlw -D'100' > rlf y,F > btfss y,0 > addlw D'100' >=20 > addlw -D'80' ;getting four bits of tens > rlf y,F > btfss y,0 > addlw D'80' >=20 > addlw -D'40' > rlf y,F > btfss y,0 > addlw D'40' >=20 > addlw -D'20' > rlf y,F > btfss y,0 > addlw D'20' >=20 > addlw -D'10' > rlf y,F > btfss y,0 > addlw D'10' >=20 > Code space can be squeezed as >=20 > clrf y >=20 > movlw const_1 > call convert >=20 > movlw const_2 > call convert > ;... >=20 > convert > subwf x,F > rlf y,F > btfss y,0 > addwf x,F > return >=20 > WBR Dmitriy. >=20 > J=C2hn Bal=C2zs wrote: > > > > Hi, > > > > I want a 8 bit number divide by 10 (ten). > > I need the quotient and the remain. > > > > Which is the fastest ASM code for pic 16f877? > > > > Many thanks!!! > > > > Balazs > > > > _____________________________________________________________________= ______ > > [origo] klikkbank lakoss=E1gi sz=E1mlacsomag havi 199 Ft-=E9rt, bankk= =E1rtya =E9ves d=EDj n=E9lk=FCl! > > www.klikkbank.hu > > > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist --===============0546935663== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 7bit -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --===============0546935663==--