BBC BASIC
« O% under w32/w64 »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 4:59pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: O% under w32/w64  (Read 331 times)
pez
New Member
Image


member is offline

Avatar




Homepage PM


Posts: 4
xx Re: O% under w32/w64
« Reply #5 on: Sep 28th, 2017, 11:45am »

Dear Mr. Russell,

I had to look for the source of this confusion of mine, and I think that I located it in the common part of the following two, slightly different, phrases - from the session "Reserving Memory" in both Assembler versions:

Basic86 Manual : "Machine code instructions are assembled as if they were going to be placed in memory at the addresses specified by the program counter, P%. Their actual location in memory may be determined by O% depending on the OPTion specified (see below)."

BBC BASIC for Windows Help : "Machine code instructions are assembled as if they were going to be placed in memory at the addresses specified by the program counter, P%. Their actual location in memory is determined by P% or O% depending on the value of OPT used."

from which I erroneously concluded that, since O% is the only one, from P% and O%, which is mentioned in both versions, then O% definitely points to actual, that is "absolute" for me, locations.

Thank you for reading all that.

Sincerely yours,

Petros Zimourtopoulos
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 691
xx Re: O% under w32/w64
« Reply #6 on: Sep 28th, 2017, 1:08pm »

on Sep 28th, 2017, 11:45am, pez wrote:
I erroneously concluded that, since O% is the only one, from P% and O%, which is mentioned in both versions, then O% definitely points to actual, that is "absolute" for me, locations.

Actually both O% and P% are mentioned in both versions (P% at the end of the first sentence, O% in the second sentence). No doubt the change from the older version to the newer one was supposed to make it clearer, but it may not have succeeded.

The historical context is that in early versions of BBC BASIC (for example the original 6502 and Z80 versions) P% determined both where the code was stored in memory and where it would ultimately be executed. There was no provision for these to be different, and neither O% nor bit 2 of OPT were used by the assembler.

This is still by far the most common mode of operation, since the assembler is normally used to generate code that will be executed at run time by the same program. The ability to store the code at a different address (O%) from that at which it will be executed (P%) was added to support two main usage cases:
  • Assembling code that will eventually be programmed into a ROM or other non-volatile read-only storage device.

  • Assembling code which be copied into, and executed in, the address space of another process.
In either case the eventual execution address must be known at assemble-time. The BBC BASIC assembler does not have the capability, that virtually all standalone assemblers do, of outputting 'relocatable' object code that can be automatically adjusted (by a linker or loader program) to execute at any address.

Of course it is possible to use any assembler, including BBC BASIC's assembler, to create 'position independent code' (PIC) that will run at any address without modification. But there is an overhead in creating such code (more so in the case of 32-bit x86 than ARM, since the former doesn't support PC-relative addressing).

Richard.
« Last Edit: Sep 28th, 2017, 1:15pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls