为什么不用TComDrv,分析要实现的功能,改用高级语言编程
解决方案 »
- DELPHI如何支持俄语?
- SQL Server数据库追加问题!
- 如何使不退出程序就不能关闭系统?
- 请大虾们看看:这是为什么?
- 系统编程-CB_ADDSTRING
- 帮忙。怎样用程序创建一个带密码的ACCESS库?(内空)
- 会delphi的帮个忙,求助帮我做一个dll.
- 好多FTP都在教育网,直接进不去,有什么好方法吗?
- idhttp 出现 http/1.1 500 internal server error 是什么错误?
- 请问怎样才可以使扩展名abc的文件默认用你指定的程序去打开。
- 求助:Big5码与简体中文对照表
- 辛辛苦苦做好了上传的个人主页,难道就是展示自我吗??此中有没有赚钱的机会??请高手说...
init_port和send_port改成汇编。多谢!#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
#include <bios.h>void init_port(code)
unsigned char code;
{
union REGS r;
r.x.dx = 0; /* com1 */
r.h.ah = 0;
r.h.al = code;
int86(0x14,&r,&r);
}void send_port(c)
char c;
{
union REGS r; r.x.dx = 0; /* com1 */
r.h.al = c;
r.h.ah = 1;
int86(0x14,&r,&r);
if (r.h.ah & 128) {
printf("send error !\n");
exit(-1);
}
}
修改如下:
//Init_port 对应 Init_port;
//send_port 对应 send_port;
//呵呵,声明一下,因为对汇编忘记的差不多了,手头没有资料,你自己看着办调试一下,看看有注释的地方对不对。要不请哪为高手更正一下!
procedure init_port(ch:char);
begin
asm
mov dx,0;
mov ah,0;
mov al,ch;
int $14;
end;
end;function send_port(ch:char):string;
label exit;
var
str:string;
begin
asm
mov dx,0;
mov al,ch;
mov ah,1;
int 14;
and ah,128; // <--注意一下这个地方
cmp ah,0; // <--还有这儿!
jnz exit;
mov str,'send error!';
exit:
end;
result:=str;
end;
int k,n; /* n=1 On, n=0 Off 1=<k<=11 */
{
send_port(27);
send_port(46);
send_port(k);
send_port(n);
}
例子调用如下:
for (i=1;i<13;i++) {
setpoint(i,1);
delay(1500);
setpoint(i,0);
}
或参考上述部份 /************** CPortLib ****************/
+----------------------------------------+
| ComPort Library version 2.61 |
| for Delphi 3, 4, 5 |
| and C++ Builder 3, 4, 5 |
| |
| by Dejan Crnila |
| 1998-2000 |
| C++ Builder support by Paul Doland |
+----------------------------------------+