Author Topic: A silly asm question  (Read 230 times)

0 Members and 1 Guest are viewing this topic.

Offline menegator

  • CPC464
  • **
  • Posts: 22
  • Country: gr
    • index.php?action=treasury
  • Liked: 11
  • Likes Given: 278
A silly asm question
« on: 14:18, 16 October 19 »
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.
« Last Edit: 16:34, 16 October 19 by menegator »

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.235
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 992
  • Likes Given: 2278
Re: A silly asm question
« Reply #1 on: 18:03, 16 October 19 »
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.

Offline menegator

  • CPC464
  • **
  • Posts: 22
  • Country: gr
    • index.php?action=treasury
  • Liked: 11
  • Likes Given: 278
Re: A silly asm question
« Reply #2 on: 18:22, 16 October 19 »
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?
« Last Edit: 18:25, 16 October 19 by menegator »

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.235
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 992
  • Likes Given: 2278
Re: A silly asm question
« Reply #3 on: 20:22, 16 October 19 »

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.


Offline menegator

  • CPC464
  • **
  • Posts: 22
  • Country: gr
    • index.php?action=treasury
  • Liked: 11
  • Likes Given: 278
Re: A silly asm question
« Reply #4 on: 20:31, 16 October 19 »
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?
« Last Edit: 20:38, 16 October 19 by menegator »

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.235
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 992
  • Likes Given: 2278
Re: A silly asm question
« Reply #5 on: 21:20, 16 October 19 »
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.