Reputation: 21
I'm trying to load a variable in assembly from user input. The variable appears to be stored correctly, but the output behaves strangely. When printing 3 variables that I filled with buffered input they are all printed on the same place.
For example if I input these variables:
strA = 'aaaaa'
strB = 'bbb'
strC = 'c'
I get this output:
cbbaa
Instead of this output:
aaaaabbbc
I have defined these variables in data segment:
strA_prompt 'Enter string A: $'
strA_buffer_args db 32, 0
strA db 32 DUP('$')
strB_prompt 'Enter string B: $'
strB_buffer_args db 32, 0
strB db 32 DUP('$')
strC_prompt 'Enter string C: $'
strC_buffer_args db 32, 0
strC db 32 DUP('$')
This is the relevant code segment:
; READ INPUT
mov dx, offset strA_prompt
mov ah, 9
int 21h
mov dx, offset strA_buffer_args
mov ah, 0ah
int 21h
mov ah, 2
mov dl, 10
int 21h
mov dx, offset strB_prompt
mov ah, 9
int 21h
mov dx, offset strB_buffer_args
mov ah, 0ah
int 21h
mov ah, 2
mov dl, 10
int 21h
mov dx, offset strC_prompt
mov ah, 9
int 21h
mov dx, offset strC_buffer_args
mov ah, 0ah
int 21h
mov ah, 2
mov dl, 10
int 21h
; PRINT VARIABLES
mov ah, 9
mov dx, offset strA
int 21h
mov dx, offset strB
int 21h
mov dx, offset strC
int 21h
What am I doing incorrectly? How do I make them print next to each other as they normally should?
Upvotes: 0
Views: 44
Reputation: 21
When calling buffered input, used string gets carriage return (ASCII 13) at the end. I just had to replace it with '$'.
Upvotes: 1