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

📄 ps2test.s

📁 ICCAVR下
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module ps2test.c
	.area lit(rom, con, rel)
_unshifted::
	.byte 13,9
	.byte 14,96
	.byte 21,'q
	.byte 22,49
	.byte 26,'z
	.byte 27,'s
	.byte 28,'a
	.byte 29,'w
	.byte 30,50
	.byte 33,'c
	.byte 34,'x
	.byte 35,'d
	.byte 36,'e
	.byte 37,52
	.byte 38,51
	.byte 41,32
	.byte 42,'v
	.byte 43,'f
	.byte 44,'t
	.byte 45,'r
	.byte 46,53
	.byte 49,'n
	.byte 50,'b
	.byte 51,'h
	.byte 52,'g
	.byte 53,'y
	.byte 54,54
	.byte 57,44
	.byte 58,'m
	.byte 59,'j
	.byte 60,'u
	.byte 61,55
	.byte 62,56
	.byte 'A,44
	.byte 'B,'k
	.byte 'C,'i
	.byte 'D,'o
	.byte 'E,48
	.byte 'F,57
	.byte 'I,46
	.byte 'J,47
	.byte 'K,'l
	.byte 'L,59
	.byte 'M,'p
	.byte 'N,45
	.byte 'R,39
	.byte 'T,91
	.byte 'U,61
	.byte 'Z,13
	.byte 91,93
	.byte 93,92
	.byte 'a,60
	.byte 'f,8
	.byte 'i,49
	.byte 'k,52
	.byte 'l,55
	.byte 'p,48
	.byte 'q,44
	.byte 'r,50
	.byte 's,53
	.byte 't,54
	.byte 'u,56
	.byte 'y,43
	.byte 'z,51
	.byte 123,45
	.byte 124,42
	.byte 125,57
	.byte 0,0
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/scancodes.h
	.dbsym e unshifted _unshifted A[136:68:2]kc
_shifted::
	.byte 13,9
	.byte 14,126
	.byte 21,'Q
	.byte 22,33
	.byte 26,'Z
	.byte 27,'S
	.byte 28,'A
	.byte 29,'W
	.byte 30,64
	.byte 33,'C
	.byte 34,'X
	.byte 35,'D
	.byte 36,'E
	.byte 37,36
	.byte 38,35
	.byte 41,32
	.byte 42,'V
	.byte 43,'F
	.byte 44,'T
	.byte 45,'R
	.byte 46,37
	.byte 49,'N
	.byte 50,'B
	.byte 51,'H
	.byte 52,'G
	.byte 53,'Y
	.byte 54,94
	.byte 57,'L
	.byte 58,'M
	.byte 59,'J
	.byte 60,'U
	.byte 61,38
	.byte 62,42
	.byte 'A,60
	.byte 'B,'K
	.byte 'C,'I
	.byte 'D,'O
	.byte 'E,41
	.byte 'F,40
	.byte 'I,62
	.byte 'J,63
	.byte 'K,'L
	.byte 'L,58
	.byte 'M,'P
	.byte 'N,95
	.byte 'R,34
	.byte 'T,123
	.byte 'U,43
	.byte 'Z,13
	.byte 91,125
	.byte 93,124
	.byte 'a,62
	.byte 'f,8
	.byte 'i,49
	.byte 'k,52
	.byte 'l,55
	.byte 'p,48
	.byte 'q,44
	.byte 'r,50
	.byte 's,53
	.byte 't,54
	.byte 'u,56
	.byte 'y,43
	.byte 'z,51
	.byte 123,45
	.byte 124,42
	.byte 125,57
	.byte 0,0
	.dbsym e shifted _shifted A[136:68:2]kc
	.area text(rom, con, rel)
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/scancodes.h
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/delay.h
	.dbfunc e delay_1us _delay_1us fV
	.even
_delay_1us::
	.dbline -1
	.dbline 10
