📄 pd.s
字号:
.module pd.c
.area text(rom, con, rel)
.dbfile f:\MYDOCU~1\AVR\test\pd.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 9
; //ICC-AVR application builder : 2008-08-28 8:30:08
; // Target : M8
; // Crystal: 8.0000Mhz
;
; #include <iom8v.h>
; #include <macros.h>
;
; void port_init(void)
; {
.dbline 10
; PORTB = 0x00;
clr R2
out 0x18,R2
.dbline 11
; DDRB = 0xFF;
ldi R24,255
out 0x17,R24
.dbline 12
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 13
; DDRC = 0x00;
out 0x14,R2
.dbline 14
; PORTD = 0xFF;
out 0x12,R24
.dbline 15
; DDRD = 0x0F;
ldi R24,15
out 0x11,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 20
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 23
;
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 24
; port_init();
rcall _port_init
.dbline 26
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 27
; GICR = 0x00;
out 0x3b,R2
.dbline 28
; TIMSK = 0x00; //timer interrupt sources
out 0x39,R2
.dbline 29
; SEI(); //re-enable interrupts
sei
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
; a -> R20
.even
_main::
.dbline -1
.dbline 34
; //all peripherals are now initialized
; }
;
; void main()
; { char a;
.dbline 35
; init_devices();
rcall _init_devices
rjmp L5
L4:
.dbline 37
; while(1)
; { PORTD |= 0xF0;
.dbline 37
in R24,0x12
ori R24,240
out 0x12,R24
.dbline 38
; a = (PIND & 0xF0);
in R20,0x10
andi R20,240
.dbline 39
; a = (a >> 4);
mov R24,R20
swap R24
andi R24,#0x0F
mov R20,R24
.dbline 40
; PORTB = PIND;
in R2,0x10
out 0x18,R2
.dbline 41
; PORTD = (a | 0xF0);
ori R24,240
out 0x12,R24
.dbline 42
; }
L5:
.dbline 36
rjmp L4
X0:
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbsym r a 20 c
.dbend
; }
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -