ideal
model small
stack 1024
dataseg
array1 db 11 dup(?)
codeseg
org 100h
PROC MAIN
CALL GETINPUT
CALL PRINTARRAY
EXIT:
mov ah, 4ch
int 21h
ENDP
PROC PRINTARRAY
lea dx, [array1]
mov ah, 9
int 21h
ret
ENDP
PROC GETINPUT
mov bx, offset array1
GET:
CALL GETCHAR
cmp al, '.'
je ENDGET
mov [array1+bx], al
inc bx
cmp bx, 10
jge ENDGET
CALL PRINTSPACE
jmp GET
ENDGET:
mov [array1+bx], '$'
ret
ENDP
PROC GETCHAR
mov ah, 1
int 21h
ret
ENDP
PROC PRINTSPACE
mov dl, ' '
mov ah, 2
int 21h
ret
ENDP
PROC PRINTCHAR
mov ah, 2
int 21h
ret
ENDP
END MAIN
Im getting an NTVDM error cs:0423 ip:0125 when adding '$'. without the sentinel i can't print the array without garbage and other characters in it. :( i dont know if its because of my OS, windows 7 32bit, or assembler. please help me. :(
Look at these two instructions:
Doesn't it look odd to you that you take the address of
array1
and then add it to itself inarray1+bx
?