📄 hc595.s
字号:
.dbline -2
L19:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r data 20 i
.dbend
.dbfunc e Seg7_Led_float _Seg7_Led_float fV
; temp -> R20,R21
; data -> y+8
.even
_Seg7_Led_float::
xcall push_arg4
xcall push_gset2
sbiw R28,4
.dbline -1
.dbline 150
; }
; /*************************************************************************
; ** 函数名称:HC595显示浮点数据
; ** 功能描述:
; ** 输 入:
; ** 输出 :
; ** 全局变量:
; ** 调用模块:
; ** 说明:
; ** 注意:
; **************************************************************************/
; void Seg7_Led_float(float data)
; {
.dbline 157
; unsigned int temp;
; /*
; 重要说明:data+=0.00001;其中0.00001为容错值
; 解决float数据类型在计算机内部存储的误差问题,可以解决显示问题
; 但是会引入新的计算误差,如果精度要求大于0.00001建议更改容错值或者将此处注释掉
; */
; data+=0.00001;
movw R30,R28
ldd R2,z+8
ldd R3,z+9
ldd R4,z+10
ldd R5,z+11
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L41
ldi R17,>L41
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32f
movw R30,R28
std z+8,R16
std z+9,R17
std z+10,R18
std z+11,R19
.dbline 158
; point=1;
ldi R24,1
sts _point,R24
.dbline 159
; if(data>999) //错误处理,超出显示范围则全亮
ldi R16,<L44
ldi R17,>L44
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brge L42
.dbline 160
; {
.dbline 161
; HC_595_OUT(0xFF);
ldi R16,255
xcall _HC_595_OUT
.dbline 162
; Seg7_Bitselect_PORT|=((1<<Seg7_Bit0)|(1<<Seg7_Bit1)|(1<<Seg7_Bit2)|(1<<Seg7_Bit3));
in R24,0x18
ori R24,240
out 0x18,R24
.dbline 163
; }
xjmp L43
L42:
.dbline 164
; else if(data>99)
ldi R16,<L47
ldi R17,>L47
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brlt X0
xjmp L45
X0:
.dbline 165
; {
.dbline 166
; temp=data*10;
ldi R16,<L50
ldi R17,>L50
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L48
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R22,R16
subi R22,0 ; offset = 32768
sbci R23,128
xjmp L49
L48:
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall fp2int
movw R22,R16
L49:
movw R20,R22
.dbline 167
; point_pos=1;
ldi R24,1
sts _point_pos,R24
.dbline 168
; Seg7_Led_Buf[3]=temp/1000;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall div16u
sts _Seg7_Led_Buf+3,R16
.dbline 169
; Seg7_Led_Buf[2]=(temp%1000)/100;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall mod16u
ldi R18,100
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+2,R16
.dbline 170
; Seg7_Led_Buf[1]=(temp%100)/10;
ldi R18,100
ldi R19,0
movw R16,R20
xcall mod16u
ldi R18,10
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+1,R16
.dbline 171
; Seg7_Led_Buf[0]=temp%10;
ldi R18,10
ldi R19,0
movw R16,R20
xcall mod16u
sts _Seg7_Led_Buf,R16
.dbline 172
; Seg7_Led_Update();
xcall _Seg7_Led_Update
.dbline 173
; }
xjmp L46
L45:
.dbline 174
; else if(data>9)
ldi R16,<L57
ldi R17,>L57
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brlt X1
xjmp L55
X1:
.dbline 175
; {
.dbline 176
; temp=data*100;
ldi R16,<L60
ldi R17,>L60
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L58
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R22,R16
subi R22,0 ; offset = 32768
sbci R23,128
xjmp L59
L58:
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall fp2int
movw R22,R16
L59:
movw R20,R22
.dbline 177
; point_pos=2;
ldi R24,2
sts _point_pos,R24
.dbline 178
; Seg7_Led_Buf[3]=temp/1000;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall div16u
sts _Seg7_Led_Buf+3,R16
.dbline 179
; Seg7_Led_Buf[2]=(temp%1000)/100;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall mod16u
ldi R18,100
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+2,R16
.dbline 180
; Seg7_Led_Buf[1]=(temp%100)/10;
ldi R18,100
ldi R19,0
movw R16,R20
xcall mod16u
ldi R18,10
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+1,R16
.dbline 181
; Seg7_Led_Buf[0]=temp%10;
ldi R18,10
ldi R19,0
movw R16,R20
xcall mod16u
sts _Seg7_Led_Buf,R16
.dbline 182
; Seg7_Led_Update();
xcall _Seg7_Led_Update
.dbline 183
; }
xjmp L56
L55:
.dbline 185
; else
; {
.dbline 186
; temp=data*1000;
ldi R16,<L66
ldi R17,>L66
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+12
ldd R3,z+13
ldd R4,z+14
ldd R5,z+15
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L64
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L51
ldi R17,>L51
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R22,R16
subi R22,0 ; offset = 32768
sbci R23,128
xjmp L65
L64:
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall fp2int
movw R22,R16
L65:
movw R20,R22
.dbline 187
; point_pos=3;
ldi R24,3
sts _point_pos,R24
.dbline 188
; Seg7_Led_Buf[3]=temp/1000;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall div16u
sts _Seg7_Led_Buf+3,R16
.dbline 189
; Seg7_Led_Buf[2]=(temp%1000)/100;
ldi R18,1000
ldi R19,3
movw R16,R20
xcall mod16u
ldi R18,100
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+2,R16
.dbline 190
; Seg7_Led_Buf[1]=(temp%100)/10;
ldi R18,100
ldi R19,0
movw R16,R20
xcall mod16u
ldi R18,10
ldi R19,0
xcall div16u
sts _Seg7_Led_Buf+1,R16
.dbline 191
; Seg7_Led_Buf[0]=temp%10;
ldi R18,10
ldi R19,0
movw R16,R20
xcall mod16u
sts _Seg7_Led_Buf,R16
.dbline 192
; Seg7_Led_Update();
xcall _Seg7_Led_Update
.dbline 193
; }
L56:
L46:
L43:
.dbline 194
; point=0;
clr R2
sts _point,R2
.dbline -2
L40:
adiw R28,4
xcall pop_gset2
adiw R28,4
.dbline 0 ; func end
ret
.dbsym r temp 20 i
.dbsym l data 8 D
.dbend
.area bss(ram, con, rel)
.dbfile D:\avrvi\AVRVi_m128_Starter_Kit\SPI\source\lib\hc595.c
_Seg7_Led_Buf::
.blkb 4
.dbsym e Seg7_Led_Buf _Seg7_Led_Buf A[4:4]c
.area lit(rom, con, rel)
L66:
.word 0x0,0x447a
L60:
.word 0x0,0x42c8
L57:
.word 0x0,0x4110
L51:
.word 0x0,0x4700
L50:
.word 0x0,0x4120
L47:
.word 0x0,0x42c6
L44:
.word 0xc000,0x4479
L41:
.word 0xc5ac,0x3727
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -