I just read a tutorial on writting "hello world" app in asm but I am confused on this code
Code:mov ax, SEG msg
mov ds, ax
Why can't I directly put the segment of msg into ds instead of copying it first to ax and then retrieving it in ds?
Printable View
I just read a tutorial on writting "hello world" app in asm but I am confused on this code
Code:mov ax, SEG msg
mov ds, ax
Why can't I directly put the segment of msg into ds instead of copying it first to ax and then retrieving it in ds?
Ok, DS stands for DATA SEGMENT. It's a pointer. It's not the Accumilator like AX is. You can tell the pointer to point to something else, but it's not a DIRECT RECIEVER of instructions.
This is how it works.. You tell AX where the message is at. Then AX tells DS - "Ok cheif, when the message is accessed, you are to POINT to that position. But ONLY when your called." So DS understands that and when there is a string to be fed, it then points to the DATA (OR STRING INFO) that you have.
Hence, this is why you MUST declare WHERE your data is by saying things like :
message DB "Your string here"
The word "message" can be anything you want. Even a memory address like 07C0h. It's just a label that DS will point too. The DB means a DATA BYTE. So when DS points to it, it will READ only 1 BYTE of DATA at a time.
Hope this helps...
In other words, you just can't.
Hahaha... I could have said it that simply, but I felt he wanted an explanation.. :)
Knight
Thanks knight:p
Now asm programming is more harder because it is not happening what I expected:mad:
Yea, I remember when I was just learning this too. Man I didn't realize how used to HLL's I was. (HLL - High Level Languages. ASM is a Low Level Language)
When I realized that I could have to create my own routines at first I was like, "No way am I going to get this.. err.." But after a while I started to SLOWLY make my own routines. And as I made more of them my life became easier. So now, I am learning how to REPLACE all of MS's INT numbers. ;)
I still have a long way to go, but i'm getting there.. :)