Assembly language

I am very new. I am sure it is very simple, but I have done it many times. I am trying to get my program to display a line on two different lines. This is a .com program, and I am using the A86 compiler. This is for HW, and I'm not trying to cheat or anything like that, because I really want to know what I'm doing wrong.

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
+2
source share
3 answers

Here are your specific issues:

  • You specify msgtwice (a86 will be barf on this).
  • You call int21 fn9 with the same msg value so that you do not print two messages, but only two copies of the first.
  • You do not have a newline character in any message so that they abut against each other, rather than on separate lines.

( ).

  • msg2.
  • msg2 dx int21 .
  • , '$' (, , ).

: - , . , . , :

         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

:

Hello Word.
Michael J. Crawley
+3

msg?

+1

I am not familiar with a86, but with NASM and MASM you need the assembler directive "org 100h" at the beginning of the com program. The way it is now, the msg offset is 0x2, and it will try to print from the second byte of the program segment prefix (a 16-bit word that contains the upper memory segment available to you).

0
source

Source: https://habr.com/ru/post/1530821/


All Articles