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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
User avatar
osdevkid
Member
Member
Posts: 72
Joined: Sun Nov 21, 2010 11:15 am
Location: India, Chennai

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

Post 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?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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

Post by JamesM »

I think the answer lies in the ill-found assumption in your question.

Use labels.
User avatar
osdevkid
Member
Member
Posts: 72
Joined: Sun Nov 21, 2010 11:15 am
Location: India, Chennai

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

Post 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.
Dulci
Posts: 17
Joined: Tue Oct 05, 2010 4:34 pm

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

Post 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?
User avatar
osdevkid
Member
Member
Posts: 72
Joined: Sun Nov 21, 2010 11:15 am
Location: India, Chennai

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

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

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

Post by Solar »

Accessing the data in the data segment is done by using labels.

Use labels.
Every good solution is obvious once you've found it.
Locked