📄 dip20~1.lst
字号:
AVRASM ver. 1.30 DIP20~1.ASM Tue Jan 01 21:06:18 2002
;************* 应用笔记 DIP20.asm ************************
;*
;* 标题: 测试DIP20 AVR单片机B口、D口功能
;* 版本: 1.0
;*最后更新日期: 2000.08.08
;*
;* 支援 E-mail: gzsl@sl.com.cn
;*
;* 描述
;* 测试DIP20 AVR单片机B口、D口功能,LED逐位移位,移位速度会变化
;* 作者: SL.
;*程序适用于所有单片机
;***************************************************************************
; AT90S1200引脚图 "*"表示引脚接LED发光二极管
; "↓"表示灯亮移位方向
; /RST 。1 20 。VCC
; PD0 ↑* 。 。* ↓ PB7
; PD1 ↑* 。 。* ↓ PB6
; XTAL2 。 。* ↓ PB5
; XTAL1 。 。* ↓ PB4
; PD2 ↑* 。 。* ↓ PB3
; PD3 ↑* 。 。* ↓ PB2
; PD4 ↑* 。 。* ↓ PB1
; PD5 ↑* 。 。* ↓ PB0
; GND 。10 11 。* ↓ PD6
;
.include "1200def.inc"
;***************************************************************************
;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y
;*
;* Number :AVR000
;* File Name :"1200def.inc"
;* Title :Register/Bit Definitions for the AT90S1200
;* Date :99.01.28
;* Version :1.30
;* Support telephone :+47 72 88 43 88 (ATMEL Norway)
;* Support fax :+47 72 88 43 99 (ATMEL Norway)
;* Support E-Mail :avr@atmel.com
;* Target MCU :AT90S1200
;*
;* DESCRIPTION
;* When including this file in the assembly program file, all I/O register
;* names and I/O register bit names appearing in the data book can be used.
;*
;* The Register names are represented by their hexadecimal addresses.
;*
;* The Register Bit names are represented by their bit number (0-7).
;*
;* Please observe the difference in using the bit names with instructions
;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc"
;* (skip if bit in register set/cleared). The following example illustrates
;* this:
;*
;* in r16,PORTB ;read PORTB latch
;* sbr r16,(1<<PB6)+(1<<PB5) ;set PB6 and PB5 (use masks, not bit#)
;* out PORTB,r16 ;output to PORTB
;*
;* in r16,TIFR ;read the Timer Interrupt Flag Register
;* sbrc r16,TOV0 ;test the overflow flag (use bit#)
;* rjmp TOV0_is_set ;jump if set
;* ... ;otherwise do something else
;***************************************************************************
;***** Specify Device
.device AT90S1200
;***** I/O Register Definitions
.equ SREG =$3f
.equ GIMSK =$3b
.equ TIMSK =$39
.equ TIFR =$38
.equ MCUCR =$35
.equ TCCR0 =$33
.equ TCNT0 =$32
.equ WDTCR =$21
.equ EEAR =$1e
.equ EEDR =$1d
.equ EECR =$1c
.equ PORTB =$18
.equ DDRB =$17
.equ PINB =$16
.equ PORTD =$12
.equ DDRD =$11
.equ PIND =$10
.equ ACSR =$08
;***** Bit Definitions
.equ INT0 =6
.equ TOIE0 =1
.equ TOV0 =1
.equ SE =5
.equ SM =4
.equ ISC01 =1
.equ ISC00 =0
.equ CS02 =2
.equ CS01 =1
.equ CS00 =0
.equ WDE =3
.equ WDP2 =2
.equ WDP1 =1
.equ WDP0 =0
.equ EEWE =1
.equ EERE =0
.equ PB7 =7
.equ PB6 =6
.equ PB5 =5
.equ PB4 =4
.equ PB3 =3
.equ PB2 =2
.equ PB1 =1
.equ PB0 =0
.equ DDB7 =7
.equ DDB6 =6
.equ DDB5 =5
.equ DDB4 =4
.equ DDB3 =3
.equ DDB2 =2
.equ DDB1 =1
.equ DDB0 =0
.equ PINB7 =7
.equ PINB6 =6
.equ PINB5 =5
.equ PINB4 =4
.equ PINB3 =3
.equ PINB2 =2
.equ PINB1 =1
.equ PINB0 =0
.equ PD6 =6
.equ PD5 =5
.equ PD4 =4
.equ PD3 =3
.equ PD2 =2
.equ PD1 =1
.equ PD0 =0
.equ DDD6 =6
.equ DDD5 =5
.equ DDD4 =4
.equ DDD3 =3
.equ DDD2 =2
.equ DDD1 =1
.equ DDD0 =0
.equ PIND6 =6
.equ PIND5 =5
.equ PIND4 =4
.equ PIND3 =3
.equ PIND2 =2
.equ PIND1 =1
.equ PIND0 =0
.equ ACD =7
.equ ACO =5
.equ ACI =4
.equ ACIE =3
.equ ACIS1 =1
.equ ACIS0 =0
.equ XRAMEND =0
.equ E2END =3F
.equ FLASHEND=1FF
.equ INT0addr=$001 ;External Interrupt0 Vector Address
.equ OVF0addr=$002 ;Overflow0 Interrupt Vector Address
.equ ACIaddr =$003 ;Analog Comparator Interrupt Vector Address
.def ZL =r30
000000 c004 rjmp RESET ;Reset Handle
.org $005
RESET:
000005 ef0f LDI r16,0XFF ;设B口、D口为输出
000006 bb07 OUT ddrb,R16 ;设b口方向寄存器为输出
000007 bb01 OUT DDRD,R16 ;设D口方向寄存器为输出
000008 bb02 out portd,r16 ;关D口LED,OK-AVR实验器硬件设定高电平LED灯灭
000009 bb08 out portb,r16 ;关B口LED,OK-AVR实验器硬件设定高电平LED灯灭
00000a e018 start: ldi R17,0x08 ;循环次数
00000b e72f ldi r18,0x7f ;0b0111 1111,OK-AVR实验器硬件设定低电平LED灯亮
00000c bb28 loop: out portb,r18 ;B口.7位 LED灯亮
00000d 9408 sec ;c=1
00000e 9527 ror r18 ;通过进位右循环
00000f d009 rcall delay ;调用延时子程序
000010 951a dec r17 ;-1
000011 f7d1 brne loop ;检测R17循环不0为转移,为0按顺序执行
000012 bb08 out portb,r16 ;关B口
000013 eb2f ldi r18,0xbf ; 0b1011 1111
000014 bb22 out portd,r18 ;D口.6位 LED灯亮
000015 d003 rcall delay ;延时
000016 ef2f ldi r18,0xff
000017 bb22 out portd,r18 ;关D口
000018 cff1 rjmp start ;循环
000019 e0da delay: ldi r29,0x0a ;延时子程序
00001a 95ea delay1: dec r30 ;复位后R30=0X00
00001b f7f1 brne delay1 ;R30不为0转,为0按顺序执行
00001c 95fa dec r31 ;复位后R31=0X00
00001d f7e1 brne delay1 ;R30不为0转,为0按顺序执行
00001e 95da dec r29 ;复位后R29=0X00
00001f f7d1 brne delay1 ;R29不为0转,为0按顺序执行
000020 9508 ret ;子程序返回
Assembly complete with no errors.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -