News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

SymbOS C Compiler (v1.0 released)

Started by prevtenet, 22:14, 21 September 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

teopl

First, thanks again, this is great tool !!!

Now, I would like to try to port some of my C code used with sdcc compiler where I used inline asm.

I understood that there is no support for inline asm but that linking with .asm (or .s) should work.

Can someone write me the smallest possible example where I would have a function with 2 variables (each 2 bytes) written in assembler - which could be called from a C program as a C function?

(previously this was easy with inline asm and some push/pop for arguments)

btw, what is asm syntax used in scc?

prevtenet

The documentation on mixing asm/C is here; I think this probably has most of the examples you need.

The only difference with a two-parameter routine is that there will be two 16-bit values on the stack on entry to the routine instead of one, with the first parameter being on the top of the stack (after the return address, of course). The example gets these parameters with POP, but another good approach (that doesn't require cleaning up the stack afterwards) is set IX to the initial stack pointer, like:

.export _asmfunc
_asmfunc:
    ld ix,#0x00
    add ix,sp
    ld l,(ix+2) ; HL = first parameter
    ld h,(ix+3)
    ld e,(ix+4) ; DE = second parameter
    ld d,(ix+5)
    ; do something with HL, DE...
    ret

As you can see one major syntax difference from SDCC is using the (ix+2) format for index registers rather than 2(ix). SDCC's syntax is kind of weird, the syntax used by SCC is more standard (it seems pretty close to the Maxam-style syntax used by WinApe, without some of the more advanced features).

prevtenet

SCC v1.1 has been published on GitHub (link). Despite the small increment in version number, this is a major feature release focused on multimedia and compatibility with the forthcoming SymbOS 4.0.

Major new features:

  • A graphics library for game development, including a tool for converting images to graphics assets.
  • Cross-platform music and sound support (SymbOS 4.0+ only).
  • The floating-point library has been fixed (and now runs 2-5x faster than SDCC).
  • SymbOS .HLP files of the documentation.
  • Various other tweaks and bugfixes (register variables now work, faster core routines, etc.)

Check out the new graphics library in the new PDP-8 Emulator for SymbOS! (Although, that source code might not be the best example of how to use it in practice...)

Powered by SMFPacks Menu Editor Mod