; /* 
;     Title:    icc-avr ps2 test
;     Author:   dushibiao
;     Date:     2007 10 18
;     Purpose:  decode ps2 keyboard code
; 	Frequency: internal 8M
;     Software: icc-avr 
;     Hardware: AVR mega16 BOARD
;     Connect:  dushibiao@126.com
; */
	.dbline 11
; 
	nop
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e delay_nus _delay_nus fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_delay_nus::
	xcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 15
; #include <iom16v.h>
; #include "scancodes.h"
; #include "shumaguan.h"
; 
	.dbline 16
; #define PORT_KB PORTD
	clr R20
	clr R21
	.dbline 17
; #define PIN_KB PIND
	xjmp L6
L3:
	.dbline 18
	xcall _delay_1us
L4:
	.dbline 17
	subi R20,255  ; offset = 1
	sbci R21,255
L6:
	.dbline 17
	cp R20,R22
	cpc R21,R23
	brlo L3
	.dbline -2
L2:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.dbfunc e delay_1ms _delay_1ms fV
;              i -> R16,R17
	.even
_delay_1ms::
	.dbline -1
	.dbline 22
; #define PIN_DIR DDRD
; #define CLOCK 3
; #define DATAPIN 2
; 
; //管脚定义
	.dbline 24
	clr R16
	clr R17
	xjmp L11
L8:
	.dbline 24
L9:
	.dbline 24
	subi R16,255  ; offset = 1
	sbci R17,255
L11:
	.dbline 24
; #define PIN_RXD			0 	//PD0   RXD
; #define PIN_TXD			1 	//PD1   TXD
	cpi R16,116
	ldi R30,4
	cpc R17,R30
	brlo L8
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e delay_nms _delay_nms fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_delay_nms::
	xcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 28
; 
; //常量定义
; #define BAUDRATE        9600	//baudrate
; #define F_CPU			8000000 //the frequency of the global clock
	.dbline 29
; 
	clr R20
	clr R21
	.dbline 30
; 
	xjmp L16
L13:
	.dbline 31
	xcall _delay_1ms
L14:
	.dbline 30
	subi R20,255  ; offset = 1
	sbci R21,255
L16:
	.dbline 30
	cp R20,R22
	cpc R21,R23
	brlo L13
	.dbline -2
L12:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.area lit(rom, con, rel)
_discode::
	.byte 192,249
	.byte 164,176
	.byte 153,146
	.byte 130,248
	.byte 128,144
	.byte 136,131
	.byte 198,161
	.byte 134,142
	.byte 191
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/shumaguan.h
	.dbsym e discode _discode A[17:17]kc
	.area text(rom, con, rel)
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/shumaguan.h
	.dbfunc e display _display fV
;            num -> R20
	.even
_display::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 21
	.dbline 22
	cbi 0x18,0
	.dbline 24
	ldi R24,<_discode
	ldi R25,>_discode
	mov R30,R20
	clr R31
	asr R31
	ror R30
	asr R31
	ror R30
	asr R31
	ror R30
	asr R31
	ror R30
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x1b,R30
	.dbline 25
	ldi R16,5
	ldi R17,0
	xcall _delay_nms
	.dbline 26
	sbi 0x18,0
	.dbline 28
	cbi 0x18,1
	.dbline 29
	ldi R18,16
	ldi R19,0
	mov R16,R20
	clr R17
	xcall mod16s
	movw R30,R16
	ldi R24,<_discode
	ldi R25,>_discode
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x1b,R30
	.dbline 30
	ldi R16,5
	ldi R17,0
	xcall _delay_nms
	.dbline 31
; unsigned char bitcount; 
	sbi 0x18,1
	.dbline -2
L17:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r num 20 c
	.dbend
	.dbfunc e displayerror _displayerror fV
	.even
_displayerror::
	.dbline -1
	.dbline 38
; 
; volatile unsigned char origialcode=0;
; 
; void intinitial(void);
; void portinitial(void); //initialize ports
; void init_USART(void);
; unsigned char decode(unsigned char sc);
	.dbline 39
; 
	cbi 0x18,0
	.dbline 41
