Looking for working assembler to compile SymbOS app.

Page 1/2
| 2

By NYYRIKKI

Enlighted (5556)

NYYRIKKI's picture

21-03-2020, 15:24

Hi,

I would like to develop some programs for SymbOS, but as pure MSX user I must say I'm really not a big fan of WinAPE emulator as a development environment for number of reasons including that I can't minimize or close the Amstrad emulator, there is no comment block, ";" does not necessarily comment out all of the line, I'm practically forced to use the embedded text editor etc. etc.

Now my question is: Is there any other Z80 assembler out there that could automatically generate me relocation tables that SymbOS executables are expected to include? If you don't get what I mean, this listing output probably should explain it self well enough:

000003  0000  (1000)        org #1000
000004  1000                relocate_start
000006  1000  21 07 10      	ld hl,test
000007  1003  11 08 10      	ld de,test2
000008  1006  C9            	ret
000010  1007  00            test	db 0
000011  1008  00            test2	db 0
000013  1009  02 00         	dw relocate_count
000014  100B  04 00         	dw relocate_size
000016  100D  01 10 04 10   relocate_table
000017  1011                relocate_end
Login or register to post comments

By sd_snatcher

Prophet (3296)

sd_snatcher's picture

21-03-2020, 15:33

Are those equivalent to the LINK-80 REL files?

I know there's a help request to implement support on sjasmplus. I'll keep following this thread to see if anything else shows up.

By NYYRIKKI

Enlighted (5556)

NYYRIKKI's picture

21-03-2020, 15:54

sd_snatcher wrote:

Are those equivalent to the LINK-80 REL files?

I took a quick look and I must say, I can't make head or tails what those REL-files include, but at least not the stuff that I need in correct format... This Macro assembler also feels quite oldish, the file output is CP/M, so the file sizes are fixed to 128 byte record size and so on... -> Causes more problems than solves.

By NYYRIKKI

Enlighted (5556)

NYYRIKKI's picture

21-03-2020, 18:29

sd_snatcher wrote:

I know there's a help request to implement support on sjasmplus. I'll keep following this thread to see if anything else shows up.

This is not quite a same thing, so I opened a new request:
https://github.com/z00m128/sjasmplus/issues/99

Let's see if that catches some attention... You don't know, if you don't ask. :)

By Ped7g

Rookie (19)

Ped7g's picture

13-07-2020, 23:39

sd_snatcher wrote:

Are those equivalent to the LINK-80 REL files?

Not even close. There are two parts to this request:

one part is the raw relocation table, that's just dump of `uint16_t` values marking offsets in the machine code which should be patched by the loader (this does allow to relocate only instructions working with 16bit values, so tricks like `ld h,high someLabel` will not get relocated). This becomes part of regular machine code output from assembler.

second part is SymbOS executable structure, putting such raw relocation table at expected place in binary and adding further meta data in header to make the OS aware how to load it and relocate it.

Neither of that involves object files or linking with WinAPE, the executable structure is generated manually from asm source by DB/DW statements, so the binary output from assembler is already final executable file.

I did take a look at Link-80 REL files before, but they seem very limited and I would need somebody actively using the tools to verify some edge-cases for me, what happens, as the format docs leave some room how to interpret some cases. So I stopped active work on that option. But that's off-topic here.

With regard to SymbOS binaries and WinAPE-like relocation support, the active work is now going on, I have about 30% of implementation done... if no disaster happens, the next release of sjasmplus should have enough support to build SymbOS executables with it.

By Ped7g

Rookie (19)

Ped7g's picture

26-07-2020, 20:16

NYYRIKKI wrote:

Now my question is: Is there any other Z80 assembler out there that could automatically generate me relocation tables that SymbOS executables are expected to include?

So the upcoming sjasmplus version (to be released in following days) does now support generation of relocate tables.

Not only that, but while verifying the functionality against two SymbOS app sources it turned out the WinAPE syntax is hugely compatible with sjasmplus (although where it differs, it will be kinda annoying, requires one change in system includes).

For example I tried to adjust "nslookup" app sources to make them compatible with the sjasmplus and this is the resulting diff-patch:

