Page 1 of 1

NASM => how to access data defined without label...

Posted: Sun Nov 21, 2010 1:00 pm
by osdevkid
Hi all,

In the below NASM code, I am defining data section without lables.

Code: Select all

SECTION .data
         db 0xAB
         db 0xCD
         db 0xEF

SECTION .text
         mov ax, 0xAB
         mov ax, 0xCD
         mov ax, 0xEF
In the above code I want to access data "0xAB 0xCD 0xEF" from "data segment" in code segment. How to do it?

Re: NASM => how to access data defined without label...

Posted: Sun Nov 21, 2010 1:06 pm
by JamesM
I think the answer lies in the ill-found assumption in your question.

Use labels.

Re: NASM => how to access data defined without label...

Posted: Sun Nov 21, 2010 1:22 pm
by osdevkid
JamesM wrote:I think the answer lies in the ill-found assumption in your question.

Use labels.
Hi my favourite JamesM,

Can you explain little bit more, I am not understand.

Thanks in advance.

Re: NASM => how to access data defined without label...

Posted: Sun Nov 21, 2010 1:26 pm
by Dulci
When you have important data, you should have labels. It makes your code more readable, and easier to write. So why do you want to access this data without labels?

Re: NASM => how to access data defined without label...

Posted: Sun Nov 21, 2010 1:29 pm
by osdevkid
Dulci wrote:When you have important data, you should have labels. It makes your code more readable, and easier to write. So why do you want to access this data without labels?
The reason is simple.
1. I want to learn how to aceess those data segment values, without labels.
2. In which case, it is useful to declare such datas without lables.

Re: NASM => how to access data defined without label...

Posted: Mon Nov 22, 2010 1:25 am
by Solar
Accessing the data in the data segment is done by using labels.

Use labels.