资源简介
51单片机的计算器.rar
代码片段和文件信息
/*******************************************************************************
************ LABCENTER ELECTRONICS ************
************ Proteus VSM Sample Design Code ************
************ Integer Calculator ( 2K Code Limit) ************
*******************************************************************************/
#include
#include
#include “calc.h“
//Variables
static data LONG lvalue;
static data LONG rvalue;
static data CHAR currtoken;
static data CHAR lasttoken;
static data CHAR lastpress;
static xdata CHAR outputbuffer[MAX_DISPLAY_CHAR];
VOID main (VOID)
//Initialise our variables and call the
//Assembly routine to initialise the LCD display.
{ lvalue = 0;
rvalue = 0;
currtoken = ‘=‘;
lasttoken = ‘0‘;
initialise(); // Initialize the LCD
calc_output(OK);
calc_evaluate();
}
VOID calc_evaluate()
{ CHAR data key;
INT data i;
CHAR xdata number[MAX_DISPLAY_CHAR];
CHAR xdata *bufferptr;
// Clear the buffer before we start.
for (i = 0; i <= MAX_DISPLAY_CHAR; i++)
{ number[i] = ‘ ‘;
}
bufferptr = number;
for (;;)
{ key = calc_getkey();
if (calc_testkey(key))
// Key test positive for digit so we read it into the
// buffer and then write the buffer to the screen/LCD.
// Size limit the number of digits - allow for termination
// and possible negative results.
{ if (bufferptr != &number[MAX_DISPLAY_CHAR - 2])
{ *bufferptr = key;
calc_display(number);
bufferptr++;
}
}
else
// Key is an operator so pass it to the function handlers.
// If we are just after startup or cancel then assign to lvalue
// otherwise assign to rvalue.
{
//Assign the value.
if (lasttoken == ‘0‘)
{ lvalue = calc_asciidec (number);}
else
{ rvalue = calc_asciidec (number);}
//Clear the number buffer.
bufferptr = number;
for (i = 0;i <= MAX_DISPLAY_CHAR; i++)
{ number[i] = ‘ ‘; }
//Process the Operator.
currtoken = key;
if (currtoken == ‘C‘)
{ calc_opfunctions(currtoken); }
else
{ calc_opfunctions(lasttoken); }
// Clear the outputbuffer for reuse on next operation.
for (i = 0;i <= MAX_DISPLAY_CHAR;i++)
{ outputbuffer[i] = ‘ ‘;}
bufferptr = number;
// Handle the equals operation here for brevity.
// All we need do is preserve the previous operator in
// lasttoken.
if (currtoken != 0x3D) lasttoken = currtoken;
}
lastpress = key;
}
}
VOID calc_opfunctions (CHAR token)
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1808 2011-01-07 12:47 C51 Calculator\8051 Calculator.vsmp
文件 6327 2011-01-07 12:47 C51 Calculator\calc
文件 7998 2011-01-07 12:47 C51 Calculator\calc.c
文件 176033 2011-01-07 12:47 C51 Calculator\calc.DSN
文件 1467 2011-01-07 12:47 C51 Calculator\Calc.h
文件 5245 2011-01-07 12:47 C51 Calculator\calc.hex
文件 1185 2013-05-06 20:16 C51 Calculator\CALC.Opt
文件 231 2013-05-06 22:15 C51 Calculator\calc.plg
文件 1038 2013-05-18 18:29 C51 Calculator\calc.PWI
文件 2016 2013-05-06 20:16 C51 Calculator\CALC.Uv2
....... 1016 2011-01-07 12:47 C51 Calculator\CALC_Opt.Bak
....... 1724 2011-01-07 12:47 C51 Calculator\CALC_Uv2.Bak
文件 13748 2011-01-07 12:47 C51 Calculator\Debug\DEBUG.OMF
目录 0 2013-05-05 11:03 C51 Calculator\Debug
文件 2315 2011-01-07 12:47 C51 Calculator\KEYPAD.ASM
文件 7336 2011-01-07 12:47 C51 Calculator\keypad.LST
文件 2107 2011-01-07 12:47 C51 Calculator\LCD.ASM
文件 6566 2011-01-07 12:47 C51 Calculator\lcd.LST
目录 0 2013-05-18 18:29 C51 Calculator
----------- --------- ---------- ----- ----
238160 19
相关资源
- 2[1].2的控制端2008.6.12更新.zip
- eXeScope.rar
- echarts-china-map点击显示省地图.zip
- mac-BaiduNetdiskPlugin.zip
- 病毒样本.rar
- CEGUI.txt
- pan.txt
- CVPR2018论文979篇.txt
- huabei.zip
- MIMOEqualizeMMSE.docx
- P_MMSE.rar
- P_ZF_SIC.rar
- memory_management.7z
- 基于Multisim10的电子摇号器设计与仿真
- hathitrust.zip
- 说明.txt
- 电力电子课程设计_secret.doc
- C.txt
- officescan.rar
- portal10.5.ecp
- Qimage.rar
- samp2_3.rar
- DropDataControl.rar
- 20.rar
- monihid.c
- sound.properties
- iso.txt
- MaskWindow.zip
- VS2010中文旗舰版(破解版).txt
- probability-sheldon-ross-solution-manual.pdf
评论
共有 条评论