Announcement

Collapse
No announcement yet.

Assembly with units in PBDOS

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

  • Clay Clear
    replied
    Basically, you should ! push the registers that your inline
    assembler code uses. If you are using DOS interrupts with
    ! int, then you should review the documentation for those interrupts
    to see which registers they modify, to see if they need to have ! push
    performed. Then, at the end of the inline assembler code, use
    ! pop in the opposite order that you used for ! push.

    Inline assembler labels are used and named like PB BASIC labels.
    The difference is that you use inline assembler jump mnemonics
    to jump to them.

    Example:

    Code:
    FUNCTION MyFunction (MyArgument%) PUBLIC AS INTEGER
        ! push ds
        ! push si
        ! push ax
        ! lds si, MyArgument%
        ! mov ax, ds:[si]
        ! test ax, -1
        ! jz PEndIt
        'conditional jump condition not met, so put code here
        PEndIt:
        ! pop ax
        ! pop si
        ! pop ds
    END FUNCTION
    As far as BYREF & BYVAL, and FUNCTION returns, read your Users Manual.
    Those topics are too long for me to want to go into at 2:50 in the
    morning. Unless some other, more wide awake & alert, kind PBer can
    help Stephane out?



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

    Leave a comment:


  • Stephane Fonteyne
    started a topic Assembly with units in PBDOS

    Assembly with units in PBDOS

    Hey,

    1. Can you explean in an example how can I do this jmp to a label
    at the and of the function or sub?

    2. Witch registers do you pushed?

    3. When is it an BYREF of BYVAL parameter?

    4. When is it in the assembly code an return value?


    (1) NEVER use ret, retf, or retn to end a PB inline assembler
    function/sub! PB handles that stuff internally. If you have to
    end a PB inline assembler function or sub ahead of time, do a
    jmp to a label at the end of the function or sub.

    (2) You should ALWAYS use ! push at the beginning of your PB inline
    assembler function or sub to save the registers that your function or sub
    uses. Then, at the end of the ASM code, put in the ! pop lines to
    restore those registers to their original states. Make sure you put in
    the ! pop lines in the REVERSE order that you put in the ! push lines.



    ------------------
Working...
X