Announcement

Collapse
No announcement yet.

Extended registers

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

  • Extended registers

    Is it possible to access the extended registers (EAX, EBX, etc.)in DOS? Specifically, I want to be able to access all 32-bits that may be returned by a call to INT 11h.
    If you try to make something idiot-proof, someone will invent a better idiot.

  • #2
    Just prefix your ASM instruction with:
    ! DB 102

    You still have to use the 16 bit registers in your code so PowerBASIC
    will recognize them (PowerBASIC for DOS doesn't recognize 32 bit
    registers), but the CPU will recognize that you want to access a
    32 bit register with the code prefix. You must prefix each instruction
    that uses a 32 bit register:


    ! DB 102
    ! MOV AX, VALUE??? ;MOV EAX, VALUE???
    ! DB 102
    ! MOV VALUE???, BX ;MOV VALUE???, EBX

    The prefix converts 16 bit values to 32 bits. It has no effect on
    8 bit values:

    ! DB 102
    ! SHL BX, CL ;SHL EBX, CL

    If you assign an immediate value to a 32 bit register, be sure to
    provide a full 32 bits. PowerBASIC won't allow more than 16 bits
    for an immediate value, since it only recognizes 16 bit registers
    (and 8 bit registers), so you must provide the upper 16 bits
    seperately:

    ! DB 102
    ! MOV AX, &HFFFF ;MOV EAX, &H0FFFFFFF: LSW of immediate value here
    ! DW &H0FFF ;MSW of immediate value here

    If you forget the upper 16 bits, you'll likely hang.

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

    Comment


    • #3
      This should be most useful. Thanks!

      Now if I want my program to be able to run on a wide range of PCs, from 8088 CPUs to Pentium-class machines, how do I detect whether the CPU is 16-bit or 32-bit, so as to know whether or not to attempt to use the extended registers at run-time?
      If you try to make something idiot-proof, someone will invent a better idiot.

      Comment


      • #4
        Check the internal byte variable, pbvCpu.

        Returns:
        1 = 8086 / 8088 / 80186
        2 = 80286
        3 = 80386+

        Check the online help for a list of all of PowerBASIC's internal
        variables and internal procedures.


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

        Comment


        • #5
          I am aware of the pbvCpu internal variable, but was on the understanding that the extended registers were not supported in 80386SX CPUs because they have a 16-bit external interface, whereas the 80386DX CPU is fully 32-bit. The pbvCpu internal variable does not enable me to distinguish between 386SX and 386DX CPUs. There were also many Intel CPU clones coming out around the time of the 386 which could make relying on determination of the CPU type problematic for determining if the extended registers are supported.
          If you try to make something idiot-proof, someone will invent a better idiot.

          Comment


          • #6
            I believe that even though the 386SX is limited to a 16 bit data
            bus, it still supports 32 bit registers. Someone else will have
            to verify this for certain.


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

            Comment


            • #7
              Yes, the 386SX does contain the 32-bit extended registers, the same as the DX. The only difference between the SX and DX is the external data path (16 bits vs. 32 bits) - which is handled by the CPU's bus-interface circuitry; if you try to load a 32-bit register, it just does two consecutive bus accesses to get the data 16 bits at a time. Your program doesn't know the difference, though. (It's the same philosophy as was behind the original 8088 / 8086 chips; they were identical internally, except that the 8088 only had an 8-bit external bus while the 8086 had a 16-bit bus, so the 8088 did two bus cycles to load a 16-bit register while the 8086 could do it in one.)

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

              Comment

              Working...
              X