Welcome, Guest. Please login or register.


Author Topic: Easy relocatable code in basic (Read 22273 times)

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Easy relocatable code in basic
« Reply #30 on: 2018.May.03. 12:33:54 »

But... did you know that Hisoft Devpac will create relocatable modules? And it automatically knows which values are addresses and which aren't. I used it several times successfully to create relocatable modules.

Then, maybe Devpac was the application used to make those classic relocatable programs.

Offline dangerman

  • EP fan
  • *
  • Posts: 100
Re: Easy relocatable code in basic
« Reply #31 on: 2018.May.03. 18:39:57 »
Then, maybe Devpac was the application used to make those classic relocatable programs.

Yes... I don't know for sure but I always assumed that they were written in Devpac. I think in the early days Devpac was the only assembler available, although ASMON appears to have been around in late summer 1986 (according to the IEUG magazines).


Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Easy relocatable code in basic
« Reply #32 on: 2018.May.08. 11:13:26 »
By the way... Does anyone have the English manual? Thanks


Google translated Magyar is very hard for me....

It is not a bad translation, but Google also translates the commands. For example, on some part of the text:

Quote
Az
     A,, <ENTER>
parancs (az editorból kiadva) általában elegendő a fordításhoz; ez a forrást assembly lista nélkül fogja fordítani.
 

Is translated as:

Quote
The
The "<ENTER>
command (issued from the editor) is generally sufficient for translation; this source will be translated without assembly list.


Then, I have to read constantly the original to see what is the real syntax of the command.
« Last Edit: 2018.May.08. 11:36:30 by gflorez »

Online Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14776
  • Country: hu
    • http://enterprise.iko.hu/
Re: Easy relocatable code in basic
« Reply #33 on: 2018.May.08. 11:37:13 »
By the way... Does anyone have the English manual? Thanks
I have :-) Forgot to scan it :oops:

[ Guests cannot view attachments ]

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Easy relocatable code in basic
« Reply #34 on: 2018.May.08. 12:42:14 »
And, the original Hisoft Pascal manual?

By the way... I have found this resemble of David Link and Dave Nutkins, founders of HISOFT:

Quote
HiSOFT has been in existence since 1980, founded by David Link and Dave Nutkins. Originally we created software for the NASCOM 1 kit-built microcomputer but swiftly moved on to the ZX Spectrum, for which we created many esoteric items such as HiSOFT Devpac, HiSOFT C, HiSOFT BASIC, HiSOFT Pascal, UltraKit, Colt and much more.

After great success with the various incarnations of the Spectrum we ported our core titles (Devpac, C++ and Pascal) to many other Z80-based computers; Tatung Einstein, Newbrain, Memotech 512, Amstrad CPC& PCW, Elan Enterprise and more! 'Twas a lot of fun and, undoubtedly, this list will stir as much excitement in some people as David's favourite band since 1971, Genesis, do in him!

After the Z80 processor began to flag (shame!), we moved on to the 68000 which meant moving stuff over to the Atari ST and Commodore Amiga. This, along with many hardware projects (such as Megalosound, Replay 16, Clarity 16, Squirrel SCSI, VideoMaster etc.) kept us going through the 90s until, reluctantly, we were forced to take the PC seriously.

Having forged a close relationship with MAXON Computer in Germany throughout the Amiga and Atari years, it was natural for us to take on the UK mantle for their flagship product, CINEMA 4D, an exciting and now rather important 3D product. HiSOFT promoted, distributed and sold CINEMA 4D from 1997 until 2001, at which point David Link formed MAXON Computer Ltd and moved all things CINEMA 4D under the MAXON umbrella.

David worked at MAXON UK as the CEO until resigning for personal reasons in early 2003, after which he ran a successful pub and café with his partner, without whom it would not have been possible.

David now designs and maintains websites while owning and running a busy pub/guest house in Shanklin, Isle of Wight.
« Last Edit: 2018.May.08. 13:32:18 by gflorez »

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Easy relocatable code in basic
« Reply #35 on: 2020.February.17. 01:27:46 »
I would like to return to this topic, now that I am about to begin to transcript the FisherTechnick CPC Basic listings to IS-BASIC.


Let's say that we can make a mixed Basic-MachineCode program on the Enterprise.

One of the most valuables tools to make a subroutine aware of its position is to pass it its own start address. This method was hinted to me some time ago by Zozo:

If the machine code subroutine has been defined with MC=HEX$("XX,XX,...") then, we can use CALL USR(MC,MC) to pass its start point  on the HL register pair. The only drawback is that we lose the option to pass data to the subroutine.

This would be convenient on short routines with a few jumps/calls or fixed positions. But the problems multiply with long code, all the juicy options of the Z80 involve absolute addressing, and it can be a problem to repositioning all the jumps and calls inside a big program.

A solution that I have found is one that has been there all the time: WORD$.

Imagine we have written a MC subroutine to print a text on the screen, for example:

Code: [Select]
start: ld a, 0        ;Channel to write
ld bc, 5       ;Length of the string
ld de, STRING  ;Adress of the string
EXOS 8              ;Write block
ret
STRING:   db "Hello"


The Basic program would look like this:

100 ALLOCATE  16
110 CODE TEXTO=HEX$("3E,00,01,05,00,11,XX,XX,F7,08,C9,48,65,6C,6C,6F")
120 CALL USR(TEXTO,0)

But this routine will not work, because we need to give DE the absolute address of the string, which we don't know.... but we already know it, if we modify the line 110:

110 CODE TEXTO=HEX$("3E,00,01,05,00,11")&WORD$(TEXTO+11)&HEX$("F7,08,C9,48,65,6C,6C,6F")

TEXTO is already defined at the start of the line, so when the execution reaches "WORD$(TEXTO+11)" it doesn't give "*** Variable not initialised."

[ Guests cannot view attachments ]

Please don't laugh too hard at me if this is common knowledge....
« Last Edit: 2020.February.17. 01:59:39 by gflorez »

Online Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14776
  • Country: hu
    • http://enterprise.iko.hu/
Re: Easy relocatable code in basic
« Reply #36 on: 2020.February.17. 02:11:36 »
For these problems developed the EXOS header 02, User relocatable modules function.
Just need to allocate memory for it, and load it to the allocated buffer. During the loading the EXOS recalculate the direct addresses to valid address for the current loading location.

Look about IstvanV's SJasmEP project, if I remember right he added support of these.

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Easy relocatable code in basic
« Reply #37 on: 2020.February.17. 14:10:50 »
Yes, thanks, IstvanV did a good work on this same thread.

I mean, the WORD$ function has been underused(by me) and it seems that this is the real task(inserted in a CODE definition) for which it was created.

Not so long ago I discovered another use, to extract the 2 bytes of 16bit numbers:






Offline elmer

  • EP fan
  • *
  • Posts: 196
  • Country: us
Re: Easy relocatable code in basic
« Reply #38 on: 2021.January.02. 19:28:23 »
Simple program to create EXOS module type 7 (relocatable extension):
...
The input is raw machine code that is compiled at org 0000h, and the code is repeated twice. With sjasm, this is achieved by including the original source file from another file and using MODULE to avoid duplicate labels.

Thanks, that's a really clever idea!  :mrgreen:

I think that I'm going to have to steal that method.  ;-)


But... did you know that Hisoft Devpac will create relocatable modules? And it automatically knows which values are addresses and which aren't. I used it several times successfully to create relocatable modules.

Cool, I was wondering if there was any assembler that could create a relocatable module.

Good old Hisoft!  :cool:


Today I prefer Sjasm :-)

But of course, I agree with Zozosoft here, these days it is much easier to just build assembly-language programs on a PC, and then test them on ep128emu.

I'm finding that the virtual device feature in zOOm's SJASMPLUS is making it really easy to do some pretty serious modifications to IS-DOS.