1.硬件2.C程序#define ADR_273 0x0200 #define ADR_244 0x0400 #define LED_PORT 0x800 void outp(unsigned int addr, char data) // 输出一字节到I/O端口 { __asm { mov dx, addr mov al, data out dx, al } } char inp(unsigned int addr) // 从I/O端口输入一字节 { char result; __asm { mov dx, addr in al, dx mov result, al } return result; } char end_flag[5]{0x55,0x55,0x55,0x55,0x55}; void delay(void) // 延时函数使用原有的双重循环延时方式 { int i; for(i0; i5000; i); for(i0; i5000; i); } void main(void) /* 闪烁灯程序8位LED时亮时灭 采用共阳LED输出0点亮输出1熄灭 */ { int i; unsigned char led_pattern; // 初始值1111 1110 (最低位D00点亮第1个LED) led_pattern 0x00; while (1) { // 输出当前模式到LED端口 outp(LED_PORT, led_pattern); // 延时控制流水速度 delay(); led_pattern ~led_pattern; outp(LED_PORT, led_pattern); delay(); } // 退出时关闭所有LED输出全1 // outp(LED_PORT, 0xFF); }汇编.MODEL TINY .8086 .code extrn _main:proc .startup call near ptr _main endless: jmp endless .data public __acrtused ; trick to force in startup __acrtused 9876h ; funny value not easily matched in SYMDEB .stack END3.编译脚本..\tools\ml.exe /c /AT /Zm /Zi rtl.asm ..\tools\dmc.exe -mt -0 -c -g main.c ..\tools\optlink.exe /TINY rtl.obj main.obj, debug.com4.下载测试