diff -Naur original/Cmd-NsLookUp-head.asm src/Cmd-NsLookUp-head.asm
--- original/Cmd-NsLookUp-head.asm	2016-01-10 02:47:36.000000000 +0100
+++ src/Cmd-NsLookUp-head.asm	2020-07-26 18:20:45.826682919 +0200
@@ -2,8 +2,8 @@
 
 org #1000
 
-write "e:\symbos\cmd\nslookup.com"
-READ "..\..\..\SVN-Main\trunk\SymbOS-Constants.asm"
+write "nslookup.com"
+READ <SymbOS-Constants.asm>
 
 relocate_start
 
@@ -109,9 +109,9 @@
 use_SyNet_DNSRSV        equ 1   ;DNS resolve
 use_SyNet_DNSVFY        equ 1   ;DNS verify
 
-READ "..\..\..\SVN-Main\trunk\Docs-Developer\symbos_lib-SymShell.asm"
-READ "..\..\..\SVN-Main\trunk\Docs-Developer\symbos_lib-SystemManager.asm"
-READ "..\..\..\SVN-Main\trunk\Docs-Developer\symbos_lib-NetworkDaemon.asm"
+READ <symbos_lib-SymShell.asm>
+READ <symbos_lib-SystemManager.asm>
+READ <symbos_lib-NetworkDaemon.asm>
 READ "Cmd-NsLookUp.asm"
 
 App_EndTrns
diff -Naur original/SymbOS-Constants.asm src/SymbOS-Constants.asm
--- original/SymbOS-Constants.asm	2020-07-12 20:18:54.220609176 +0200
+++ src/SymbOS-Constants.asm	2020-07-26 18:07:23.721888233 +0200
@@ -91,7 +91,7 @@
 MSC_DSK_MENCTX  equ 52  ;opens context menu (P1=ram bank, P2/3=address data record, P4/5=Xbeg [-1=mouse position], P6/7=Ybeg) ##!!## doc+lib
 MSC_DSK_STIADD  equ 53  ;adds systray-icon (P1=ram bank, P2/3=address, P4=ID)
 MSC_DSK_STIREM  equ 54  ;removes systray-icon (P1=number)
-    MSC_DSK_STIUPD  equ 55  ;updates systray-icon (P1=number)
+MSC_DSK_STIUPD  equ 55  ;updates systray-icon (P1=number)
 MSC_DSK_CONPOS  equ 56  ;move a virtual control to a new position (P2/3=xpos, P4/5=ypos, P6/7=xlen, P8/9=ylen)
 
 ;Desktop Manager Responses

So I had to convert WRITE/READ directives to sjasmplus OUTPUT/INCLUDE, fix the file paths to work well on my local box + Continuous Integration servers when testing builds, and remove one whitespace in SymbOS-Constants.asm file, to get identical "nslookup.com" file.

The "notepad" app did require few more changes, but still in similar scope, all of them very easy for me who has sjasmplus experience, but should be workable by new users if they study my tests and examples to see what I did modify in the original sources.

I guess there are probably some other SymbOS apps which would require more effort and code changes to make them sjasmplus buildable, also I'm not sure if it's feasible to support both WinAPE and sjasmplus with the main project (although I guess that may be an option, if all contributors would support that and follow the syntax rules to write only code compatible for both assemblers), so this is not promising "it will work, it's easy".

But the initial results looks better than I expected, if the SymbOS community is ever interested to switch from WinAPE, I can help with the migration of this (small-ish) scope easily.

(if the decision would be on me, I would drop WinAPE completely, because I would not stand the `db #dd : ld h,a`, sorry, that's just lame. Big smile (or I would fix the WinAPE instead, although I think it's not open source? If not, then that would be for me another red flag and reason to migrate ASAP and completely) - but I'm not part of SymbOS community .. although while working on this, it seems like there's some possibility to port SymbOS to ZX Spectrum Next. Obviously it would be very likely lot of work, and I'm not going to commit to such thing in following months, but maybe in couple of years, it may be fun project).

EDIT: oh, I forgot, the patch may seem really minimal... too minimal, right? There's "preamble" piece of code masking some other sjasmplus differences, making WinAPE source valid:

