assemblydosx86-16a86

print a string on two different lines


I am trying to get my program to display a string on two different lines.

This is a .com program and I am using A86 assembler.

jmp start               ; This will start the program

;============================

  msg   db  "Hello Word.$"      ; A string variable 
  msg   db  "Michael J. Crawley$"   ; A string variable with a value.

;============================

start:

  mov ah,09             ; subfunction 9 output a string

  mov dx,offset msg         ; DX for the string

  int 21h               ; Output the message

  int 21h               ; Output the message

exit:

  mov ah,4ch
  mov al,00             ; Exit code 

  int 21h               ; End program

Solution

  • Here are your specific problems:

    The solutions to those points (without providing the actual code).


    Update: Since some other helpful soul has already provided source, here's my solution. I would suggest you learn from this and modify your own code to do a similar thing. If you copy it verbatim from a public site for classwork, you'll almost certainly be caught out for plagiarism:

             jmp start                   ; This will start the program
    
    msg      db  "Hello Word.",0a,"$"    ; A string variable .
    msg2     db  "Michael J. Crawley$"   ; A string variable with a value.
    
    start:   mov ah,09                   ; subfunction 9 output a string
             mov dx,offset msg           ; DX for the string
             int 21h                     ; Output the message
             mov dx,offset msg2          ; DX for the string
             int 21h                     ; Output the message
    exit:
             mov ah,4ch
             mov al,00                   ; Exit code 
             int 21h                     ; End program
    

    This outputs:

    Hello Word.
    Michael J. Crawley