⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led.s

📁 单片机中的中断处理模块
💻 S
📖 第 1 页 / 共 3 页
字号:
	xjmp L68
L67:
	movw R30,R28
	ldd R16,z+22
	ldd R17,z+23
	ldd R18,z+24
	ldd R19,z+25
	xcall fp2int
	movw R10,R16
L68:
	movw R22,R10
	.dbline 235
;   temp=(temp2/100);// 123.4/100=1
	ldi R18,100
	ldi R19,0
	movw R16,R22
	xcall div16u
	mov R20,R16
	.dbline 236
;   display_one(7,temp);
	mov R18,R20
	ldi R16,7
	xcall _display_one
	.dbline 237
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 238
;   led_contrl_port |= (1<<7);
	sbi 0x12,7
	.dbline 240
;   
;   temp2=data/10;
	movw R30,R28
	ldd R2,z+22
	ldd R3,z+23
	ldd R4,z+24
	ldd R5,z+25
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L38
	ldi R17,>L38
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L69
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	xcall fp2int
	movw R24,R16
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R10,R24
	xjmp L70
L69:
	movw R30,R28
	ldd R16,z+0
	ldd R17,z+1
	ldd R18,z+2
	ldd R19,z+3
	xcall fp2int
	movw R10,R16
L70:
	movw R22,R10
	.dbline 241
;   temp=temp2%10;// 123.4/10%10=2
	ldi R18,10
	ldi R19,0
	movw R16,R22
	xcall mod16u
	mov R20,R16
	.dbline 242
;   display_one(6,temp);
	mov R18,R20
	ldi R16,6
	xcall _display_one
	.dbline 243
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 244
;   led_contrl_port |= (1<<6);
	sbi 0x12,6
	.dbline 246
;   
;   temp2=data;
	movw R30,R28
	ldd R2,z+22
	ldd R3,z+23
	ldd R4,z+24
	ldd R5,z+25
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L71
	movw R30,R28
	ldd R2,z+22
	ldd R3,z+23
	ldd R4,z+24
	ldd R5,z+25
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	xcall fp2int
	movw R24,R16
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R10,R24
	xjmp L72
L71:
	movw R30,R28
	ldd R16,z+22
	ldd R17,z+23
	ldd R18,z+24
	ldd R19,z+25
	xcall fp2int
	movw R10,R16
L72:
	movw R22,R10
	.dbline 247
;   temp=(temp2%10);// 123.4%10=3
	ldi R18,10
	ldi R19,0
	movw R16,R22
	xcall mod16u
	mov R20,R16
	.dbline 248
;   display_one(5,temp);
	mov R18,R20
	ldi R16,5
	xcall _display_one
	.dbline 249
;   led_port &= 0x7F; //点亮对应小数点
	in R24,0x1b
	andi R24,127
	out 0x1b,R24
	.dbline 250
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 251
;   led_contrl_port |= (1<<5);
	sbi 0x12,5
	.dbline 253
;   
;   temp2=(data*10);
	ldi R16,<L38
	ldi R17,>L38
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R30,R28
 ; stack offset 4
	ldd R2,z+26
	ldd R3,z+27
	ldd R4,z+28
	ldd R5,z+29
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32f
	movw R30,R28
	std z+4,R16
	std z+5,R17
	std z+6,R18
	std z+7,R19
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L73
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	xcall fp2int
	movw R24,R16
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R10,R24
	xjmp L74
L73:
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall fp2int
	movw R10,R16
L74:
	movw R22,R10
	.dbline 254
;   temp=temp2%10;// 123.4*10%10=4
	ldi R18,10
	ldi R19,0
	movw R16,R22
	xcall mod16u
	mov R20,R16
	.dbline 255
;   display_one(4,temp);
	mov R18,R20
	ldi R16,4
	xcall _display_one
	.dbline 256
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 257
;   led_contrl_port |= (1<<4);
	sbi 0x12,4
	.dbline 258
;  }
	xjmp L66
L65:
	.dbline 259
;  else led_error();
	xcall _led_error
L66:
L56:
L46:
L34:
	.dbline -2
L26:
	adiw R28,16
	xcall pop_gset3
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r temp2 22 s
	.dbsym r temp 20 c
	.dbsym l data 22 D
	.dbend
	.dbfunc e display_float2 _display_float2 fV
;           temp -> R20,R21
;           data -> y+8
	.even
_display_float2::
	xcall push_arg4
	xcall push_gset2
	sbiw R28,4
	.dbline -1
	.dbline 269
