DEFFNder: a small library of BASIC functions written in Z80

I've published a small library of 15 Sinclair BASIC functions written in Z80. I wrote it last year for a project of mine. Some of them are generic, some are very specific for the project, mainly to manipulate strings and data.

I include the fully commented sources and the compiled code, ready to use (in TAP, DSK and MGT files); usage and compile instructions are included as well.

It's called DEFFNder:

http://programandala.net/en.program.deffnder.html

I hope it's useful to somebody. Any feedback will be appreciated.
Marcos Cruz (programandala.net)

Comments

  • edited August 2015
    Nice work, I wrote a quick demo program using pasmo and zmakebas 1.5
    which is available here.

    The assembly language code will compile in both pasmo and zasm assemblers.

    A couple of the DEF FN example calls in the documentation are not correct e.g. lookup16, lookup8 so they are
    slightly different in the demo source.

    Regards,
    Derek.
    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.7 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 14.0.1 Apple TV Gen 2
    Thanked by 1programandala.net
  • dbolli wrote: »
    I wrote a quick demo program using pasmo and zmakebas 1.5
    The assembly language code will compile in both pasmo and zasm assemblers.

    Thank you! It's great. I've published it in the download section of the DEFFNder web page.
    dbolli wrote: »
    A couple of the DEF FN example calls in the documentation are not correct e.g. lookup16, lookup8 so they are
    slightly different in the demo source.

    I see, the usage example of both lookup functions was wrong:
       10 DEF FN f(h$,k)="" USR lookup16
    

    Instead of:
       10 DEF FN f(h$,k)=USR lookup16
    

    Thank you. I fixed them and updated the package.
    Marcos Cruz (programandala.net)
  • edited December 2015
    Hi Marcos,

    I've written a couple of extensions to DEFFNder to implement 16 bit AND, OR and XOR bitwise functions and also
    string functions to return 8 bit values as binary and hex strings.

    The source for the additional modules is available here
    Just unzip and copy the .z80s files into /Path/To/deffnder/src and re-run
    make clean
    make
    make dsk
    

    The demo program has been updated and can be found here.
    Just unzip and copy the files into /Path/To/deffnder/demo
    It now loads the code for the routines at $F000 rather than $8000 in the previous demo version.
    Original demo can be found here.

    Regards,
    Derek.
    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.7 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 14.0.1 Apple TV Gen 2
    Thanked by 1programandala.net
  • dbolli wrote: »
    I've written a couple of extensions to DEFFNder to implement 16 bit AND, OR and XOR bitwise functions and also
    string functions to return 8 bit values as binary and hex strings.

    That's great, thank you, Derek.

    I will update the whole package. Beside, I will put DEFFNder on my GitHub account in order to make it easier to co-operate and update.

    I've tried the new demo, but it seems the "PEEKs and POKEs" test fails on 128 machines (on Fuse). After printing "This is a rather long string", some screen attributes are corrupted and the system freezes. I've tried the previous demo and it fails too, what is strange, because I always run Spectrum 128 by default, and I think it worked months ago. Maybe it has something to do with my current configuration, but I don't understand what exactly yet. There's no problem on Spectrum 48. I'll do more tests. Does it work for you on 128 models?
    Marcos Cruz (programandala.net)
  • Whoops. My fault on the demo crashing on 128K.
    Well spotted.

    I was using $5B00 as temp string storage which is printer buffer on 48K but is extra System Variables on 128K and caused a crash.
    I now use the DEFFNder code buffer as temporary string storage for that part of the demo.

    Demo package has been updated here.

    I will also investigate the github repository.

    Regards,
    Derek.
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.7 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 14.0.1 Apple TV Gen 2
  • I have updated the package and the web page, and created a repository in GitHub. I integrated your functions with the rest of the sources, but included the demo as-is, in its zip archive. See:

    DEFFNder web page
    DEFNder in GitHub
    Marcos Cruz (programandala.net)
    Thanked by 1dbolli
  • Hello,

    the makefile failed for me.
    maybe opensuse has different standards
    pasmo is in : usr/local/bin/
    wich is in my PATH
    ch@linux-4xd4:~/Downloads/deffnder> sudo make mgt
    cd src ; \
    for source in $(ls -1 fn_*.z80s) ; do \
      		base_name=${source%%.z80s} ; \
    	echo "Compiling $source" ; \
    	pasmo --tap --name $base_name $source ../bin/$base_name.tap ../bin/$base_name.symbols.z80s ; \
    done ; \
    cd - ; \
    cat bin/fn_*.tap > bin/deffnder.tap
    Compiling fn_band16.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_bor16.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_bxor16.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_dispbin.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_disphex.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_dpeek.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_dpoke.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_instr1.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_instr.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_lookup16.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_lookup8.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_peekcs.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_peeko.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_peeks.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_pokeo.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_pokes.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_string.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_termn.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_term.z80s
    /bin/sh: line 4: pasmo: command not found
    Compiling fn_trunc.z80s
    /bin/sh: line 4: pasmo: command not found
    /home/ch/Downloads/deffnder
    mkmgt bin/deffnder.mgt sys/gplusdos-sys-2a.tap bin/deffnder.tap
    make: mkmgt: Command not found
    Makefile:101: recipe for target 'mgt' failed
    make: *** [mgt] Error 127
    ch@linux-4xd4:~/Downloads/deffnder> 
    
    
    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • Crisis wrote: »
    the makefile failed for me.
    maybe opensuse has different standards
    pasmo is in : usr/local/bin/
    wich is in my PATH

    I don't know why it fails in your case, but I'll examine the Makefile, just in case. I suppose you can execute Pasmo and compile the source from the command line, right?
    Marcos Cruz (programandala.net)
  • edited January 2016
    Crisis wrote: »
    the makefile failed for me.
    maybe opensuse has different standards
    pasmo is in : usr/local/bin/
    wich is in my PATH

    I don't know why it fails in your case, but I'll examine the Makefile, just in case. I suppose you can execute Pasmo and compile the source from the command line, right?

    this is my 'standard' definition which i use with KATE and PASMO
    ; pasmo -d --tap --name %n %f %n.tap %n.symbol
    ; pasmo -d %f %n.bin %n.symbol
    
    ; pasmo -d -1 -v --tap --name %n KeyPT111.asm KeyPT111.tap KeyPT111.symbol
    

    so $base_name= %n and $source = %f

    edit
    z80s is a txtfile, thats easy
    klick and go
    fn_disphex.tap = 88 bytes? with a 63 codeblock?

    00000000 EQU 0003BH
    00000002 EQU 02AB6H
    00000003 EQU 02BF1H
    DEFADD EQU 05C0BH
    dmphnc1 EQU 0002AH
    dmphnc2 EQU 00037H
    dumphex EQU 0001DH
    fn_disphex EQU 00000H
    fn_disphex_size EQU 0003FH
    Post edited by Crisis on
    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
  • Crisis wrote: »
    pasmo is in : usr/local/bin/
    wich is in my PATH
    ch@linux-4xd4:~/Downloads/deffnder> sudo make mgt
    cd src ; \nfor source in $(ls -1 fn_*.z80s) ; do \n  		base_name=${source%%.z80s} ; \n	echo "Compiling $source" ; \n	pasmo --tap --name $base_name $source ../bin/$base_name.tap ../bin/$base_name.symbols.z80s ; \ndone ; \ncd - ; \ncat bin/fn_*.tap > bin/deffnder.tap
    Compiling fn_band16.z80s
    

    Have you tried adding the path to pasmo in Makefile? Just in case.
    	/usr/local/bin/pasmo --tap --name $base_name $source ../bin/$base_name.tap ../bin/$base_name.symbols.z80s ;
    
    Crisis wrote: »
    mkmgt bin/deffnder.mgt sys/gplusdos-sys-2a.tap bin/deffnder.tap
    make: mkmgt: Command not found
    Makefile:101: recipe for target 'mgt' failed
    make: *** [mgt] Error 127
    ch@linux-4xd4:~/Downloads/deffnder> 
    

    This last error is different. If you want Plus D disk you have to install mkmgt.

    Marcos Cruz (programandala.net)
  • Crisis wrote: »
    fn_disphex.tap = 88 bytes? with a 63 codeblock?

    That's correct. It's the TAP header.

    If I understand well, it works when you compile a source file from the Kate editor?

    Does it work when you give the command (the same pasmo command used the Makefile) directly in the 'scr' directory?.
    Marcos Cruz (programandala.net)
Sign In or Register to comment.