Announcement

Collapse
No announcement yet.

DOS ASM Equivalent?

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

  • DOS ASM Equivalent?

    I am at a loss, here. I have tried numerous variations of code
    to try to achieve the desired results, and none have worked.

    To wit:

    In the 32-bit PB compilers, you can do:

    ! lea edi, Q&&

    or, for strings:

    ! lea edi, S$
    ! mov edi, [edi]

    This loads the address for the vars into whichever general purpose
    registers were selected.

    How do I accomplish the same thing in PB/DOS 3.5? I already know how
    to use:

    ! lds si, var???

    But the only thing that seems to work for that is if var??? is a
    prepopulated POINTER to the actual var. So, how can I "shortcut"
    loading the live variables' address into segment: offset registers,
    as can be done in 32-bit? Or is this impossible, because 32-bit
    proggies use a flat memory model, but DOS programs use segment: offset
    addressing? (i.e., the Intel opcodes will not support it)

    Thank you for any replies.


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


    [This message has been edited by Clay Clear (edited March 01, 2003).]

  • #2
    Clay,
    you have to get the segment and offset seperately:

    Code:
    b%=123
    d%=0
    
    print varseg(b%)
    print varptr(b%)
    
    !lea ax,b%  'get the offset into a%
    !mov a%,ax
    !mov d%,ds  'get the data segment into b%
    
    
    print a%,d%
    Paul.


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

    Comment


    • #3
      Thanks, Paul. Once again, you have "come to the rescue."


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

      Comment


      • #4
        Paul,

        I am sorry for singling you out, but you have been the only person
        who has bothered to answer my ASM questions.

        Can you give me a URL link to a site that explains what the
        assorted segment registers in DOS ASM are used for? The 32-bit
        ASM is much simpler to understand/use, it's the DOS addressing
        modes that I am weak on.

        Thank you for any reply you can give me.


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

        Comment


        • #5
          Clay,

          PBDOS has a function to return the strings seg ffset address and length
          called GetStrLoc. Below is an ASM example of how to use it.


          Code:
          Declare Function GetStrLoc(ByVal AllocHandle%) As Long
           
          a$ = "My String Value Here!"
           
          !  mov AX, a$         ; Handle of a$ into AX
          !  push AX            ; Pass it as a parameter for the next CALL
          !  call GetStrLoc     ; Call the internal function GetStrLoc
          !  mov ES, DX         ; DX contains the segment address of the string
          !  mov BX, AX         ; AX contains the offset address of the string
          !  mov a%, CX         ; CX contains the strings length
          !  mov AX, ES:[BX+1]  ; Copy the second character from the string into AX
          !  mov b%, AL         ; Copy that into the variable b%
           
          Cls
          Print "The 2nd letter is " ;Chr$(b%); " and string is"; a%; "in len."
          End

          ------------------
          Scott Slater
          Summit Computer Networks
          www.summitcn.com
          Scott Slater
          Summit Computer Networks, Inc.
          www.summitcn.com

          Comment


          • #6
            Thanks, Scott! You just combined into one neat code what I've been
            trying to accomplish all morning! I sure am glad that I came
            back to the Forums just now! My solution in DOS ASM so far
            has been to populate a DWORD pointer var with the STRPTR32()
            of the strings, then use ! lds si (or ! les di). My solution
            WORKS, but I am trying to move my PBU's into being as pure
            ASM as possible (those that natively belong to ASM, anyway ).
            The reason I use ds:[si] and es:[di] so much is because I make a lot
            of use of such ASM opcodes s ! movsb, ! scasb, etc. Anyway, so I
            don't bore you any longer, let me just say "Thank You", once again.



            [This message has been edited by Clay Clear (edited March 01, 2003).]

            Comment


            • #7
              Clay,
              I don't have a URL but I'd recommend the book "The 8086 8088 primer" by Stephen Morse (he's one of the designers of the 8086 at Intel) ISBN 0-8104-6255-9 (but don't tell Bob Z. I told you 'cos he thinks as, it's called a "primer", it isn't worthwhile).

              DOS segment registers are not difficult. There are only 4 of them. They are multiplied by 16 when used so if the register contains &h123 then it points to the 64k block of memory starting at &h1230 (thats &h123 x 16).

              CS is the current code segment, that's the segment your program is currently executing in.
              DS is the data segment where all data is stored.
              SS is the Stack segment, where the stack is.
              ES is the extra segment, it's for you to use as you wish.

              Paul.


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

              Comment


              • #8
                Paul,

                Thank you very much for your reply. I will not need the primer, now,
                because your description of the 4 segment registers cleared
                up a lot of the "fog" in my brain. The only one I knew for sure
                before then was the CodeSegment register.

                Thanks again.


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

                Comment


                • #9
                  Clay,
                  and it's not 4:00 yet! I must be replying before I go to bed instead of when I get up.

                  Paul.


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

                  Comment

                  Working...
                  X