News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

A silly asm question

Started by menegator, 12:18, 16 October 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

menegator

Hello,

It's really a silly question that i had for many years but not bothered to ask, but as they say, better late than never.

The org directive is petty straightforward. So is the run but:

       
  • If the execution address is different from the origin how do you calculate it beforehand ?
  • What is the necessity of having different execution address from the origin?
I recall there was a binary (boulder dash iirc) with origin at #256 and execution at #259 and for the life of me i couldn't figure out why.

robcfg

You may have a binary file with some data followed by some code, so the load address would be the start of the data and the exec address the one for the code.


You may for example male a single binary file that has a loading screen and some code, so you would only issue a run command and display your screen with the code loading and running afterwards.

menegator

#2
I understand the existence of these use cases, what i don't understand is the necessity, that is what is the benefit programming wise.

Additionally does the "run" directive accept a label as argument? If yes then this is the answer to my second question. If no, how it is calculated beforehand by the programmer?

robcfg


I think you're mixing two different questions.


The RUN command accepts a file name. Now, files saved to tape or disk are added a header than contains the load and exec addresses, so when loaded or run, the file will be loaded at the load address.


Computing the exec address is up to the programmer. Some assemblers can compute it based on labels. You specify both addresses when saving the file to tape or disk.


menegator

#4
The run directive on assembler to my knowledge accepts an address, like org does.

ORG #8000
RUN #9000

Is this not correct ?

This, also to my knowledge, will produce if save is used, a binary with loading address #8000 and execution address #9000

Does run also accept label?

robcfg

Ok, I was talking about the RUN" command from basic.


The Org directive tells the assembler which would be the load address for the generated binary file so it compute the addresses for the jump and branch instructions. Maybe the Run directive tells the assembler the exec address so it can inject the binary into a tape or disk image.


Regarding label support, depends on the assembler you're using.

Powered by SMFPacks Menu Editor Mod