Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing variable values! 1

Status
Not open for further replies.

notepad

Programmer
Sep 18, 2001
7
0
0
LK
Hi All!
I have a variable called key, defined as key db "A$".
inside the program i change its value to "B" and display, still i get the same initial value which is "A". Can somebody help please?, my prog is as follows:

DOSSEG
.MODEL SMALL
.STACK 200h
.data
key db "A$"
.CODE

START:
mov bx,offset key
mov byte ptr[bx],"B"
inc bx
mov byte ptr[bx],"$"

mov ax,seg key
mov ds,ax
mov ah,9
mov dx,offset key
int 21h

mov ax,4c00h int 21h

END START


 
This is prolly your problem:

The ff. two statements:
mov ax,seg key
mov ds,ax
should be BEFORE you replace "A" with "B".... Because ds isn't initialized yet....

Tell me if this fixed it... "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Dear AmkG!
It really worked, thank you very much.Can you explain why it really happens?

Thank you.
 
can you see this?

I've had a bit of trouble posting my comments that are not derogatory or bitter and twisted.

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"
 
It has to do with the fact that, when you start your program, ds is not aligned with your .data segment; this is NOT automatic and you HAVE to do this yourself. Since ds is not aligned with your .data segment, any data access you perform will, most probably, be outside the .data segment and hence you will not be accessing anything in .data... UNLESS you load ds BEFORE you do any data access. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top