DataOS_A.asm
资源名称:length.rar [点击查看]
上传用户:sdjqgc
上传日期:2022-08-06
资源大小:2404k
文件大小:1k
源码类别:
嵌入式/单片机编程
开发平台:
Asm
- //=======================================================================================//
- //Program: 二进制转换成BCD码 C语言调用 unsigned int F_Binary_BCD(unsigned int Binary)
- //InPut: Binary 要转换的二进制数
- //OutPut: r1
- //Date: 2004年4月25日
- //=======================================================================================//
- .ram
- .var BCD_qw,BCD_bw;
- .code
- .public _F_Binary_BCD
- _F_Binary_BCD:.proc
- push r2,r4 to [sp]
- r2=0
- r3=0
- r4=0
- [BCD_bw]=r2
- [BCD_qw]=r2
- cmp r1,1000
- jb F_BCD_B
- F_BCD_Q:
- r2=[BCD_qw]
- r2+=1
- [BCD_qw]=r2
- r1-=1000
- cmp r1,1000
- jae F_BCD_Q
- F_BCD_B:
- cmp r1,100
- jb F_BCD_S
- r2=[BCD_bw]
- r2+=1
- [BCD_bw]=r2
- r1-=100
- cmp r1,100
- jae F_BCD_B
- F_BCD_S:
- cmp r1,10
- jb F_BCD_G
- r3+=1
- r1-=10
- cmp r1,10
- jae F_BCD_S
- F_BCD_G:
- r4=r1
- r1=0x0000
- r1=r1 rol 4
- r1=[BCD_qw]
- r2=[BCD_bw]
- r2=r2 ror 4
- r1=r1 rol 4
- r3=r3 ror 4
- r1=r1 rol 4
- r4=r4 ror 4
- r1=r1 rol 4
- pop r2,r4 from [sp]
- retf
- .endp