2

I am really new to the assembly language(Started to learn just a couple of days ago). I am trying to figure out directives in assembly. As far as I understand, directives are like a variable declaration in high-level languages. For example, after the

AREA myData, DATA 

line, I need to initialize my variables and to start inserting instructions; I need to start with adding this line:

AREA myCode, CODE, READONLY

And if I want to declare more variables I need to write first line again. Please correct me if I am wrong.

My question is, what are the names 'myData' and 'myCode' really for? Do I need to use 'myData' name for accessing the variables declared at that part or does it contain some sort of address?

If it is a repeated question I am sorry. I searched but could not find any answer to that spesific question.

fuz
  • 88,405
  • 25
  • 200
  • 352
  • 1
    What assembler are you programming for? Did you have a look at the documentation for that assembler? – fuz Oct 30 '20 at 11:15
  • 1
    I am using ARM assembler on Keil MDK. I think the name is armasm. I searched for documents and some books but I could not find any usage on the names of those directives. – Ömer Bayram Demir Oct 30 '20 at 11:25
  • 1
    @ÖmerBayramDemir Here's [the documentation on the AREA directive](https://www.keil.com/support/man/docs/armasm/armasm_dom1361290002714.htm). Combined with this [overview document](https://www.keil.com/support/man/docs/armasm/armasm_dom1359731143697.htm), this should answer your question. – fuz Oct 30 '20 at 11:36
  • segments are specific to the tools, many different tools use similar or same names, often you see text, data and bss as the minimum text is the code, data is read/write data that is pre-initailized (as far as the high level language is concerned int x = 5; ) and bss which is read write data that is zeroed (as far as the high level language is concerned int z;). some may have code instead of text, etc. and some may have many more either created by the user in the linker script or by the tool (rodata for read only data for example) – old_timer Oct 30 '20 at 14:38
  • but very much tool specific as to what they are called and how to declare them – old_timer Oct 30 '20 at 14:39
  • the tools will then isolate the blobs of bytes into these segments so all code per object into one place all read/write bytes, etc.. then the linker based on the user's desire can then take those segments and they will ultimately land in the right places in memory for execution and the code/etc patched up to complete the links between items. – old_timer Oct 30 '20 at 14:52

0 Answers0