P
P
Ponteley2021-08-10 17:47:24
assembler
Ponteley, 2021-08-10 17:47:24

Why is this program not working?

Masm ms-dos. The program should output the input string. The line output interrupt does not work, although the ah and dx registers contain the correct values.

assume cs:codeseg, ds:codeseg

codeseg segment
start:
main proc
  xor dx, dx
  mov ax, codeseg
  mov ds, ax

  call input
  call output

  jmp end_prog
main endp

input proc
  mov ah, 0ah
  lea dx, bufer
  int 21h

  ret
input endp

output proc
  ; добавить знак доллара в конец строки
  xor bx, bx
  mov bl, byte ptr [len]
  lea si, [text + bx]
  mov byte ptr [si], 24h

  ; вывод строки
  mov ah, 09h
  lea dx, text
  int 21h

  ret
output endp

end_prog:
  mov ah, 4ch
  int 21h

bufer label byte
max db 20
len db 00
text db 32 dup(0)
codeseg ends
end start

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-08-11
@Ponteley

Why is this program not working?

She actually works. It's just that the output falls exactly on the input line, which makes it unclear what happened. With this change, you will see what works:
...
  call input
  mov dl, 0ah
  mov ah, 2
  int 21h
  call output
  ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question