Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 149 online users. » 0 Member(s) | 146 Guest(s) Applebot, Bing, Google
|
Latest Threads |
Strange Happenings
Forum: Bug Reports
Last Post: zedex82
05-07-2025, 09:05 AM
» Replies: 0
» Views: 40
|
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 417
|
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 332
|
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,659
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 602
|
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 936
|
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 372
|
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,133
|
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,919
|
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 438
|
|
|
hex numbers in asm blocks |
Posted by: LTee - 07-23-2014, 07:31 PM - Forum: Help & Support
- Replies (4)
|
 |
Sorry to be creating so many posts the last couple of days. 
Should this work?
Code: asm
defb ffh
end asm
I read a post elsewhere which suggested that that was the correct syntax to use for hex numbers in an asm block, but I get this:
Code: test.bas:1: Error: Undefined label 'ffh'
If I switch the 'ffh' for a '255' then all is fine. 1.4.0-s1885, as before. Thanks!
|
|
|
Should I be able to declare an array of @ addresses? |
Posted by: LTee - 07-23-2014, 07:01 PM - Forum: Help & Support
- No Replies
|
 |
Not sure if this is a bug or not, so I thought I'd pose the question first. 
I read this post from last year, which suggests that @ addresses should now be treated as constants:
<!-- l --><a class="postlink-local" href="http://www.boriel.com/forum/post4283.html?hilit=%20not%20constant%20#p4283">post4283.html?hilit=%20not%20constant%20#p4283</a><!-- l -->
So I figured I should probably be able to make some labels and then do something like this:
Code: dim addressMap(4) as uinteger => {@label1,@label2,@label3,@label4}
... except I can't - the compiler won't accept the @ addresses as being constants if they're being used to initialise an array.
So I though I might cheat and try to do this instead:
Code: const c1 as uinteger = @label1
const c2 as uinteger = @label2
const c3 as uinteger = @label3
const c4 as uinteger = @label4
dim addressMap(4) as uinteger => {c1,c2,c3,c4}
... but that doesn't work either - it doesn't think the constants are constant either. 
Should either of those things work? Or am I going about doing this the wrong way? I'm importing some data in asm defb format and thought I might use the @ addresses of some ZX Basic labels to refer to various points within the data. Using 1.4.0-s1885, by the way. Thanks for any input!
|
|
|
Function declarations not working (sometimes) (*solved*) |
Posted by: LTee - 07-22-2014, 08:21 PM - Forum: Bug Reports
- Replies (4)
|
 |
Okay, I think I figured out what my other problem is. 
In 1.3 I could call a function in the code before it was declared providing I declared the function with a prototype at the top of the class. So this would've worked okay, despite the 'addWibble' function appearing after the call to 'addWibble':
Code: 'function prototypes
declare function addWibble(msg as String) as String
'call addWibble even though it's declared down there vvvv
dim newMsg as String
newMsg = addWibble("Hello")
print newMsg
'return a string suffixed with 'wibble'
function addWibble(msg as String) as String
dim newString as String
newString = msg
newString = newString + "wibble"
return newString
end function
In 1.4 this won't compile, it seemingly ignores the 'declare' prototype of the function and doesn't recognise 'addWibble' when it first encounters it, giving an error like this:
Code: TestFunction.bas:8: 'addWibble' is neither an array nor a function.
If you move the call below function like this then everything is fine:
Code: 'return a string suffixed with 'wibble'
function addWibble(msg as String) as String
dim newString as String
newString = msg
newString = newString + "wibble"
return newString
end function
'call addWibble even though it's declared down there vvvv
dim newMsg as String
newMsg = addWibble("Hello")
print newMsg
HOWEVER.... it's a bit more complicated than that. It seems that I only see this effect if the function returns a String. If I quickly switch the function to return a ubyte instead then everything compiles fine.
Code: 'function prototypes
declare function addWibble(msg as string) as ubyte
'call addWibble even though it's declared down there vvvv
dim newMsg as ubyte
newMsg = addWibble("test")
print newMsg
'return the number 1
function addWibble(msg as string) as ubyte
return 1
end function
Hope that makes sense!
|
|
|
Declaring arrays with constants (*solved*) |
Posted by: LTee - 07-21-2014, 07:19 PM - Forum: Bug Reports
- Replies (6)
|
 |
Hi guys, it's been a little while. 
I finally got around to upgrading to 1.4.0-s1881 and set about recompiling a bunch of old stuff to see how it turned out. One thing I'm having a problem with is that some of my code uses consts in the declaration of arrays, which was fine in 1.3 but doesn't seem to like compiling in 1.4.
e.g.
Code: 'constants
const DGMAXX as ubyte = 10
const DGMAXY as ubyte = 10
'dungeon data
dim dgConnected(DGMAXY, DGMAXX) as ubyte
This fails to compile with an error telling me that I must use a constant (which I thought I did). 
Code: DunGen.bas:6: Array bound must be a constant expression.
DunGen.bas:6: Array bound must be a constant expression.
Traceback (most recent call last):
File "zxb.py", line 348, in <module>
File "zxb.py", line 262, in main
File "ply\yacc.pyc", line 263, in parse
File "ply\yacc.pyc", line 710, in parseopt
File "zxbparser.pyc", line 600, in p_bound_list_bound
File "zxbparser.pyc", line 324, in make_bound_list
File "symbols\boundlist.pyc", line 45, in make_node
File "ast_\tree.pyc", line 147, in appendChild
File "ast_\tree.pyc", line 52, in append
AssertionError
Apologies if this has already been covered in here, I didn't have much luck with the search!
|
|
|
Function pointers |
Posted by: antoniovillena - 07-08-2014, 11:22 PM - Forum: Wishlist
- No Replies
|
 |
