首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

關於汇编语言的問題解决办法

2012-02-24 
關於汇编语言的問題這個是案鍵的編程式但我有些部分看不懂麻煩大大幫幫忙幫我解釋一下謝謝#includeavr/io

關於汇编语言的問題
這個是案鍵的編程式
但我有些部分看不懂
麻煩大大幫幫忙幫我解釋一下
謝謝
#include   <avr/io.h>

//function   prototypes   for   user   defined   functions
char   ReadKeypad();

int   main()
{
unsigned   char   key;

DDRA   =   0xFF;

while(1)
{
key   =   ReadKeypad();

if   (key==0xFF)   continue;     //不懂

PORTA   =   key;                       //不懂
}

while(1);
return   0;
}

//define   a   look-up   table
char   lookup[]={   '1 ',   '2 ',   '3 ',   'A ',
'4 ',   '5 ',   '6 ',   'B ',
'7 ',   '8 ',   '9 ',   'C ',
'* ',   '0 ',   '# ',   'D '};

char   ReadKeypad()
{
//declare   local   variables
unsigned   char   row,   col;
unsigned   char   input,   shift;

//define   Port   D   to   connect   to   the   kaypad
//PD0   -   PD3   as   input,   PD4   -   PD7   as   output
DDRD   =   0xF0;         //不懂     為什麼是0xF0   而不是0xFF

//write   1 's   to   those   pins   defined   as   input
//to   enable   the   pull-up   R 's
PORTD   =   0xFF;

//prepare   scanning
row   =   0;//the   first   row         //不懂
shift   =   0x10;//the   first   row   as   1         //不懂

//start   scanning
for   (row=0;   row <4;   row++)
{
PORTD   =   ~shift;                 //不懂
shift   =   shift < <1;//shift   < <=   1;         //不懂
input   =   PIND;                                 //不懂

input   =   input   |   0xF0;//screen   the   output   pins   //不懂
input   =   ~(input);       //不懂

if   (input   !=   0)           //不懂
break;

}

//any   key   pressed?
if   (row   <   4)           //不懂
{
//the   loop   was   broken   because   a   key   was   pressed
//the   row   output   0   is   the   row   value

//find   out   the   col   which   is   1
shift   =   0x01;       //不懂
for   (col=0;   col <4;   col++)       //不懂
{
if   (input   &   shift)     //不懂
{
//use   input   to   hold   the   key   value
input   =   4*row   +   col;     //不懂
//return   input;
return   lookup[input];       //不懂
}
shift   =   shift < <1;       //不懂
}



}
input   =   0xFF;         //不懂
return   input;         //不懂
}

[解决办法]
发到C语言版吧
[解决办法]
看看 鍵盤的ascii

热点排行