Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About constants
#4
LCD Wrote:Thank you Boriel. I hope, I can finish some of my Projects from my website using your Compiler...
The Problem was: I never used FreeBasic. so the syntax is a bit strange for me. But now after I know where I can find the references, it will be maybe easier.
Thank you for your interest. I will fill in the documentation as soon as possible. If you can use subversion (or tortoiseSVN for windows) I encourage you to try de alpha developing version. Just clock on the zxbasic directory with your File Explorer and do a SVN Update. Currently 3 new features are in the alpha version:
  1. If you specify an optimization level like, zxb -O2 program.bas then unused functions won't be compiled Wink
  2. You can start arrays by default with lower bound 1 (the default is 0): DIM a(10) is the same as DIM a(0 TO 10). If you want them like in Sinclair Basic, use zxb --option-base=1
  3. The print, DRAW, PLOT and CIRCLE routines has been slightly optimized (they use attributes in a more efficient way).

Quote:The Macros looks like a excellent idea because, if I understand this right, it is faster than calling a function or procedure, but it will surely eat more memory with longer macros. Do ZX Basic support procedures (with shared or local variables)?
Yes, a macro is faster than a procedure/function, but takes more memory. Use it only for very simple functions (like the square example above). Macros can have more than one line. Look in library/retrace.bas

ZX BASIC supports FUNCTIONS and procedures (SUB). Declared variables (with DIM) in them are local. In fact SCREEN$, POINT and ATTR are implemented this way. Function calls uses the STD_CALL convention (used in most compilers today). You can see the library of high-level functions in the library/ directory to see how functions are implemented (some of them use inline ASM).

To use a function from the library (e.g. SCREEN$), use #include directive:
Code:
#include <screen.bas>

For functions/subs that use only 1 or none parameters you can use the FASTCALL convention (parameteres are passed in the registers). This is VERY internal Wink so please, ask me more if interested.

Quote:Supporting Hex and binary (%0111) natively is a great idea, because it is faster than BIN function. And the InLine ASM is something, I wanted since I was using compilers.
Binary numbers here are written either %0111 or 0111b Wink

Quote:The fact is: HiSoft Basic Calls to additional ASM routines are extremly slow. I had here the fastest PLOT routine ever written (with 1 Kb of tables), but calling it from HiSoft Basic over the ROM USR routine made it slower than the ROM PLOT routine.
Is HiSoft BASIC available today for FREE? I would like to try it.

You can embed your PLOT routine this way:
Code:
SUB FASTCALL myplot(x AS UBYTE, y AS UBYTE)
    ASM
    pop hl ' HL gets the return address
    ex (sp),hl ' HL now contains the X parameter (in H register)
    ' Now A register contains Y
    ' and H register contains X
    ' ASM includes must be included within asm scope
#include "myplot.asm"
     END ASM
END SUB
Note: ZX BASIC is (by now), case sensitive. This means that for your function and variables, MYVARIABLE and myvariable refers to diferent variables.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)