Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 258
» Latest member: manuelzo75
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

Online Users
There are currently 300 online users.
» 0 Member(s) | 298 Guest(s)
Bing, Google

Latest Threads
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 228
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 267
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,538
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 524
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 423
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 294
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,026
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,864
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 403
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,641

 
  ZXBasic 1.2.6-r1561
Posted by: boriel - 04-29-2010, 05:46 PM - Forum: Bug Reports - Replies (2)

This is a new beta version (released a minute ago :!Smile. Basically it adds 3 new command line parameters:

  • --strict-boolean will enforce boolean results to be always 0 or 1 (with a slight impact on performance). Using --sinclair also enables this feature.
  • --debug-array will raise an error if an array access is made out of boundaries (3 Subscript Wrong)
  • --debug-memory will raise an error when out of memory. This might happen when working with strings

Using --debug-xxx will affect a bit the program speed (due to extra checking). So this should only be used during development stage. :wink:

Download at <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb">http://www.boriel.com/files/zxb</a><!-- m --> as always...

Print this item

  Missing label issue *found*
Posted by: britlion - 04-21-2010, 08:24 AM - Forum: Help & Support - Replies (2)

I have a program (fourspriter. Yet again!) that has a compilation error "no such label". Except I can see it. Right there! :-)

Am I going crazy?

I copied and pasted the following code into a separate project:

Code:
SUB FASTCALL fspUpdate()
asm
fspUpdateAsm:
         ld     hl, fspDataStartAsm+1     ; Points to sprite 1
         ld     de, fspDataStartAsm+3            
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43     ; Points to sprite 2
         ld     de, fspDataStartAsm+3+43                  
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43     ; Points to sprite 3
         ld     de, fspDataStartAsm+3+43+43                
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43+43     ; Points to sprite 4
         ld     de, fspDataStartAsm+3+43+43+43                    
         ldi
         ldi
         ret
END asm
END SUB

SUB fspCollisionCheck()
END SUB


SUB FASTCALL fspRedraw()
   fspCollisionCheck()
asm
   halt
   call fspEraseAsm
   call fspBufferAndDrawAsm
   call fspUpdateAsm
end asm                                          
END SUB

fspRedraw()

And it compiled perfectly. Which is bad, because this is FULL of references that don't exist. However, when I try the main code block, it reports:

FourSpriter3.bas:906: Error: Undefined label 'fspUpdateAsm'

Now, quite apart from the fact that line 906 reads " ;LD BC,2120 "- which means I have to hunt down the line it really means, that label is only used in two places. Both of those places are shown in the code above. One call and one arrival point.

I have NO idea why it's doing this. It's weird that it doesn't like the label in the main program, and yet is fine with all those other undefined labels in the part above. Any idea what's going on here?

Print this item

  how to use a standard character set
Posted by: programandala.net - 04-20-2010, 12:52 PM - Forum: How-To & Tutorials - Replies (3)

