How can I save the string I entered to use it again
I tried changing the value of A1,A2 for example:
A1 DB ?
and
A1 DB '$\'
.DATA
P1 DB 'Enter the First Strig : $\'
P2 DB 'Enter the Second character : $\'
L db 0ah,0dh,'$'
P3 DB ' the " $\'
P4 DB ' " and " $\'
P5 DB ' " is: $\'
FIRST_BASE db 255
SECOND_BASE db 255
A1 DB dup('$')
A2 DB dup('$')
.code
.model small
start:
mov ax,@data
mov ds,ax
printString P1
lea dx, FIRST_BASE
mov ah,0ah
int 21h
MOV A1,AH < --------- (!!!Here's the problem I can't save the string!!!)
printString L
printString P2
lea dx, SECOND_BASE
mov ah,0ah
MOV A2,AH < --------- (!!!Here's the problem I can't save the string!!!)
int 21h
printString L
for printing
(2)= Here he prints strange shapes and letters
printString P3
printString A1 <-----------(2)
printString P4
printString A2 <-----------(2)
printString P5
mov ax,ham_dist
I want it to look like this = the "(The string that I entered first) " and "(The string you entered second) " is:(Did not matter)
Lines like A1 DB ?
and A1 DB '$\'
don't reserve enough bytes to be of any use when it comes to storing a string.
FIRST_BASE db 255 SECOND_BASE db 255 A1 DB dup('$') A2 DB dup('$') ... lea dx, FIRST_BASE mov ah,0ah int 21h MOV A1,AH < --------- (!!!Here's the problem I can't save the string!!!)
This is not how you setup for this DOS function! Do those A1 and A2 lines even compile (without a numeric value in front of the dup
)? Also a line like MOV A1,AH
makes no sense; the AH
register still contains the function number 0Ah, hardly anything interesting.
You can read all about the DOS.BufferedInput function 0Ah in How buffered input works.
Since you need more than one string input, you could choose to setup 1 input buffer and copy the strings to their own private buffers, or you could setup 2 input buffers and leave the strings where they were inputted. I chose the latter:
FIRST_BASE db 80, 0, 80 dup (0)
SECOND_BASE db 80, 0, 80 dup (0)
...
lea dx, FIRST_BASE
mov ah, 0Ah
int 21h
...
And this is how you read the length of the inputted text:
mov bl, [FIRST_BASE + 1]
mov bh, 0
And this is how you make the inputted text $-terminated, ready for printing:
mov byte ptr [FIRST_BASE + 2 + bx], '$'
And this is how you print this:
lea dx, FIRST_BASE + 2
mov ah, 09h
int 21h