资源简介
利用peotues基于8086实现计算器功能,加减乘除等等,内部含有代码,原理图,模块图等
代码片段和文件信息
#include “board.h“
#include “7seg.h“
void outp(unsigned int addr char data)
// Output byte to port
{ __asm
{ mov dx addr
mov al data
out dx al
}
}
char inp(unsigned int addr)
// Input byte from port
{ char result;
__asm
{ mov dx addr
in al dx
mov result al
}
return result;
}
void set_int(unsigned char int_no void * service_proc)
{ _asm
{ push es
xor ax ax
mov es ax
mov al int_no
xor ah ah
shl ax 1
shl ax 1
mov si ax
mov ax service_proc
mov es:[si] ax
inc si
inc si
mov bx cs
mov es:[si] bx
pop es
}
}
/* USART */
unsigned char putch_buffer[256];
unsigned char putch_out_pos;
unsigned char putch_pos;
void putch_out(void)
// Output one symbol from buffer to 8251A USART
{ if (putch_out_pos == putch_pos)
return;
if((inp(ADR_USART_STAT) & 0x01) == 0)
return;
outp(ADR_USART_DATA putch_buffer[putch_out_pos]);
putch_out_pos++;
}
unsigned char putch( unsigned char c )
// Put one symbol into buffer
{ putch_buffer[putch_pos] = c;
putch_pos++;
return c;
}
void prints(char* s)
// Print string using putch() function
{ char c;
while(s && *s)
{ c = *s;
if (c == ‘\r‘)
c = ‘\n‘;
putch(c);
s++;
}
}
void printui(unsigned int i)
// Print unsigned int using putch() function
{ unsigned char val;
unsigned int temp = 10000;
unsigned char printed=0;
while (temp >= 1)
{ val = (i / temp) % 10;
if ((val!=0) || printed || (temp == 1))
{ putch(val + ‘0‘);
printed = 1;
}
if (temp == 1)
break;
temp /= 10;
}
}
void setup_usart(void)
// 8251 USART Setup
{ /* setup USART */
outp(ADR_USART_CMD 0x7D); /* ED */
outp(ADR_USART_CMD 0x07); /* RxEn TxEn DTRa */
putch_out_pos = 0;
putch_pos = 0;
}
/* Timer */
signed char delay;
int sound_enabled;
int display_enabled;
void sound_nmi(void)
{ delay++;
if (delay >= 10)
delay = -delay;
outp(ADR_TIMER_CONTROL TIMER_COUNTER2 | TIMER_MODE2 | TIMER_LSB);
outp(ADR_TIMER_DATA2 ABS(delay)+0x40);
}
void _interrupt _far nmi_handler(void);
void setup_nmi(void)
// Set NMI Timer at 50Hz.
{ set_int(0x02 (void *)&nmi_handler);
outp(ADR_TIMER_CONTROL TIMER_COUNTER1 | TIMER_MODE2 | TIMER_LSB_MSB);
outp(ADR_TIMER_DATA1 0xD0);
outp(ADR_TIMER_DATA1 0x07);
}
/* PIO */
// Value to be displayed
unsigned int display_value;
// Current display position
unsigned char cur_display_pos;
// Current dispaly segments
unsigned char cur_display_segs;
unsigned char keys[16];
#define KEY_7 0
#define KEY_8 1
#define KEY_9 2
#define KEY_DIV 3
#define KEY_4 4
#define KEY_5 5
#define KEY_6 6
#define KEY_MUL 7
#define KEY_1 8
#define KEY_2 9
#define KEY_3 10
#
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4769 2012-06-28 09:45 8086 Demo Board\7seg.h
文件 1191 2018-08-21 23:15 8086 Demo Board\80C31\main.asm
文件 6422 2012-06-28 09:45 8086 Demo Board\board.c
文件 2030 2012-06-28 09:45 8086 Demo Board\board.h
文件 7860 2012-06-28 09:45 8086 Demo Board\calc.c
文件 14576 2012-06-28 09:45 8086 Demo Board\calc.exe
文件 1464 2012-06-28 09:45 8086 Demo Board\calc.h
文件 55 2012-06-28 09:45 8086 Demo Board\cleanup.bat
文件 281 2012-06-28 09:45 8086 Demo Board\compile.bat
文件 95700 2012-08-23 10:30 8086 Demo Board\DemoBoard.pdsprj
文件 3329 2018-08-22 22:58 8086 Demo Board\DemoBoard.pdsprj.LAPTOP-L37PB4J6.GaoMin.workspace
文件 3072 2012-06-28 09:45 8086 Demo Board\math.lib
文件 255 2012-06-28 09:45 8086 Demo Board\rtl.asm
目录 0 2018-08-21 23:15 8086 Demo Board\80C31
目录 0 2018-08-21 23:15 8086 Demo Board
----------- --------- ---------- ----- ----
141004 15
- 上一篇:GAMIT 解算各步骤
- 下一篇:土狼优化算法
评论
共有 条评论