?? slavr743.lst
字號:
.equ SPE =6
.equ DORD =5
.equ MSTR =4
.equ CPOL =3
.equ CPHA =2
.equ SPR1 =1
.equ SPR0 =0
.equ SPIF =7
.equ WCOL =6
.equ RXC =7
.equ TXC =6
.equ UDRE =5
.equ FE =4
.equ OR =3
.equ RXCIE =7
.equ TXCIE =6
.equ UDRIE =5
.equ RXEN =4
.equ TXEN =3
.equ CHR9 =2
.equ RXB8 =1
.equ TXB8 =0
.equ ACD =7
.equ ACO =5
.equ ACI =4
.equ ACIE =3
.equ ACIC =2
.equ ACIS1 =1
.equ ACIS0 =0
.def XL =r26
.def XH =r27
.def YL =r28
.def YH =r29
.def ZL =r30
.def ZH =r31
.equ RAMEND =$25F ;Last On-Chip SRAM Location
.equ XRAMEND =$FFFF
.equ E2END =$1FF
.equ FLASHEND=$FFF
.equ INT0addr=$001 ;External Interrupt0 Vector Address
.equ INT1addr=$002 ;External Interrupt1 Vector Address
.equ ICP1addr=$003 ;Input Capture1 Interrupt Vector Address
.equ OC1Aaddr=$004 ;Output Compare1A Interrupt Vector Address
.equ OC1Baddr=$005 ;Output Compare1B Interrupt Vector Address
.equ OVF1addr=$006 ;Overflow1 Interrupt Vector Address
.equ OVF0addr=$007 ;Overflow0 Interrupt Vector Address
.equ SPIaddr =$008 ;SPI Interrupt Vector Address
.equ URXCaddr=$009 ;UART Receive Complete Interrupt Vector Address
.equ UDREaddr=$00a ;UART Data Register Empty Interrupt Vector Address
.equ UTXCaddr=$00b ;UART Transmit Complete Interrupt Vector Address
.equ ACIaddr =$00c ;Analog Comparator Interrupt Vector Address
000000 c024 rjmp reset
.def temp = r16 ;暫存器
.def cnt1d = r17
.def cnt2d = r18 ;cnt1、dcnt2d和cnt3d存放結果的十進制
.def cnt3d = r19
.def count = r20
.def res1 = r21
.def res2 = r22 ;res1、res2和res3存放結果的十六進制
.def res3 = r23
.def dt = r25
.def aa = r26
.def bb = r27
.def cc = r28
.org 0x003 ;icp觸發中斷向量
000003 c004 rjmp captr
.org 0x007 ;timer0觸發中斷向量
000007 c010 rjmp interru
captr: ;icp觸發中斷子程序
000008 f046 brts cap2
cap1:
000009 e002 ldi temp, 0b00000010
00000a bf03 out tccr0, temp ;開timer0
00000b e00a ldi temp, 0b00001010
00000c bf09 out timsk, temp
00000d ec00 ldi temp, 0b11000000 ;致timer0中斷和捕捉中斷
00000e bd0e out tccr1b,temp
00000f 9468 set
000010 9518 reti
cap2:
000011 e000 ldi temp, 00
000012 bf03 out tccr0, temp
000013 b752 in res1, tcnt0
000014 d052 rcall htd3
over:
000015 d080 rcall clrm1
000016 d045 rcall sys
000017 9518 reti
interru: ;timer0溢出中斷子程序
000018 9488 clc
000019 9563 inc res2
00001a f421 brne b
00001b 9573 inc res3
00001c 307f cpi res3, 15 ;溢出處理
00001d f008 brlo b
00001e cff6 rjmp over
b:
00001f 9488 clc
000020 e00a ldi temp, 0b00001010
000021 bf09 out timsk, temp
000022 ec00 ldi temp, 0b11000000
000023 bd0e out tccr1b,temp
000024 9518 reti
reset:
000025 e50f ldi temp, low(ramend)
000026 bf0d out spl, temp
000027 e002 ldi temp, high(ramend) ;設置堆棧
000028 bf0e out spl+1, temp
000029 ef0f ldi temp, $ff ;初始化數碼管狀態
00002a bb07 out ddrb, temp ;B口:數碼管數據輸出
00002b bb01 out ddrd, temp ;D口:pd0-pd5為數碼管片選
00002c e000 ldi temp, $00
00002d bb08 out portb, temp ;共陰極,數碼管全滅
00002e bb02 out portd, temp
00002f d063 rcall clrm
000030 9478 sei
000031 d02a rcall sys
loop: ;在數碼管顯出十進制數
000032 2fa1 mov aa, cnt1d
000033 70af andi aa, $0f ;顯示個位
000034 d043 rcall a
000035 9890 cbi portd, 00
000036 0000 nop
000037 9a90 sbi portd, 00
000038 2fa1 mov aa, cnt1d
000039 7fa0 andi aa, $f0 ;顯示十位
00003a 95a2 swap aa
00003b d03c rcall a
00003c 9891 cbi portd, 01
00003d 0000 nop
00003e 9a91 sbi portd, 01
00003f 2fa2 mov aa, cnt2d
000040 70af andi aa, $0f ;顯示百位
000041 d036 rcall a
000042 9892 cbi portd, 02
000043 0000 nop
000044 9a92 sbi portd, 02
000045 2fa2 mov aa, cnt2d
000046 7fa0 andi aa, $f0 ;顯示千位
000047 95a2 swap aa
000048 d02f rcall a
000049 9893 cbi portd, 03
00004a 0000 nop
00004b 9a93 sbi portd, 03
00004c 2fa3 mov aa, cnt3d
00004d 70af andi aa, $0f ;顯示萬位
00004e d029 rcall a
00004f 9894 cbi portd, 04
000050 0000 nop
000051 9a94 sbi portd, 04
000052 2fa3 mov aa, cnt3d
000053 7fa0 andi aa, $f0 ;顯示十萬位
000054 95a2 swap aa
000055 d022 rcall a
000056 9895 cbi portd, 05
000057 0000 nop
000058 9a95 sbi portd, 05
000059 fd90 sbrc dt, 0
00005a 9508 ret
00005b cfd6 rjmp loop
sys: ;初始化
00005c 94e8 clt
00005d 9488 clc
00005e e0bf ldi bb, $0f
00005f e090 ldi dt, 00
000060 e000 ldi temp, 00
000061 bf02 out tcnt0, temp
000062 e008 ldi temp, 0b00001000
000063 bf09 out timsk, temp
000064 ec00 ldi temp, 0b11000000
000065 bd0e out tccr1b,temp
000066 9508 ret
htd3: ;16轉10子程序
000067 6091 sbr dt, 1
000068 e148 ldi count, 24
000069 2711 clr cnt1d
00006a 2722 clr cnt2d
00006b 2733 clr cnt3d
00006c 9488 clc
loopd:
00006d 1f55 rol res1
00006e 1f66 rol res2
00006f 1f77 rol res3
000070 1f11 rol cnt1d
000071 1f22 rol cnt2d
000072 1f33 rol cnt3d
000073 954a dec count
000074 f409 brne c
000075 cfbc rjmp loop
000076 d007 c: rcall adjn
000077 cff5 rjmp loopd
a:
000078 e0f4 ldi zh, high(zk*2)
000079 e0e0 ldi zl, low(zk*2)
00007a 0fea add zl, aa
00007b 95c8 lpm
00007c ba08 out portb, r0
00007d 9508 ret
adjn:
00007e 934f push count
00007f 2f41 mov count, cnt1d
000080 d009 rcall adjd1
000081 2f14 mov cnt1d, count
000082 2f42 mov count, cnt2d
000083 d006 rcall adjd1
000084 2f24 mov cnt2d, count
000085 2f43 mov count, cnt3d
000086 d003 rcall adjd1
000087 2f34 mov cnt3d, count
000088 914f pop count
000089 9508 ret
adjd1:
00008a e003 ldi temp, 3
00008b 0f04 add temp, count
00008c fd03 sbrc temp, 3
00008d 2f40 mov count, temp
00008e e300 ldi temp, $30
00008f 0f04 add temp, count
000090 fd07 sbrc temp, 7
000091 2f40 mov count, temp
000092 9508 ret
clrm:
000093 2711 clr cnt1d
000094 2722 clr cnt2d
000095 2733 clr cnt3d
clrm1:
000096 2755 clr res1
000097 2766 clr res2
000098 2777 clr res3
000099 9508 ret
.equ zk=0x0200
.org zk ;字形表
.db 0x03f,0x006,0x05b,0x04f
000200 063f
000201 4f5b
.db 0x066,0x06d,0x07d,0x007
000202 6d66
000203 077d
.db 0x07f,0x06f,0x077,0x07c
000204 6f7f
000205 7c77
.db 0x039,0x05e,0x071,0x0ff
000206 5e39
000207 ff71
Assembly complete with no errors.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -