1

For the past few months in my class we've been writing programs in Pep/9 in machine language, which made it easy to figure out which memory addresses need to be loaded and used to store data. I'd just write it on paper and count down the addresses like this. If its D1 FC 15 then

  1. D1
  2. FC
  3. 15

etc.

Now we're using assembly language where you assign it like:

LDBA 0x000D,d

Now I understand what this means but I do not understand how I'm supposed to figure out what memory address I store data when writing a program from scratch. How do I know to load it from 000D if I cant count down on paper the memory addresses? The memory dump doesn't give a clear answer. I just cannot grasp the concept of it for some reason and my textbook doesn't explain, its as if the answer is extremely basic that it'd assume I know.

Am I just supposed to count down like this? LDBA 0x000D,d

  1. 0x
  2. 00
  3. 0D

etc.

Because this doesn't seem right nor does it workout.

Or am I supposed to write the program in machine language to figure out the memory addresses, then translate to assembly and assign it like that?

1 Answers1

2

In assembly language, we generally use labels for addresses.

Labels are simple identifiers, like hello.

To define a label, usually the identifier is placed at the very beginning of the line, and in some assemblers, is followed by a comma or colon.  Most assemblers will allow a label alone on the line (but some don't they still want an instruction on that line).

hello:                 # label definition
       ldba hello,d    # label usage

Labels apply to code locations, and these would generally be the target of branch/jump/call instructions.  Labels also apply to data locations and these would generally be the target of load and store instructions and input/output instructions, (e.g.stro for printing strings, deci for input numbers, etc..).

The point of labels is to let the assembler do the counting of addresses, and so you can insert/remove code or data without manually recalculating addresses.

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53