单片机开发资料光盘-双龙-686M.zip

源代码在线查看: kb.s

软件大小: 574027 K
上传用户: rllfllef
关键词: 686 zip 单片机 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module kb.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 C:\work\mega128\mix_exp/scancodes.h
					.dbsym e unshifted _unshifted A[136:68:2]c
				_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]c
				_ascii::
					.word 48
					.word 49
					.word 50
					.word 51
					.word 52
					.word 53
					.word 54
					.word 55
					.word 56
					.word 57
					.word 65
					.word 66
					.word 67
					.word 68
					.word 69
					.word 70
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbsym e ascii _ascii A[32:16]I
					.area data(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
				_input::
					.blkb 1
					.area idata
					.byte 0
					.area data(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbsym e input _input c
				_output::
					.blkb 1
					.area idata
					.byte 0
					.area data(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbsym e output _output c
					.area text(rom, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbfunc e put_kbbuff _put_kbbuff fV
				;              c -> R16
					.even
				_put_kbbuff::
					.dbline -1
					.dbline 18
				; #include 
				; #include "pindefs.h"
				; #include "scancodes.h"
				; #define BUFF_SIZE 64
				; extern void delay_ms(unsigned int time);
				; const ascii[16]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
				;                  0x39,0x41,0x42,0x43,0x44,0x45,0x46};
				; unsigned char bitcount;  
				; unsigned char kb_buffer[BUFF_SIZE];
				; unsigned char input=0;
				; unsigned char output=0;
				; extern void cls(unsigned x,unsigned y,unsigned char high,unsigned char width);
				; extern void asc_tran(unsigned char x,unsigned char y,unsigned char *asc_p);
				; extern void ocmj_write(unsigned char data);
				; extern void hz_tran(unsigned char x,unsigned char y,unsigned char *hz_p);
				; extern void delay_ms(unsigned int n);
				; void put_kbbuff(unsigned char c)
				;  {
					.dbline 19
				;   kb_buffer[input]=c;
					ldi R24,					ldi R25,>_kb_buffer
					lds R30,_input
					clr R31
					add R30,R24
					adc R31,R25
					std z+0,R16
					.dbline 20
				;   if (input					lds R24,_input
					cpi R24,63
					brsh L2
					.dbline 21
				;      input++; 
					subi R24,255    ; addi 1
					sts _input,R24
					xjmp L3
				L2:
					.dbline 23
					clr R2
					sts _input,R2
				L3:
					.dbline -2
					.dbline 24
				;   else
				;      input=0;	 
				;  }
				L1:
					.dbline 0 ; func end
					ret
					.dbsym r c 16 c
					.dbend
					.dbfunc e getchar _getchar fc
				;           temp -> R16
					.even
				_getchar::
					.dbline -1
					.dbline 26
				; unsigned char getchar(void)
				;   {
					.dbline 28
				;    unsigned char temp;
				;    if(output==input)
					lds R2,_input
					lds R3,_output
					cp R3,R2
					brne L5
					.dbline 29
				;        return 0;
					clr R16
					xjmp L4
				L5:
					.dbline 31
				;    else
				;       {
					.dbline 32
				; 	   temp=kb_buffer[output];
					ldi R24,					ldi R25,>_kb_buffer
					lds R30,_output
					clr R31
					add R30,R24
					adc R31,R25
					ldd R16,z+0
					.dbline 33
				; 	   if(output					lds R24,_output
					cpi R24,63
					brsh L7
					.dbline 34
				; 	     {
					.dbline 35
				; 		  output++;
					subi R24,255    ; addi 1
					sts _output,R24
					.dbline 36
				; 		 }
					xjmp L8
				L7:
					.dbline 38
				; 	   else
				; 	     output=0;
					clr R2
					sts _output,R2
				L8:
					.dbline 39
				; 	   return temp;	  
					.dbline -2
				L4:
					.dbline 0 ; func end
					ret
					.dbsym r temp 16 c
					.dbend
					.dbfunc e init_kb _init_kb fV
					.even
				_init_kb::
					.dbline -1
					.dbline 43
				; 	  }	     
				;   }
				; void init_kb(void)
				;     {
					.dbline 44
				; 	EICRB=0x02; 
					ldi R24,2
					out 0x3a,R24
					.dbline 45
				;     bitcount = 11;
					ldi R24,11
					sts _bitcount,R24
					.dbline -2
					.dbline 46
				;     }
				L9:
					.dbline 0 ; func end
					ret
					.dbend
					.area bss(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
				L11:
					.blkb 1
				L12:
					.blkb 1
				L13:
					.blkb 1
					.area text(rom, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbfunc e decode _decode fV
					.dbsym s shiftup L13 c
					.dbsym s up L12 c
					.dbsym s shift L11 c
				;              i -> R20
				;             sc -> R22
					.even
				_decode::
					xcall push_gset3
					mov R22,R16
					sbiw R28,2
					.dbline -1
					.dbline 48
				; void decode(unsigned char sc)
				;     {
					.dbline 51
				;       static unsigned char shift,up,shiftup;
				; 	  unsigned char i;
				; 	  if (sc==0xf0)
					cpi R22,240
					brne L14
					.dbline 52
				; 	      {
					.dbline 53
				; 		   up=1;
					ldi R24,1
					sts L12,R24
					.dbline 54
				; 		   return;
					xjmp L10
				L14:
					.dbline 56
				; 		  }
				; 	  if (up==1)
					lds R24,L12
					cpi R24,1
					brne L16
					.dbline 57
				; 	  	  {
					.dbline 58
				; 		   up=0;
					clr R2
					sts L12,R2
					.dbline 59
				; 		   if ((sc==0x12)|(sc==0x59)) shift=0;
					cpi R22,18
					brne L20
					ldi R24,1
					ldi R25,0
					movw R10,R24
					xjmp L21
				L20:
					clr R10
					clr R11
				L21:
					cpi R22,89
					brne L22
					ldi R20,1
					ldi R21,0
					xjmp L23
				L22:
					clr R20
					clr R21
				L23:
					movw R2,R10
					or R2,R20
					or R3,R21
					tst R2
					brne X0
					tst R3
					brne X3
					xjmp L10
				X3:
				X0:
					.dbline 59
					clr R2
					sts L11,R2
					.dbline 60
				; 		   return;
					xjmp L10
				L16:
					.dbline 62
				; 		  }
				; 	  if(sc==0x71)
					cpi R22,113
					brne L24
					.dbline 63
				; 	     {
					.dbline 64
				; 		  ocmj_write(0xf4);
					ldi R16,244
					xcall _ocmj_write
					.dbline 65
				; 		  hz_tran(1,1,"将要重新启动");
					ldi R24,					ldi R25,>L26
					std y+0,R24
					std y+1,R25
					ldi R18,1
					ldi R16,1
					xcall _hz_tran
					.dbline 66
				; 		  asm("wdr");
					wdr
					.dbline 67
				;           WDTCR=(1					ldi R24,24
					out 0x21,R24
					.dbline 68
				; 		  WDTCR|=(1					in R24,0x21
					ori R24,7
					out 0x21,R24
				L27:
					.dbline 70
				L28:
					.dbline 69
				; 		  while(1)
					xjmp L27
				X1:
					.dbline 72
				; 		  ;
				; 		  //delay_ms(3000);
				; 		 }	 	   
				L24:
					.dbline 73
				; 	  switch (sc)
					mov R20,R22
					clr R21
					cpi R20,18
					ldi R30,0
					cpc R21,R30
					breq L33
					cpi R20,18
					ldi R30,0
					cpc R21,R30
					brlt L30
				L53:
					cpi R20,89
					ldi R30,0
					cpc R21,R30
					breq L34
					xjmp L30
				X2:
					.dbline 74
				; 	    {
				L33:
					.dbline 75
				; 		 case 0x12:{
					.dbline 76
				; 					shift=1;		
					ldi R24,1
					sts L11,R24
					.dbline 77
				; 					shiftup=1;
					sts L13,R24
					.dbline 78
				; 		           }		           
				L34:
					.dbline 79
				; 		 case 0x59:{
					.dbline 80
				; 				    shift=1;	
					ldi R24,1
					sts L11,R24
					.dbline 81
				; 					shiftup=1;
					sts L13,R24
					.dbline 82
				; 		           }		           
				L30:
					.dbline 83
				; 		 default:{
					.dbline 84
				; 		          if (shift==0)
					lds R2,L11
					tst R2
					brne L35
					.dbline 85
				; 					 {
					.dbline 86
					clr R20
					xjmp L40
				L37:
					.dbline 86
				L38:
					.dbline 86
					inc R20
				L40:
					.dbline 86
				; 					 for(i = 0;unshifted[i][0]!=sc && unshifted[i][0]; i++);
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_unshifted
					add R30,R24
					adc R31,R25
					lpm R2,Z
					clr R3
					cp R2,R22
					breq L41
					tst R2
					brne L37
				L41:
					.dbline 87
				;                      if (unshifted[i][0] == sc)
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_unshifted
					add R30,R24
					adc R31,R25
					lpm R30,Z
					cp R30,R22
					breq X4
					xjmp L36
				X4:
					.dbline 88
				; 						  put_kbbuff(unshifted[i][1]);	 
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_unshifted+1
					add R30,R24
					adc R31,R25
					lpm R16,Z
					xcall _put_kbbuff
					.dbline 89
				; 					 }
					xjmp L36
				L35:
					.dbline 91
				; 				  else
				; 				     {
					.dbline 92
					clr R20
					xjmp L48
				L45:
					.dbline 92
				L46:
					.dbline 92
					inc R20
				L48:
					.dbline 92
				; 					 for(i = 0;shifted[i][0]!=sc && shifted[i][0]; i++);
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_shifted
					add R30,R24
					adc R31,R25
					lpm R2,Z
					clr R3
					cp R2,R22
					breq L49
					tst R2
					brne L45
				L49:
					.dbline 93
				;                      if (shifted[i][0] == sc)
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_shifted
					add R30,R24
					adc R31,R25
					lpm R30,Z
					cp R30,R22
					brne L50
					.dbline 94
				;                          {
					.dbline 95
				; 						  put_kbbuff(shifted[i][1]);						  
					ldi R24,2
					mul R24,R20
					movw R30,R0
					ldi R24,					ldi R25,>_shifted+1
					add R30,R24
					adc R31,R25
					lpm R16,Z
					xcall _put_kbbuff
					.dbline 96
				; 						 }	 	 						 
				L50:
					.dbline 97
				; 					 } 
				L36:
					.dbline 98
				; 		         }		         
					.dbline 99
				; 		} 
					.dbline -2
					.dbline 105
				; 		/*debug
				; 	 kb_buffer[1]=ascii[sc%16];
				; 	 sc=sc/16;
				; 	 kb_buffer[0]=ascii[sc%16];
				; 	    debug*/	
				;     }
				L10:
					adiw R28,2
					xcall pop_gset3
					.dbline 0 ; func end
					ret
					.dbsym r i 20 c
					.dbsym r sc 22 c
					.dbend
					.area vector(rom, abs)
					.org 20
					jmp _int4_isr
					.area text(rom, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.area bss(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
				L55:
					.blkb 1
					.area text(rom, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
					.dbfunc e int4_isr _int4_isr fV
					.dbsym s data L55 c
					.even
				_int4_isr::
					xcall push_lset
					xcall push_gset1
					.dbline -1
					.dbline 108
				; #pragma interrupt_handler int4_isr:6
				; void int4_isr(void)
				;    {
					.dbline 121
				;     static unsigned char data;   
				; 	/*if((bitcount < 11)&(bitcount > 2))
				;        {
				; 	    data = (data >> 1);
				;         if((PINE&0x20)!=0)
				;            data|=0x80;
				; 	   }   
				;     if (--bitcount==0)
				; 	     {
				; 		  bitcount=11;
				; 		  decode(data);
				; 		 }*/
				;     switch (bitcount)
					lds R20,_bitcount
					clr R21
					cpi R20,1
					ldi R30,0
					cpc R21,R30
					breq L63
					cpi R20,2
					ldi R30,0
					cpc R21,R30
					breq L62
					cpi R20,1
					ldi R30,0
					cpc R21,R30
					brlt L56
				L68:
					cpi R20,11
					ldi R30,0
					cpc R21,R30
					breq L59
					xjmp L56
				X5:
					.dbline 122
				; 	  {
				L59:
					.dbline 123
				; 	   case 11:{
					.dbline 124
				; 	            if ((PINE&0x20)!=0)
					sbis 0x1,5
					rjmp L60
					.dbline 125
				; 				     return;
					xjmp L54
				L60:
					.dbline 127
				; 			    else		 
				; 	   			    bitcount--;
					lds R24,_bitcount
					subi R24,1
					sts _bitcount,R24
					.dbline 128
				; 	    		break;}
					xjmp L57
				L62:
					.dbline 129
				; 	   case 2:{
					.dbline 130
				; 	   			bitcount--;	   		   
					lds R24,_bitcount
					subi R24,1
					sts _bitcount,R24
					.dbline 131
				; 			    break;}
					xjmp L57
				L63:
					.dbline 132
				; 	   case 1:{
					.dbline 133
				; 	   			bitcount--;	 
					lds R24,_bitcount
					subi R24,1
					sts _bitcount,R24
					.dbline 134
				; 				if ((PINE&0x20)==0)
					sbic 0x1,5
					rjmp L64
					.dbline 135
				; 				    {
					.dbline 136
				; 					 bitcount=11;
					ldi R24,11
					sts _bitcount,R24
					.dbline 137
				; 					 return;
					xjmp L54
				L64:
					.dbline 140
				; 					}
				; 				else
				; 				   {
					.dbline 141
				; 				    bitcount=11;
					ldi R24,11
					sts _bitcount,R24
					.dbline 142
				; 		            decode(data);
					lds R16,L55
					xcall _decode
					.dbline 143
				; 				   }	  
					.dbline 144
				; 	   	        break;}
					xjmp L57
				L56:
					.dbline 145
				; 	   default:{
					.dbline 146
				; 	   	        data = (data >> 1);
					lds R2,L55
					lsr R2
					sts L55,R2
					.dbline 147
				;                 if((PINE&0x20)!=0)
					sbis 0x1,5
					rjmp L66
					.dbline 148
				;                     data|=0x80;
					mov R24,R2
					ori R24,128
					sts L55,R24
				L66:
					.dbline 149
					lds R24,_bitcount
					subi R24,1
					sts _bitcount,R24
					.dbline 150
					.dbline 151
				L57:
					.dbline -2
					.dbline 152
				; 				bitcount--;
				; 	            }		
				; 	  }		 		 	  	
				;     } 
				L54:
					xcall pop_gset1
					xcall pop_lset
					.dbline 0 ; func end
					reti
					.dbend
					.area bss(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
				_kb_buffer::
					.blkb 64
					.dbsym e kb_buffer _kb_buffer A[64:64]c
				_bitcount::
					.blkb 1
					.dbsym e bitcount _bitcount c
					.area data(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
				L26:
					.blkb 13
					.area idata
					.byte 189,171,210,170,214,216,208,194,198,244,182,175,0
					.area data(ram, con, rel)
					.dbfile C:\work\mega128\mix_exp\kb.c
							

相关资源