; /*-----------------------------------------------------------------
; function: send a char to the uart
	ldi R30,<_discode+16
	ldi R31,>_discode+16
	lpm R30,Z
	out 0x1b,R30
	.dbline 42
; para:    the char to be send
	ldi R16,5
	ldi R17,0
	xcall _delay_nms
	.dbline 43
; -----------------------------------------------------------------*/
	sbi 0x18,0
	.dbline 45
; void put_c(unsigned char c) //发送采用查询方式
; {
	cbi 0x18,1
	.dbline 46
; 	while( !(UCSRA & (1<<UDRE)) );        //wait until the uart is empty
	ldi R30,<_discode+16
	ldi R31,>_discode+16
	lpm R30,Z
	out 0x1b,R30
	.dbline 47
; 	UDR=c;                                  //write data to uart
	ldi R16,5
	ldi R17,0
	xcall _delay_nms
	.dbline 48
; }
	sbi 0x18,1
	.dbline -2
L18:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/shumaguan.h
_origialcode::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test/shumaguan.h
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test\ps2test.c
	.dbsym e origialcode _origialcode c
	.area text(rom, con, rel)
	.dbfile D:\M16开发板实验教程\icc-avr\ps2test\ps2test.c
	.dbfunc e put_c _put_c fV
;              c -> R16
	.even
_put_c::
	.dbline -1
	.dbline 45
L22:
	.dbline 46
L23:
	.dbline 46
	sbis 0xb,5
	rjmp L22
	.dbline 47
	out 0xc,R16
	.dbline -2
L21:
	.dbline 0 ; func end
	ret
	.dbsym r c 16 c
	.dbend
	.dbfunc e put_s _put_s fV
;            ptr -> R20,R21
	.even
_put_s::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 54
; /*-----------------------------------------------------------------
; function: send a string to the uart
; para:     ptr---the pointer point to the string
; ------------------------------------------------------------------*/
; void put_s(unsigned char *ptr)
; {
	xjmp L27
L26:
	.dbline 56
	.dbline 57
	movw R30,R20
	ld R16,Z+
	movw R20,R30
	xcall _put_c
	.dbline 58
L27:
	.dbline 55
; 	while (*ptr)
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L26
	.dbline 59
; 	{
; 		put_c(*ptr++);
; 	}
; 	put_c(0x0D); 
	ldi R16,13
	xcall _put_c
	.dbline 60
; 	put_c(0x0A);  //结尾发送回车换行
	ldi R16,10
	xcall _put_c
	.dbline -2
L25:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r ptr 20 pc
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 64
; }
; 
; void  main(void)
; {
	.dbline 65
;       portinitial();
	xcall _portinitial
	.dbline 66
;  	  intinitial();
	xcall _intinitial
	.dbline 67
; 	  init_USART();
	xcall _init_USART
	.dbline 70
; 	  
; 
;       put_s("PS2--KEYOARD test");
	ldi R16,<L30
	ldi R17,>L30
	xcall _put_s
	.dbline 71
;       put_s("dushibiao");
	ldi R16,<L31
	ldi R17,>L31
	xcall _put_s
	.dbline 72
;       put_s("dushibiao@126.com");
	ldi R16,<L32
	ldi R17,>L32
	xcall _put_s
	.dbline 73
;       put_c(0x0a);
	ldi R16,10
	xcall _put_c
	.dbline 74
;       put_c(0x0d);//换行 
	ldi R16,13
	xcall _put_c
	.dbline 76
; 
; 	  SEI();            //enable interrupt ,this was predefined in MACROS.h
	sei
	xjmp L34
L33:
	.dbline 79
	.dbline 80
	lds R16,_origialcode
	xcall _display
	.dbline 81
L34:
	.dbline 78
	xjmp L33
X0:
	.dbline -2
L29:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e portinitial _portinitial fV
	.even
_portinitial::
	.dbline -1
	.dbline 88
; 	 
; 	while(1)
;     {
; 		display(origialcode);
; 	}
; 	  
; }
; /*********************************************************************
; fuction: ports initialize

⌨️ 快捷键说明

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