; define substitutions for directives which have different name in WinAPE
    DEFINE write OUTPUT
    DEFINE READ INCLUDE
    DEFINE nolist OPT listoff

; reconfigure the sjasmplus to a bit stricter syntax with extra warnings
; and enable directives at the beginning of the line (--dirbol)
    OPT --syntax=abfw --dirbol

; include original "head" file which will produce the com file
    INCLUDE "src/Cmd-NsLookUp-head.asm"

By Ped7g

Rookie (19)

Ped7g's picture

27-07-2020, 16:59

sjasmplus v1.16.0 is out:
https://github.com/z00m128/sjasmplus/releases/tag/v1.16.0

(get also the full source package or clone the github to have also the SymbOS apps conversion examples, the "nslookup" is in the regular examples folder, the "notepad" is in tests/integration ... the win-zip contains only the regular ZX48 relocation example done by me)

By NYYRIKKI

Enlighted (5556)

NYYRIKKI's picture

27-07-2020, 17:40

Thank you sir! Just what the doctor ordered. Smile
I was just saying today, I hope there was Windows binaries and now you saved my day.

By NYYRIKKI

Enlighted (5556)

NYYRIKKI's picture

27-07-2020, 18:02

Ped7g wrote:

(if the decision would be on me, I would drop WinAPE completely, because I would not stand the `db #dd : ld h,a`, sorry, that's just lame. Big smile

Actually that limitation must be some ancient history or a quirk in Prodatron's thinking. I see no problem of using syntax like IXh and IXl on WinAPE.

By pgimeno

Master (191)

pgimeno's picture

27-07-2020, 19:44

Traditionally this has been the job of the linker. The assembler produces relocatable objects, and the linker produces the final executable from these objects. In this case the relocatable files would be .REL (or .o files if using GNU binutils). Then you link these .rel files into an executable in any format supported by the linker. So I think that the assembler should produce .rel, and work should go into a linker that supports linking .rel files into SymbOS executables.

Producing the different executable formats directly from the assembler sounds a bit ass-backwards to me.

By Ped7g

Rookie (19)

Ped7g's picture

28-07-2020, 09:26

phimeno: basically yes.

Except SymbOS executables are one step beyond that, being PIE, so the relocation data are still part of the executable for runtime relocation (but that doesn't mean they can't be linked together first from independent object files and patch+collect the object file relocation data into big executable relocation data by some linker).

For fixed executables it would be enough to handle this by linker and just produce final machine code without relocation data.

(so my objection to your comment is to make these two use cases sound as totally equal, they are slightly different and not mutually exclusive)

About support of .rel/.o files by sjasmplus. The current issue is that I'm not aware of any object file format (usable by some linker). There was suggestion to support original REL files used by L80 linker, but I was unable to figure out the file format (the docs don't cover corner-case values and I'm too lazy to try to run the original SW by myself to see what it actually does in those corner cases). And also those are horribly limited (to the point I personally find them unusable with my style of assembly).

If I'm understanding the gossips right, the GNU binutils recently added Z80 as target? If somebody would hold my hand and show me precisely what's the binary format of the object file, I guess there's some chance to produce such object files with sjasmplus, especially now with the internal mechanics of detecting relocatable data. But it would take probably another couple of weeks of development, and the GNU folks tend to prefer their own as, often with non-vendor machine-like syntax (like the "AT&T" syntax for x86, which still triggers me a lot), and the linker is probably producing ELF executables, not related to any targets the sjasmplus does focus (ZX Spectrum machines mostly).

So I guess support of GNU .o files would be nice, but not used by any one? ... the SymbOS-like relocation data generator was directly asked for by NYYRIKKI, so that may end up used at least once (also I did example with my own relocator code for ZX48, which can be used by non-SymbOS projects - if they want runtime relocation - may be interesting for things like editors/assemblers to make their memory position configurable).

Whatever it sounds to you Tongue ... in the end it's about whether somebody is using it for their project or not. Do you have some project which you would like to use sjasmplus for its assembling, and you are missing some feature? Let me know about it, and I may decide I like your project enough to put my hours into extending sjasmplus further. If you have no such project, and you have just opinion about executable formats, then I acknowledge it, and even agree with it, but that's all it is, opinion discussion. Smile

Page 1/2
| 2