Ver Mensaje Individual
  #4  
Antiguo 21-04-2008
JoseFco JoseFco is offline
Baneado
 
Registrado: dic 2007
Posts: 1.861
Reputación: 0
JoseFco cantidad desconocida en este momento
Hola candia.

Si lo que quieres es ver como se ve un programita Delphi en asm para el puerto serie, aqui te dejo esto:

Código Delphi [-]
var
  Form1: TForm1;
  data,status:byte;
const
    base = $3f8;{base address port serial}
    lcr = 3; {line control register}
    dll = 0; {divisor lacht low byte}
    dlh = 1; {divisor lacht high byte}
    lsr = 5; {line status register}

Procedure Initserial;
begin
    asm
        mov dx,base+lcr; {address line control register}
        mov al,$80 ; {10000000b = access bit divisor lacht}
        out dx,al
;
        mov dx,base+dll; {address divisor lacht low byte}
        mov al,$30 ; {DLLB = 30h}
        out dx,al
;
        mov dx,base+dlh; {address divisor lacht high byte}
        mov al,$00     ; {DLLH = 00h}
        out dx,al
;                       {In this case Port Serial have}
;                       { baud rate = 2400 bps}
        mov dx,base+lcr;{address line control register}
        mov al,$03 ;    {00000011b =}
        out dx,al ;     {bit 7=0, access to Rx buffer & Tx
;                       {bit 6=0, set break disable
;                       {bit 5-4-3=000, no parity
;                       {bit 2=0, one stop bit
;                       {bit 1-0=11,data lenght 8 bit}
        end;
end;

Procedure Send_Data_Serial;
begin
    asm
        mov dx,base
        mov al,data
        out dx,al
    end
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Initserial;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
repeat
  asm
   mov dx,base+lsr ; {address line status register }
   in al,dx
   and al,$20      ; {00100000b =not masking bit 5}
   mov status,al   ; {bit5=Empty Transmitting holding reg}
  end;
until status = $20; { If ETHR = 1 then data ready tobe send }
data:=0;
Send_Data_Serial;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 repeat
  asm
   mov dx,base+lsr; {address line status register }
   in al,dx
   and al,$20     ; {00100000b =not masking bit 5}
   mov status,al  ; {bit5=Empty Transmitting holding reg}
  end;
until status = $20; { If ETHR = 1 then data ready tobe send}
data:=1;
Send_Data_Serial;
end;

Yo prefiero usar ComPort por muchas razones y una es que en asm, algunas PC ya no quieren rodar bien.Por ejemplo Win XP da problemas cuando se crea un asm para controlar el puerto serie.
Con los PICs no te puedo ayudar. Pero aqui hay algunos colegas que si conocen bastante estos chips.

Un Saludo.
Responder Con Cita