资源简介
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
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论