Re: I/O Port access from eVC++ 4.0

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Michael Schwab (michael.schwab_at_cobecv.com)
Date: 04/27/04

  • Next message: Alan Serpini: "Thread and GUI"
    Date: Tue, 27 Apr 2004 14:40:35 -0600
    
    

    _asm works fine.
    Here's what I use on my Advantech PCM5820, and it's worked under both CE 3.0
    and CE 4.2:

    // To input a 16-bit data value from I/O port addr:
    unsigned short inpw(unsigned short addr) {
     unsigned short retval;
     _asm{ push dx
       push ax
       mov dx,addr
       xor ax,ax
       in ax,dx
       mov retval,ax
       pop ax
       pop dx
     }
     return(retval);
    }

    // To output 16-bit data to I/O port addr:
    void outpw(unsigned short addr, unsigned short data){
     _asm{ push dx
       push ax
       mov dx,addr
       mov ax,data
       out dx,ax
       pop ax
       pop dx
     }
    }

    // To output 8-bit data to I/O port addr:
    void outpw(unsigned short addr, unsigned short data){
     _asm{ push dx
       push ax
       mov dx,addr
       mov ax,data
       out dx,al
       pop ax
       pop dx
     }
    }

    "Anthony Marchini" <marchini@am_r_c.nl0ckerd0tcom> wrote in message
    news:OY0uLZGLEHA.912@tk2msftngp13.phx.gbl...
    >
    > "Paco Novell" <anonymous@discussions.microsoft.com> wrote in message
    > news:BDE6D8E6-2CF2-4A29-855D-7FC7665495DC@microsoft.com...
    > > I am using an Advantech PCM-5820 SBC (Geode Processor)
    >
    > Didn't Advantech supply any drivers?
    > Pehaps you can make a VC++ dll that creates an output and an input
    function
    > and
    > uses an inline ASM series of instructions to use the OUT and IN opcodes.
    > I don't know if the _asm{ } directive is still supported
    > T.
    >
    >


  • Next message: Alan Serpini: "Thread and GUI"

    Relevant Pages

    • Re: Help: ASM to ASM calls
      ... Subject: Help: ASM to ASM calls ... push ebp ... mov al, ... This won't work as EAX will be altered by your call ...
      (comp.lang.asm.x86)
    • Re: how do I read data from a port in WINCE
      ... Well, gee, you never set dx to anything (like the addr value). ... _asm{push dx ... mov retval,ax ... assembly code in embedded visual C++ and I can read one byte at a time. ...
      (microsoft.public.windowsce.app.development)
    • Re: popen
      ... push mod ... mov, eax ... other "interactive scripting widgets") from ASM. ...
      (alt.lang.asm)
    • understanding speed
      ... Does each line of asm take the same time? ... I mean is a "mov" performed ... as fast as an "add" or a "push"? ... Looking for a good game? ...
      (alt.lang.asm)
    • Re: Byte to byte compare, duplicate file finder/killer
      ... Then we could maybe port asm, by writing it all in asm. ... mov edx D$DuplicateList ... .While ecx < D$DuplicateCanditates ... While ebx < D$DuplicateCanditates ...
      (alt.lang.asm)