Announcement

Collapse
No announcement yet.

Inline ASM Question...

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

  • Inline ASM Question...

    Is it possible to do the following in PB's Inline-Assembler?

    Code:
    Ptr1=VARPTR(Arr(1))
    ------------------
    Adam Drake
    PowerBASIC

  • #2
    Technically, no, not without calling the VARPTR function and the Array Engine.

    Why not? Because the PB array descriptor is proprietary, meaning you can't know "where" the data are unless you use VARPTR. (No doubt someone will post something showing what they figured out vis-a-vis the descriptor, but of course that is subject to change in the next version of PB).

    Of course, you could always manage your own arrays (or simply manage the memory and use an ABSOLUTE array) if using assembly language is that important to you.

    MCM


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      But i think he's asking for the address of the buffer.
      Not the varptr of the array
      Or is it still a PB related thing..?


      ------------------
      http://www.hellobasic.com
      hellobasic

      Comment


      • #4
        This is not something that for me is absolutely necessary, I've just converted all of a particular subroutine to inline assembler except the lines that use the VARPTR function. Reason I was curious is because you can load pointers to strings using inline assembler, didn't know if the same was true for arrays.

        ------------------
        Adam Drake
        PowerBASIC

        Comment


        • #5
          ... why do you need to do that one line in inline asm though?

          [Edit - just saw your reply] -- no, unfortunately I dont think you can refer to arrays like you can with strings/dwords etc. It'd be handy though


          [This message has been edited by Wayne Diamond (edited August 15, 2003).]
          -

          Comment


          • #6
            particular subroutine to inline assembler except the lines that use the VARPTR function
            VARPTR(X) = Address of X

            I don't do assembly language, but I was sure there is an explicit intruction for "load address of 'x' to this register."

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Why not ask at Hutch's site: MasmForum.com ,
              he has a SubForum specifically for "PowerBasic Assembly"
              and it not only may get answered, but will help spread knowlege of PB,
              a few of the members there have already purchased PB, because of Hutch's
              site, and are quite delighted!!!


              ------------------
              Wash DC Area

              Comment


              • #8

                It slipped Brad's mind... so here it is
                http://www.masmforum.com/viewforum.p...5e1be9484c682d

                Marc

                ------------------
                Regards,
                Marc
                Regards,
                Marc

                Comment


                • #9
                  Adam,
                  I'm not sure it is possible because of what MCM said. I usually calculate the start of the array in BASIC before the ASM starts and then pass the 32-bit pointer to the ASM which is easy
                  e.g.
                  Code:
                   ArrPtr=VarPtr(Arr(0)) 'get the address of the 1st element of the array
                   ..
                   ..
                   !mov eax,ArrPtr   'get the address of the first element into EAX
                  MCM,
                  you can get the address of a simple variable in ASM using:
                  Code:
                  !lea eax, Variable  'get address of Variable into EAX register
                  .. but you can't have arrays in the ASM statements so this won't work for an array elememt.

                  Paul.

                  Comment


                  • #10
                    No, currently there is no reasonable way to do this. That's because:

                    1- PowerBASIC assembler syntax does not support a way to obtain the address of the array descriptor (because the array descriptor contents are not documented, because they may be subject to change in the future).

                    2- The array descriptor contents are needed in order to calculate the memory location of any particular element in the array.

                    3- It requires multiple opcodes to calculate the address of an array element regardless.

                    Regards,

                    Bob Zale
                    PowerBASIC Inc.


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

                    Comment

                    Working...
                    X