Something like this:
<!-- m --><a class="postlink" href="http://virtualink.wikidot.com/fbex20">http://virtualink.wikidot.com/fbex20</a><!-- m -->
|
|
|
Program refuses to compile |
Posted by: Darkstar - 06-29-2014, 03:22 PM - Forum: Bug Reports
- Replies (28)
|
 |
Hello.
I got a program that works fine under 130s1121 but not under 140s1876. When I try to compile it then it bombs with this message:
Traceback (most recent call last):
File "/home/pi/zxbasic/zxb.py", line 348, in <module>
sys.exit(main(sys.argv)) # Exit
File "/home/pi/zxbasic/zxb.py", line 274, in main
translator.visit(zxbparser.ast)
File "/home/pi/zxbasic/ast_/ast.py", line 105, in visit
stack.append(self._visit(stack.pop()))
File "/home/pi/zxbasic/arch/zx48k/translator.py", line 143, in _visit
return NodeVisitor._visit(self, node)
File "/home/pi/zxbasic/ast_/ast.py", line 118, in _visit
return meth(node)
File "/home/pi/zxbasic/ast_/ast.py", line 122, in generic_visit
raise RuntimeError("No {}() method defined".format('visit_' + node.token))
RuntimeError: No visit_SAVE() method defined
Usage: zxbasm.py <input file> [options]
I do not wnat to share the source on a forum, is there any way that I can get the source to you Boriel so that you can have a look at it?
Also, under the old version if you had a wihite paper and a black ink but a yellow border then the SAVE command did change the paper color to yellow afterwards and the tape message got displayed in paper yellow instead of white. Highly fishy. And if I tried to compile this program with -O3 then it bombed so I had to set it back to -O1. Now it totally refuses to compile under the new version. Help would be good here Boriel.
|
|
|
an additional label in <library-asm/print.asm> |
Posted by: programandala.net - 06-08-2014, 07:11 PM - Forum: Library
- Replies (3)
|
 |
Mi wish is easy to satisfy: I need one label after CP 80h in <print.asm>:
Code: ex af, af'
cp 80h ; Is the char an UDG, a block character or a token?
JUMP_IF_GREATER_THAN_80H:
; XXX label needed to hack the printing system
jp c, __SRCADDR ; if not, jump
(That is an extract from my hacked version of <print.asm>, with additional comments of my own; the actual name of the label doesn't matter.)
The reason I need a label there is I have written a module that provides a sub to switch on an off the ZX Spectrum legacy printing mode (that treats ASCII chars, block chars and UDG chars apart). When the legacy mode is off, all chars 32-255 are taken from the same charset. This makes it possible to write source code with a modern 8-bit encoding, e.g. Latin1. This is very useful for programs that print a lot of text in other languages than English.
I tinkered with this idea four years ago, and hacked <print.asm>, but I had to redo the changes after every new version of ZX BASIC. The new approach is simpler and better: The sub modifies the code of <print.asm> in two locations, and the legacy printing mode can be restored at any time by the program. It works great. So far I have tried it with a modified version of <print.asm>. That's why I need that single label.
I will publish the module as soon as it can be used with a new version of ZX BASIC, unless someone requires it sooner.
Thank you.
|
|
|
RAM page support |
Posted by: wilco2009 - 05-29-2014, 05:17 PM - Forum: Wishlist
- No Replies
|
 |
I've never programmed used bank switching, but now I'm developing a new external interface to convert a 16Kb Spectrum to a machine very close to a plus 3 machine but with 512Kb of RAM, and due to it, I'm starting to be interested of this kind of programming.
I know now that ZXBasic has not support for bank-switching.
I have a suggestion about the possibility of support it natively and then support 512Kb of RAM too. The method to change the page above 128Kb is the same that the used in Pentagon, ie using bits 6 and 7 of the same port than 128Kb ($7FFD).
Could be very interesting to do it, because if we do it manually we can only use it for data, as a very fast disk, but not for code. The best way is to implement it natively. It is not possible to do that with a library.
The main challenge could be to use the same addresses for different functions.
|
|
|
Bank switching in ZX-Basic |
Posted by: wilco2009 - 05-22-2014, 09:34 AM - Forum: Help & Support
- Replies (2)
|
 |
I've never programmed used bank switching, but now I'm developing a new external interface to convert a 16Kb Spectrum to a machine very close to a plus 3 machine but with 512Kb of RAM, and due to it, I'm starting to be interested of this kind of programming.
Have ZXBasic support for bank-switching?. If the aswer is yes, I have a suggestion about the possibility of support for 512Kb of RAM. The method to change the page above 128Kb is the same that the used in Pentagon, ie using bits 6 and 7 of the same port than 128Kb ($7FFD).
If it is not supported, could be very interesting to do it, because if we do it manually we can only use it for data, but not for code. The best way is to implement it natively. It is not possible to do that with a library.
The main challenge could be to use the same addresses for different functions.
|
|
|
poke string address,string$ |
Posted by: programandala.net - 05-21-2014, 05:17 PM - Forum: Wishlist
- Replies (1)
|
 |
I think POKE STRING would be useful in many situations. It would poke the content of a string (not its lenght). I've written it this way:
Code: sub fastcall pokeString(address as uinteger,text$ as string)
asm
; HL = first parameter, address
ex de,hl ; DE = address
pop bc ; return address
pop hl ; second parameter, address of the text$ lenght
push bc ; restore the return address
ld c,(hl)
inc hl
ld b,(hl) ; BC = text$ lenght
inc hl ; HL = first char of text$
ldir
end asm
end sub
The advantage of a native POKE STRING would be POKE would work with all current types.
|
|
|
|