Announcement

Collapse
No announcement yet.

I need read/write 1-byte and 2-bytes ports routines for PBDOS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need read/write 1-byte and 2-bytes ports routines for PBDOS

    Hey all,

    I will an procedure for read/write: 1 byte port, 2 byte port for PBDOS.
    How can I change the code for :

    'Return an byte from the specific port
    DECLARE FUNCTION InpB(BYVAL PortAddress AS BYTE) AS INTEGER

    'Return an word from the specific port
    DECLARE FUNCTION InpW(BYVAL PortAddress AS WORD) AS INTEGER

    'Write an byte to the specific port
    DECLARE SUB OutB(BYVAL PortAddress AS BYTE, BYVAL Value AS INTEGER)

    'Write an word to the specific port
    DECLARE SUB OutW(BYVAL PortAddress AS WORD, BYVAL Value AS INTEGER)

    Question :
    Is that for read/write 8-bits or 16-bits ports?

    SUB pbOut(BYVAL port AS INTEGER, BYVAL value AS INTEGER)
    ! mov AX, value
    ! mov DX, port
    ! out DX, AL
    END SUB

    FUNCTION pbInp(BYVAL port AS INTEGER) AS INTEGER
    ! mov DX, port
    ! in AL, DX
    ! mov FUNCTION[0], AL
    END FUNCTION

    Please help me for changes how this code for PBDOS

    Greetz
    Stephane



    ------------------
    ICQ: 123632482

  • #2
    Stephane,
    these routines work with BYTEs if the IN/OUT instruction uses AL.
    They work with WORDs if the IN/OUT instruction uses AX.

    e.g OUT DX,AX will output the 16 bit word in AX to the port specified in DX.
    OUT DX,AL will output the 8 bit byte in AL to the port specified in DX.

    Paul.



    ------------------

    Comment


    • #3
      Hey Paul,

      Can you please corrected my declarations and sourcecode for PBDOS.
      'Return an byte from the specific port
      DECLARE FUNCTION InpB(BYVAL PortAddress AS BYTE) AS INTEGER

      'Return an word from the specific port
      DECLARE FUNCTION InpW(BYVAL PortAddress AS WORD) AS INTEGER

      'Write an byte to the specific port
      DECLARE SUB OutpB(BYVAL PortAddress AS BYTE, BYVAL Value AS INTEGER)

      'Write an word to the specific port
      DECLARE SUB OutpW(BYVAL PortAddress AS WORD, BYVAL Value AS INTEGER)

      Question :
      Is that FOR READ/WRITE 8-bits OR 16-bits ports?

      SUB OutB(BYVAL PORT AS INTEGER, BYVAL value AS BYTE)
      'Write an byte to the specific port
      ASM mov AX, value
      ASM mov DX, port
      ASM out DX, AL
      END SUB

      FUNCTION InpB(BYVAL PORT AS INTEGER) AS BYTE
      'Return an byte from the specific port
      ASM mov DX, port
      ASM in AL, DX
      ASM mov FUNCTION[0], AL
      END FUNCTION

      SUB OutpW(BYVAL PORT AS WORD, BYVAL value AS WORD)
      'Write an word to the specific port
      ASM mov AX, value
      ASM mov DX, port
      ASM out DX, AX
      END SUB

      FUNCTION InpW(BYVAL PORT AS INTEGER) AS WORD
      'Return an word from the specific port
      ASM mov DX, port
      ASM in AX, DX
      ASM mov FUNCTION[0], AX
      END FUNCTION

      Thanks in advance
      Stephane



      ------------------
      ICQ: 123632482

      Comment


      • #4
        Stephane,
        you have got all your byte/integer/words mixed up. Try this,

        Paul.

        'Return an byte from the specific port
        DECLARE FUNCTION InpB(BYVAL PortAddress AS word) AS byte

        'Return an word from the specific port
        DECLARE FUNCTION InpW(BYVAL PortAddress AS WORD) AS word

        'Write an byte to the specific port
        DECLARE SUB OutpB(BYVAL PortAddress AS word, BYVAL Value AS byte)

        'Write an word to the specific port
        DECLARE SUB OutpW(BYVAL PortAddress AS WORD, BYVAL Value AS word)

        'Question :
        'Is that FOR READ/WRITE 8-bits OR 16-bits ports?

        SUB OutB(BYVAL PORT AS word, BYVAL value AS BYTE)
        'Write an byte to the specific port
        ASM mov AX, value
        ASM mov DX, port
        ASM out DX, AL
        END SUB

        FUNCTION InpB(BYVAL PORT AS word) AS BYTE
        'Return an byte from the specific port
        ASM mov DX, port
        ASM in AL, DX
        ASM mov FUNCTION[0], AL
        END FUNCTION

        SUB OutpW(BYVAL PORT AS WORD, BYVAL value AS WORD)
        'Write an word to the specific port
        ASM mov AX, value
        ASM mov DX, port
        ASM out DX, AX
        END SUB

        FUNCTION InpW(BYVAL PORT AS word) AS WORD
        'Return an word from the specific port
        ASM mov DX, port
        ASM in AX, DX
        ASM mov FUNCTION[0], AX
        END FUNCTION



        ------------------

        Comment


        • #5
          Hey Paul,

          Thanks for your tips.
          I have a new update of my code. Can you test my this code with an
          example?

          '==========================================================================='
          'Read and Write the PC Ports in DOS '
          '==========================================================================='
          $COMPILE UNIT "PORTS16.PBU"

          'Return an byte from the specific port
          DECLARE FUNCTION InpB(BYVAL PortAddress AS WORD) AS BYTE

          'Return an word from the specific port
          DECLARE FUNCTION InpW(BYVAL PortAddress AS WORD) AS WORD

          'Write an byte to the specific port
          DECLARE SUB OutB(BYVAL PortAddress AS WORD, BYVAL Value AS BYTE)

          'Write an word to the specific port
          DECLARE SUB OutW(BYVAL PortAddress AS WORD, BYVAL Value AS WORD)

          SUB OutB(BYVAL PortAddress AS WORD, BYVAL value AS BYTE)
          ASM mov AX, value
          ASM mov DX, PortAddress
          ASM out DX, AL
          END SUB

          FUNCTION InpB(BYVAL PortAddress AS WORD) AS BYTE
          ASM mov DX, PortAddress
          ASM IN AL, DX
          ASM mov FUNCTION[0], AL
          END FUNCTION

          SUB OutpW(BYVAL PortAddress AS WORD, BYVAL value AS WORD) PUBLIC
          ASM mov AX, value
          ASM mov DX, PortAddress
          ASM out DX, AX
          END SUB

          FUNCTION InpW(BYVAL PortAddress AS WORD) AS WORD
          ASM mov DX, PortAddress
          ASM IN AX, DX
          ASM mov FUNCTION[0], AX
          END FUNCTION

          Is that now corrected.
          May I used the statements PUBLIC and EXTERNAL but where and how?

          Greetz,
          Stephane



          ------------------
          ICQ: 123632482

          Comment


          • #6
            Stephane, I don't see any variables in that code that would need to be PUBLIC or EXTERNAL, since you are using function parameters and return values for everything.

            However, you might want to add a PUBLIC clause to the FUNCTION statements... see the Reference Guide for more info.

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Stephane and Lance ..

              I have been following this one with interest. I dropped research
              a while back on the use of the little IRMAN TV remote control unit
              with PowerBASIC for DOS over what I found to be a minor issue with
              one and two byte COMM port work.

              The little IRMAN TV hand held remote control clicker uses only
              one and two byte I/O commands. For test purposes it did fine on
              my research with the ZOC terminal program which has both a native
              OS/2 and WIN-9+ interface from a common user registration code.
              IRMAN, when you open the COMM port, sends you back ONE and ONLY ONE
              byte to tell you, "Success! I'm here!" Then you send it only
              one or two byte commands and it confirms them that way. The
              test lashup with ZOC for OS/2 as well as two different DOS-VDM
              modem control programs could intitialize the COMM port and run it.

              But my PowerBASIC 3.5 could not! In OS/2, as well as in WIN and
              DOS, we have tools to look at what is acutally going across a COMM
              port byte for byte. Mine in OS/2 come as part of the Ray Gwinn
              SIO much better replacement for the IBM suppied COMM port drivers
              in a package called SIO which inludes Poor Man's Line Monitor as
              PMLM.EXE. Looking at this COMM port routine revealed that while
              any of either the native OS/2 or DOS-VDM terminal programs such as
              COMIT for DOS, could do it, PowerBASIC was failing for one reason.

              As far as I can tell, it flushes the COMM port buffer on opening the
              port! I never could determine from any way of timing it whether
              that arises from an arbitrary action, or something else. In that
              the later 16550AN serial port controller chips and so on that we
              now use contain a 16 bit I/O buffer, it may be that there is a
              glitch in the timing which simply cannot handle only a one bute
              initial response back to the open action! To this extent, Ray's
              SIO 160d has MUCH better control of such things. You and disable
              the entire 16 bit buffer on the port if you want and switch it ot
              single byte I/O and scrap the 16550 action if you want. You can
              also stop OS/2 from emulating that or whatever. Regardless of that,
              unsing no combination for control of CTS, TRS, hard or software
              control of the port, buffer size, nothing ... could I ever get the
              PowerBASIC comm port code to ever pass that single and one and only
              one byte to acknowlege the device was on line.

              So I temporarily shelved the project until I had time to go back
              and look at the possibility of ASSEMBLER to handle this port job.
              It is also important that I do not destroy the high speed functions
              of the whole DOS-VDM session with which this will be used. The
              reason for that is that this IRMAN device will have to control and
              be used with two other COMM ports in the same executable which are
              passing data back and forth between them at full data rates at the
              same time the third port is hosting IRMAN and at the same time
              the forth COMM port is assigned to TELNET over IP.

              Do you folks think that this whole thread, together with ASSEMBLER
              could be used to solve this problem?

              I know better than to attempt to use ASSEMBLER to open a port,
              then try to use PowerBASIC for the actual I/O or the reverse of
              that!

              Can you suggest a complete ASSMBLER operation which could be used
              to handle the port open and close here as well? One that would
              be able to see that single byte 'ready' flag from IRMAN?

              I'm not fussing at all about PowerBASIC's COMM routines. The
              average person would never, I think, ever have run on this. It
              is just something I have to crack for this deal and I ASSURE
              you I don't want to rewrite all the communicatios stuff in
              ASSEMBLER for the rest of the game!

              Thanks!


              ------------------
              Mike Luther
              [email protected]
              Mike Luther
              [email protected]om

              Comment


              • #8
                Hey,

                I working to the library and testing. I'm try to write
                code for driving ports 4 bytes

                Kind regards
                Stephane

                ------------------
                ICQ: 123632482

                Comment

                Working...
                X