AVR乘除法子程序_第1页
AVR乘除法子程序_第2页
AVR乘除法子程序_第3页
AVR乘除法子程序_第4页
AVR乘除法子程序_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

AVR乘法除法程序apliccationioetvavr 20 * * * * * * * * * * * * * * * * * * title : multipleyanddivideroutines*版本:1.1上次更新:97.07.04* target : at 90 sxxxx (allravrdevices )* * supporte-mail : AVR * * * DESCRIPTION* thisapplicationnotelistingssubroutinesforthefollowing* muliliply/divide applications.routeinesarestraight-line implements用于速度的最优化:* * 88=16比特不一致* 168=32比特不一致* 1616=32比特不一致*8/8=88比特不一致 * 16/16=16 16 bit unsigned* *求求求求求求求求求求求求求求求求求求求求求. include 1200def.inc rjmpRESET; 重置处理程序。求求求求求求求求求求求求求求求求求求求求求* * mpy8u -8x8 bitunsignedmultiplication* * * Number of cycles:65低注册用户: none高注册用户:3 (mc8u、mp8u/m8uL、m8uH )* * note : resultlowbyteandthemultipliersharethesameregister* thiscausesthemultipliertobeoverwrittenbytheresult .* *求求求求求求求求求求求求求求求求求求求求求subrouteineregistervariables. defmc8u=r16; 多路复用器cand. defmp8u=r17; multiplier. defm8uL=r17; result Low byte. defm8uH=r18; result High byte. defcycle=r31* * * * *代码mpy8u : ldi循环,8clrm8uH; 清除结果高字节lsrmp8u; shift multiplierm8u:brccnoad80; if carry setaddm8uH、mc8u; addmultipliercandtoresulthighbytenoad80:rorm8uH; shift right result High byterorm8uL; rotaterightresultlbyteandmultiplierdec cyclebrne m8uret求求求求求求求求求求求求求求求求求求求求求2字节乘法子例程16位* 16位-ah.al * BH.bl=result-16位* 8位- ah.al * bl=result3.2.1-求求求求求求求求求求求求求求求求求求求求求. defaL=r16; 多行字节/被乘数. defaH=r17; 多重高位元组。. defbL=r18; multiplier low byte /乘数. defbH=r19; multiplier高字节. defresult0=r18; result byte 0 (LSB ). defresult1=r19; result byte 1. defresult2=r20; result byte 2. defresult3=r21; 结果字节3 (PS ). defcycle=r31* * * * * *代码m16_8u: ldi cycle,8ldir 19,0rjmp mBeginm 16 _ 16u : ldi周期,16msbegin:clrresult3; clear 2 highest bytes of resultclrresult2lsrbH; 乘数/2rorbL; C-Rd.0 Rd.0-Rd.1 Rd.15-0m16_16u1:brccnoadd; Rd.0=1/(if carry set )addresult2,aL; 乘数的低位字节与结果的2字节相加adcresult3,aH; 乘法的高位字节加上结果的3字节noadd:rorresult3; shift right result byte 3rorresult2; rotate right result byte 2rorresult1; rotateresultbyte1andmultiplierhighrorresult0; rotateresultbyte0andmultiplierlowdec cyclebrne m16_16u1ret求求求求求求求求求求求求求求求求求求求求求* * div8u -8/8 bitunsigneddivision* * thisssubroultinedivesthetworegistervariables dd8u (divided ) and* dv8u (divisor ).theresultisplaceddin dress 8u andtheremainderin * drem8u”* *words :94返回低注册用户:1 (drem 8u )高亮度:2 (dres 8u/dd8u、dv8u、cycle )* *求求求求求求求求求求求求求求求求求求求求求subrouteineregistervariables. defdrem8u=r15; remainder. defdres8u=r16; result (结果). defdd8u=r16; 戴维德公司. defdv8u=r17; divisor. defcycle=r18代码* * * * * * * * r16/r17=r16r 15 * * * * * * * * * * * *div8u:clrdrem8u; clear remainder and carryldi周期,9; 8 1d8u_0:罗尔德8u; shift left dividenddec cyclebreqd8u_2罗尔德rem 8u; shift dividend into remainder辅drem8u、dv8u; remainder=remainder - divisorbrccd8u_1; if result negativedrem8u、dv8u; restore remainderclc; clearcarrytobeedintoresultrjmpd8u_0; elsed8u_1:sec; set carry to be shifted into resultrjmpdd8u_0d8u_2:ret求求求求求求求求求求求求求求求求求求求求求* * div8u -8/8 bitunsigneddivision* * thisssubroultinedivesthetworegistervariables dd8u (divided ) and* dv8u (divisor ).theresultisplaceddin dress 8u andtheremainderin * drem8u”* *words :66返回周期编号:50/58/66 (最小/avg /最大)返回低注册用户:1 (drem 8u )* highregisterused :2 (dres 8u/dd8u,dv8u )* *求求求求求求求求求求求求求求求求求求求求求subrouteineregistervariables. defdrem8u=r15; remainder. defdres8u=r16; result (结果). defdd8u=r16; 戴维德公司. defdv8u=r17; divisor* * * * * *代码div8u :辅drem8u、drem8u; clear remainder and carry罗德8u; shift left dividend罗尔德rem 8u; shift dividend into remainder辅drem8u、dv8u; remainder=remainder - divisorbrccd8u_1; if result negativedrem8u、dv8u; restore remainderclc; clearcarrytobeedintoresultrjmpd8u_2; elsed8u _ 1:秒; set carry to be shifted into resultd8u _ 2: 罗ldd 8u; shift left dividend罗尔德rem8u; shift dividend into remainder辅drem8u、dv8u; remainder=remainder - divisorbrccd8u_3; if result negativedrem8u、dv8u; restore remainderclc; clearcarrytobeedintoresultrjmpd8u_4; elsed8u _ 3:秒; set carry to be shifted into resultd8u _ 4: 罗ldd 8u; shift left dividend罗尔德rem 8u; shift dividend i

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论