Announcement

Collapse
No announcement yet.

db dup ... using inline asm?

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

  • db dup ... using inline asm?

    I wish allocate some space in code segment, something like this...

    buffer: db 255 dup (0)

    using power basic for dos inline asm. Can I?

    Ed


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

  • #2
    Nope. The PB inline ASM commands do not use the same syntax
    as assemblers such as MASM, etc. You could go about it in
    several ways:

    S$ = SPACE$(255). Then populate the string with the desired data,
    and reference the string's bytes with an index pointer.

    DIM S AS ASCIIZ*255. Use as above.

    MyTable:
    ! db 00
    ! db 00
    etc., up to the 255 bytes

    Then use ! lea dx, MyTable, and reference CS:[DX], using DX (or whichever
    index register you specified) as the index.

    TYPE MyType
    a(1 TO 255) AS BYTE
    END TYPE

    DIM w AS MyType.

    Then do:

    ! lea di, w
    ! push ds
    ! pop es

    Then reference it in es:[di]

    P.S. I am not sure if you can use the DX register as the index register
    in the CS:[DX] - it's been quite a while since I used labeled tables
    in my PB/DOS.

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




    [This message has been edited by Clay Clear (edited May 14, 2003).]

    Comment


    • #3
      AX, CX, and DX can't be used for addressing. BX, SI, or DI are good bets.

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Thanks, Tom, for the clarification. I already knew that, but I
        guess my sleep-deprived mind blew it off. <chuckle>


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

        Comment

        Working...
        X