; }
; 
; /***********************************************
; ** 显示浮点数 本函数占用 mega16 的空间 9%,有一点闪烁感,可将display中的延时调小
; ** 思路二:直接显示整数,再显示点
; ** 注意:输入的data必须为小于1000的四位小数(0.234,1.23,12.45,224.8) 等
; ***********************************************/
; 
; void display_float2(float data)
; {
	.dbline 271
;  UNS16 temp;
;  if(data>1000)
	ldi R16,<L29
	ldi R17,>L29
	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 X6
	xjmp L76
X6:
	.dbline 272
;  {
	.dbline 273
;  temp=data;
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L78
	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,<L39
	ldi R17,>L39
	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 L79
L78:
	movw R30,R28
	ldd R16,z+8
	ldd R17,z+9
	ldd R18,z+10
	ldd R19,z+11
	xcall fp2int
	movw R22,R16
L79:
	movw R20,R22
	.dbline 274
;  display(temp,1);
	ldi R18,1
	movw R16,R20
	xcall _display
	.dbline 275
;   return;
	xjmp L75
L76:
	.dbline 277
;  }
;  if(data>100)   //比如123.4
	ldi R16,<L42
	ldi R17,>L42
	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 X7
	xjmp L80
X7:
	.dbline 278
;  {
	.dbline 279
;   temp=data*10;
	ldi R16,<L38
	ldi R17,>L38
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L82
	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,<L39
	ldi R17,>L39
	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 L83
L82:
	movw R30,R28
	ldd R16,z+0
	ldd R17,z+1
	ldd R18,z+2
	ldd R19,z+3
	xcall fp2int
	movw R22,R16
L83:
	movw R20,R22
	.dbline 280
;   display(temp,0); //普通模式显示 1234
	clr R18
	movw R16,R20
	xcall _display
	.dbline 281
;   led_contrl_port |= (1<<5); //选中第三位
	sbi 0x12,5
	.dbline 282
;   led_port = 0x80; //点亮对应小数点
	ldi R24,128
	out 0x1b,R24
	.dbline 283
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 284
;   led_contrl_port &=~ (1<<5);
	cbi 0x12,5
	.dbline 285
;   return;
	xjmp L75
L80:
	.dbline 287
;  }
;  if(data>10)   //比如12.34
	ldi R16,<L38
	ldi R17,>L38
	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 X8
	xjmp L84
X8:
	.dbline 288
;  {
	.dbline 289
;   temp=data*100;
	ldi R16,<L42
	ldi R17,>L42
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L86
	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,<L39
	ldi R17,>L39
	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 L87
L86:
	movw R30,R28
	ldd R16,z+0
	ldd R17,z+1
	ldd R18,z+2
	ldd R19,z+3
	xcall fp2int
	movw R22,R16
L87:
	movw R20,R22
	.dbline 290
;   display(temp,0); //普通模式显示 1234
	clr R18
	movw R16,R20
	xcall _display
	.dbline 291
;   led_contrl_port |= (1<<6); //选中第二位
	sbi 0x12,6
	.dbline 292
;   led_port = 0x80; //点亮对应小数点
	ldi R24,128
	out 0x1b,R24
	.dbline 293
;   delay_ms(6);
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 294
;   led_contrl_port &=~ (1<<6);
	cbi 0x12,6
	.dbline 295
;   return;
	xjmp L75
L84:
	.dbline 297
;  }
;  if(data>1)   //比如1.234
	ldi R16,<L35
	ldi R17,>L35
	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 X9
	xjmp L88
X9:
	.dbline 298
;  {
	.dbline 299
;   temp=data*1000;
	ldi R16,<L29
	ldi R17,>L29
	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,<L39
	ldi R17,>L39
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L90
	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,<L39
	ldi R17,>L39
	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 L91
L90:
	movw R30,R28
	ldd R16,z+0
	ldd R17,z+1
	ldd R18,z+2
	ldd R19,z+3
	xcall fp2int
	movw R22,R16
L91:
	movw R20,R22
	.dbline 300
	clr R18
	movw R16,R20
	xcall _display
	.dbline 301
	sbi 0x12,7
	.dbline 302
	ldi R24,128
	out 0x1b,R24
	.dbline 303
	ldi R16,6
	ldi R17,0
	xcall _delay_ms
	.dbline 304
	cbi 0x12,7
	.dbline 305
L88:
	.dbline -2
L75:
	adiw R28,4
	xcall pop_gset2
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r temp 20 s
	.dbsym l data 8 D
	.dbend
	.dbfunc e led_error _led_error fV
	.even
_led_error::
	.dbline -1
	.dbline 313
;   display(temp,0); //普通模式显示 1234
;   led_contrl_port |= (1<<7); //选中第一位
;   led_port = 0x80; //点亮对应小数点,这里用等于,否则display函数的显影有残留。
;   delay_ms(6);
;   led_contrl_port &=~ (1<<7);
;   return;
;  }
; }
; 
; /***********************************************
; ** 异常处理,led全亮 8。8。8。8。
; ***********************************************/
; void led_error(void)
; {
	.dbline 315
;  // 以下两句将会使LED全亮,如果立即更改状态,将看不出来效果
;   led_port = 0xFF;
	ldi R24,255
	out 0x1b,R24
	.dbline 316
;   led_contrl_port |= (1<<led_a)|(1<<led_b)|(1<<led_c)|(1<<led_d);
	in R24,0x12
	ori R24,240
	out 0x12,R24
	.dbline -2
L92:
	.dbline 0 ; func end
	ret
	.dbend
	.area lit(rom, con, rel)
L42:
	.word 0x0,0x42c8
L39:
	.word 0x0,0x4700
L38:
	.word 0x0,0x4120
L35:
	.word 0x0,0x3f80
L32:
	.word 0x0,0x0
L29:
	.word 0x0,0x447a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -