No announcement yet.

int 21h service 40h

  • Filter
  • Time
  • Show
Clear All
new posts

  • int 21h service 40h

    i can do the simple stuff when i use asm code in my dos
    pb, but could someone help me with service 40h. like printing
    a letter to screen is ok: asm mov ah,2
    asm mov dl,&h45
    asm int &h21
    but when it comes to displaying a string to the display i'm
    i tried the following code but it's not correct.

    asm mov bx,&h0001
    asm mov cx,l%
    asm lea dx,m$
    asm mov ah,&h40
    asm int &h21

    could someone show me the right way to use int 21h service 40h?

    thank you.


  • #2
    Here's a variation you can play with - it uses a builtin PB DOS
    string function (if you are not using the latest PB/DOS 3.5 compiler
    (version 3.5), I do not know if this will work):

    M$ = "This is a test!"
    ! mov ax, M$
    ! push ax
    [b]! call GetStrLoc[/b]
    ' cx will already contain the length of the string
    ! mov ds, dx 'dx contains SEG for string
    ! mov dx, ax 'ax contains PTR for string
    ! mov ah, &h40
    ! mov bx, 1
    ! int &h21
    I am kind of rusty on the DOS ASM, but hopefully this will give
    you a starting point.



    • #3
      The PRINT statement writes directly into video memory, so it's pretty fast. Is there a specific reason you want to drop down to the DOS interrupt level to do this? Your ASM code might be fast, but PRINT will likely be faster.

      If an allowance for redirection is the main consideration, then use STDOUT instead (since that will be routed through DOS).

      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      mailto:[email protected]


      • #4
        thank you for the help. all i'm trying to do is learn how
        asm can be written using pb 3.5, but i'm having a terriable
        time understanding how asm and pb 3.5 inter mix. any advice
        on an easy first tutor for asm ? i'm interested in the bios
        and interrupts but every time i try , it seems i get a whole
        lots of error messages , but that's ok because the error
        messages are in a nice color to look at. once again thank you.



        • #5
          Hi Tim,

          I really got rolling with assembly only after I downloaded the a86
          assembler ( It's free, the documentation
          includes a simple tutorial, and it is still, I think, the best assembler
          ever made for the a86. It was much easier for me to learn assembly with
          this standalone assembler, and then learn how to interface assembly
          language with PB/DOS programs, then to try and learn assembly from within
          PB/DOS. YMMV...