Sometimes, in order to use the Spanish characters (áéíóúüñÁÉÍÓÚÜÑ¿¡) in my Spectrum programs, I put them in the place of less used Spectrum chars (#, ', @...).

In the source code of my current project there's a lot of Spanish texts to be printed by the Spectrum. It would be uncomfortable to use those fake chars all over the source. Then I had a quite brilliant Wink idea: Let's use the same standard character set both in the source code and in the Spectrum!

First, I wrote a trivial asm sub to change the character set address. Then I added the character graphics, with the Spanish chars in the right position (in the ISO-8859-1 standard). The only needed trick is to fill the gaps of the unused chars. Happily, I already had all the character definitions is assembler DEFBs, in another project of mine.

This is the first part of the sub:

Code:
sub fastcall changeCharacterSet()

    asm

systemCHARS    equ 23606

    jp actuallyChangeCharacterSet

characterSet equ $-256

;(space)
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
;!
    defb %00000000
    defb %00010000
    defb %00010000
    defb %00010000
    defb %00010000
    defb %00000000
    defb %00010000
    defb %00000000

And so on... This is the end:

Code:
    defs (243-241-1)*8 ; unused chars
;ó = 243
    defb %00001000
    defb %00010000
    defb %00111000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

    defs (250-243-1)*8 ; unused chars
;ú = 250
    defb %00001000
    defb %00010000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

    defs (252-250-1)*8 ; unused chars
;ü = 252
    defb %01000100
    defb %00000000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

actuallyChangeCharacterSet:

    ld hl,characterSet
    ld (systemCHARS),hl

    end asm
end sub

Easy, isn't it?

The next task is to hack the print.asm library in order to print all characters from 32 to 255. I show the removed or added lines (they are clearly marked):

First:

Code:
; 1 LINE REMOVED:
;        LOCAL __PRINT_UDG

And then the rest:

Code:
; 8 LINES REMOVED:
;        cp 80h    ; Is it an UDG or a ?
;        jp c, __SRCADDR

;        cp 90h
;        jp nc, __PRINT_UDG

        ; Print a 8 bit pattern (80h to 8Fh)

;        ld b, a
;        call PO_GR_1 ; This ROM routine will generate the bit pattern at MEM0
;        ld hl, MEM0
;        jp __PRGRAPH

PO_GR_1 EQU 0B38h

; 4 LINES REMOVED:
;__PRINT_UDG: ;REMOVED
;        sub 90h ; Sub ASC code
;        ld bc, (UDG)
;        jp __PRGRAPH0

__SOURCEADDR EQU (__SRCADDR + 1)    ; Address of the pointer to chars source
__SRCADDR:
        ld bc, (CHARS)

__PRGRAPH0:
; 1 LINE REMOVED:
;        add a, a    ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
        ld l, a
        ld h, 0        ; HL = a * 2 (accumulator)
        add hl, hl
; 1 LINE ADDED:
        add hl, hl
        add hl, hl ; HL = a * 8
        add hl, bc ; HL = CHARS address

__PRGRAPH:

That's all. Now all characters from 32 to 255 are in the same set: no block graphics, no UDGs, no Basic tokens. Any desired graphic can be defined in any character code. Any standard 8-bit character set can be used. Now I can write the Spanish texts in the source and they show perfectly on the Spectrum's screen.

I'd like my hacked version to be an independent library, to be #included, and used with a new command (print224, printplus or whatever). But rigth now that task is beyond my current skill with ZX Basic. Any help?

Another issue is to use the gaps of the unused chars for variables, but I'm still not sure how to use asm labels in ZX Basic. I have to explore it. Any help?

Now I will tinker with the second part of the system: I have to modify my own input routine, to let it accept some key combinations (e.g. Symbol Shift (+Shift)+letter) to get the Spanish characters...

Print this item

  --asm and --tap together
Posted by: programandala.net - 04-20-2010, 10:05 AM - Forum: Wishlist - Replies (4)

Some times I need to check the assembler, and I have to compile the sources twice in order to get also the .TAP file, because anyway I need to execute the program too.

Maybe in the future both the assembler file and the object file could be created with one single command?

Print this item

  values returned by comparations
Posted by: programandala.net - 04-19-2010, 07:52 PM - Forum: Bug Reports - Replies (4)

I realized that some comparations with string lenghts return different values than in Sinclar Basic:

Code:
dim text as string
let text="A"
print len(text)=1 ' prints 0!
print len(text)=len(text) ' prints 255!
print 2=2 ' prints 1 as expected

Why?

Print this item

  string slicing using len()
Posted by: programandala.net - 04-19-2010, 04:09 PM - Forum: Help & Support - Replies (3)

I didn't understand why a piece of my program didn't work as expected. I suspected something was wrong with the for-next loop. I tried some tests, simplified versions of the problem, and finally find out the following:

Code:
dim text as string
dim i as ubyte

let text="hello world!"

cls
print "Fine:"
for i = 0 to len(text)-1
    print i,text(to i)
next i

pause 0
cls
print "All texts are complete!:"
for i = 0 to len(text)-1
    print i,;
    let text = text(to len(text)-1)
    print text
next i

stop
It was a surprise. The second loop prints the same original text every time.

I tried the equivalent code in Sinclair Basic, and of course it worked as expected:
Code:
10 LET A$="hello world!"
20 FOR I=0 TO LEN(A$)-1
30 PRINT I,;
40 LET A$=A$(TO LEN(A$)-1)
50 PRINT A$
60 NEXT I
70 STOP

Then I tried it without the loop:

Code:
dim text as string
let text="hello world!"
cls
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
stop
And the problem remained.
Then I hardcoded some slicing values:
Code:
dim text as string
let text="hello world!"
print text
let text = text(to 10)
print text
let text = text(to 9)
print text
let text = text(to 8)
print text
let text = text(to 7)
print text
let text = text(to 6)
print text
let text = text(to 5)
print text
stop
And it worked fine.

Is there something I'm missing in my code or is it a compiler issue?

Print this item

  How to change the compiling ORG address?
Posted by: programandala.net - 04-19-2010, 12:52 PM - Forum: Help & Support - Replies (1)

I wonder how to change the default address 32768. I've searched for "org" in the forum archive, but all references are about the assembler ORG. There's no mention in the wiki either.
I blindly tried this:

Code:
org 30000
And this:
Code:
#org 30000
But they are not accepted. Then I tried this:
Code:
asm
org 24000
end asm
print "hello"
stop
And got the following assembler:
Code:
    org 32768
__START_PROGRAM:
    di
    push ix
    push iy
    exx
    push hl
    exx
    ld hl, 0
    add hl, sp
    ld (__CALL_BACK__), hl
    ei
    call __PRINT_INIT
#line 3
        org 24000
#line 4
    ld hl, __LABEL0
    call PRINT_STR
    call PRINT_EOL
    ld a, 8
    call __STOP
    ld hl, 0
    ld b, h
    ld c, l
__END_PROGRAM:
    di
    ld hl, (__CALL_BACK__)
    ld sp, hl
    exx
    pop hl
    exx
    pop iy
    pop ix
    ei
    ret
I searched for "or" and "pragma" through the sources, but I found no clue.

Print this item

  About POS
Posted by: programandala.net - 04-18-2010, 08:25 PM - Forum: ZX Basic Compiler - Replies (5)

I just needed the POS function to adapt a code of mine from FreeBASIC... But I didn't suspect POS is already defined in ZX Basic! I realized when the compiler halted: it seems two POS functions are too much Smile

By the way, this was my definition:

Code:
#define systemSPOSN 23688

function pos() as ubyte

    return 34-peek(systemSPOSN)

end function

First I made some tests, because I wasn't sure if the object code produced by the compiler uses the ROM routines and so the related system variables are updated as well. I find out the content of the S POSN system variable is not the same when the same code is executed by Sinclair Basic or compiled by ZX Basic:

Code:
#define systemSPOSN 23688

cls
print at 0,0;peek(systemSPOSN) ' prints 34
print at 1,10;peek(systemSPOSN) ' prints 24
print at 2,20;peek(systemSPOSN) ' prints 14
print at 3,25;peek(systemSPOSN) ' prints 9
stop

' Sinclair Basic prints one less (33, 23, 13 and 8)!

Yes, the same program in Sinclair Basic returns lower values. It's interesting.

Anyway, it's great POS already exists. I took a look at its source file and the rest of library files. There are many interesting undocumented functions.

I created the POS page in the wiki.

Print this item

  conflict between "label EQU" and "#DEFINE label"?
Posted by: programandala.net - 04-18-2010, 06:51 PM - Forum: Bug Reports - Replies (1)

I got the following error:

Quote:random.asm:10: Error: Syntax error. Unexpected token '23672' [INTEGER]

I took a look at the random.asm library. Lines 10 are 11 are the following:

Code:
    LOCAL TAKE_FRAMES
    LOCAL FRAMES

And line 31:

Code:
FRAMES EQU    23672

So I suspected the problem had something to do with this line of my program:

Code:
#define FRAMES 23672

I defined FRAMES because I use it for several calculations.

I was right: I renamed it MYFRAMES and the error didn't happen again.

Does it means the EQU assembler labels conflict with #DEFINEd labels?

Print this item

  AttributeError: 'SymbolSTRSLICE' object has... (*solved*)
Posted by: programandala.net - 04-18-2010, 02:49 PM - Forum: Bug Reports - Replies (6)

For the second time, I get the following output (version 1.2.5):

Quote:marcos$ zxb.py --tap --autorun --BASIC --sinclair colegio_erevest_4.bas
Generating LALR tables
Generating LALR tables
WARNING: Token 'UMINUS' defined, but not used
WARNING: There is 1 unused token
Traceback (most recent call last):
File "/home/marcos/bin/zxb.py", line 255, in <module>
sys.exit(main(sys.argv)) # Exit
File "/home/marcos/bin/zxb.py", line 203, in main
zxbtrad.traverse(zxbtrad.FUNCTIONS) # This will fill MEMORY with pending functions
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 250, in traverse
traverse(l)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 959, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 257, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 770, in traverse
traverse(tree.next[1])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 720, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1004, in traverse
traverse(tree.next[i])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1008, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 569, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 375, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 530, in traverse
if tree.next[0].token != 'STRING' and tree.next[0].token != 'ID' and tree.next[0].symbol._mangled[0] != '_':
AttributeError: 'SymbolSTRSLICE' object has no attribute '_mangled'

I've searched for "mangled" in the forums, but there's no message about it.

It seems it happens when no more syntax errors are found in the source, but I'm not sure. Any clue? Is it a compiler issue or is it caused by my program?

Print this item