程序很简单,是这样的: procedure readport(Port:WORD;num:word;addr:pbytearray); label cycle; begin ASM push esi; push edi; and ecx,0; mov cx,num; mov edi,addr; MOV DX, Port; inc dx; inc dx; mov al,$20; out dx,al; {lpt1 output} dec dx; dec dx; cycle:in AL, DX; mov [edi],AL; inc edi; loop cycle; pop edi; pop esi; END; end;procedure TForm1.Button1Click(Sender: TObject); var a:word; {b:array[0..1000] of byte; } c:pbytearray; i:integer; begin a:=100; memo1.text:='asd'; getmem(c,1000); readport($378,a,@c); for i:=1 to 100 do begin memo1.text:='assdfrf'; memo1.Text:=memo1.Text+inttostr(c[i])+' '; end; freemem(c); end; 编译通过了,执行的时候,按下按钮1,就出现了一个debugger Exception Notifation警告对话框,说是在执行到$00XXXXXX处发生了读某个大于$FXXXXXXX地址的错误。且有选择CPU窗口的提示。
procedure readport(Port:WORD;num:word;addr:pbytearray);
label cycle;
begin
ASM
push esi;
push edi;
and ecx,0;
mov cx,num;
mov edi,addr;
MOV DX, Port;
inc dx;
inc dx;
mov al,$20;
out dx,al; {lpt1 output}
dec dx;
dec dx;
cycle:in AL, DX;
mov [edi],AL;
inc edi;
loop cycle;
pop edi;
pop esi;
END;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:word;
{b:array[0..1000] of byte; }
c:pbytearray;
i:integer;
begin
a:=100;
memo1.text:='asd';
getmem(c,1000);
readport($378,a,@c);
for i:=1 to 100 do
begin
memo1.text:='assdfrf';
memo1.Text:=memo1.Text+inttostr(c[i])+' ';
end;
freemem(c);
end;
编译通过了,执行的时候,按下按钮1,就出现了一个debugger Exception Notifation警告对话框,说是在执行到$00XXXXXX处发生了读某个大于$FXXXXXXX地址的错误。且有选择CPU窗口的提示。