ZX-IDE Tutorial for programming assembler and ZX BASIC

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by bru65pag » Sun Jan 03, 2016 10:29 pm

Good evening,

I should start by wishing you all a happy new year, and a big thank you to the developers of the ZX-IDE and other tools; they make my learning ZX81 assembly experience so much easier!

I would like to report two issues I ran into with ZX-IDE. Let me know if I am doing something wrong. I am running version 1.71.01P.Z80.

1/ The following line:

Code: Select all

63 LET DI=1-(2 AND(L=20 OR INKEY$="M"))
got translated into:

Code: Select all

63 LET DI=1-(220="M"))
I found a workaround by replacing the line with

Code: Select all

63 LET DI=-((L=20 OR INKEY$="M") AND 2)+1
Here is the source and a dump made from the p file with ZXLIST:
ZXIDEIssue.jpg
ZXIDEIssue.jpg (126.7 KiB) Viewed 1874 times
2/ While trying to find a workaround, I came up with an out of memory error with the following program:

Code: Select all

10 LET D=1-(
It seems that unbalanced parenthesis are not welcome.
What was a little bit surprising to me, is that the same line in a REM statement also gives the same error:
|code]10 REM LET D=1-([/code]

Hope you can help. Thanks a lot. Bruno.
Last edited by bru65pag on Mon Jan 04, 2016 12:04 pm, edited 2 times in total.

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by PokeMon » Mon Jan 04, 2016 12:49 am

I will take a look at it tomorrow.
Yes - there maybe situations where the ZX-IDE crashes and complex usage of parenthesis may cause problems for the interpreter.
This has to do with a change in syntax to replace () with [] as this was originally used from the underlying FASM software which was adapted from x86 to Z80 instruction set. This was quite complicate stuff as () are used for numerical expressions as well and not easy to distinct between mnemonics and arithmetic calculations. Sorry for that.

bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by bru65pag » Mon Jan 04, 2016 1:20 pm

About my first point: I did further investigations. The easiest workaround is to add additional parenthesis:

Code: Select all

63 LET DI=1-(2 AND (L=20 OR INKEY$="M"))
becomes

Code: Select all

63 LET DI=1-((2) AND ((L=20) OR (INKEY$="M")))

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by PokeMon » Tue Jan 05, 2016 1:49 am

There is a new updated version of ZX-IDE (FASMW-ZX) in the first posting of this thread for download available:
ZX-IDE 1.71.01q.Z80 (01/2016)

The following missing undocumented opcodes where added:

Code: Select all

LD IXh,n
LD IXl,n
LD IYh,n
LD IYl,n
Also made changes in the interpretation of BASIC lines which should allow even more complex constructions like described above (line 63) and this has been tested with all general instruction and contexts available in my test programs and should work properly with all source code (I think so).
Have fun. 8-)

User avatar
marste
Posts: 129
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by marste » Tue Jan 05, 2016 4:09 pm

PokeMon wrote:I will take a look at it tomorrow.
Yes - there maybe situations where the ZX-IDE crashes and complex usage of parenthesis may cause problems for the interpreter.
This has to do with a change in syntax to replace () with [] as this was originally used from the underlying FASM software which was adapted from x86 to Z80 instruction set. This was quite complicate stuff as () are used for numerical expressions as well and not easy to distinct between mnemonics and arithmetic calculations. Sorry for that.
I know very well the situation since I use a lot of parenthesis and I already used for same purpose the x86 version and I can imagine that you are doing "mortal jumps" (as we say in Italy ;) ) to keep everything running smoothly.

The question is: would not be better to completely follow the FASM philosophy (even if it is x86 originated) and keep the "[]" as a memory reference?

Since the Z80 logic is already there (and some aficionado might not willing to change), there might be a flag for compatibility (like the FORMAT one), but at least will allow people like me that would prefer to use all power of FASM expressions without always be afraid of bugs (or as often trying all the ways to overcome them) with just the cost of using different set of parenthesis!

And even more: I think that is not only easier but source code will be even more clear (as in the original FASM) since the squared one will always indicate a memory reference while curved ones will always indicate expressions!!

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by PokeMon » Tue Jan 05, 2016 9:45 pm

I think the parenthesis stuff is fixed now.
I did this already for IF THEN statements and processed all after a zx81 statement as "text" (even if it is a function or similar).
I was not sure if this gives a conflict when assembly context is needed like PRINT USR #label but tested out that these statements have been correctly translated - so I decided to handle all default instruction stuff on a BASIC line in the same way. I think this problem must be save for all future constellations as well.

About the [] this is used from FASM for memory referencing - I decided to implement the original Zilog language with () as this is more retrolike and old code can be compiled with ZX-IDE easily. So I don't consider to step this way back but you can of course use [] as well like LD HL,[nnnn] - you may try it.

The problem I had with the () is that the AND/OR and +,-,*,/ are processed for calculating numerical values which gives strange results.
But I think with new version this is really fixed now. ;)

bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by bru65pag » Wed Jan 06, 2016 11:07 pm

Good evening Pokemon,
I confirm that the issue is fixed on my side, the generated p file has the correct BASIC lines :-)
Thanks a lot for your prompt reply.
Bruno.

bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Re: Edit and compile (assemble)

Post by bru65pag » Sun Jan 10, 2016 12:30 pm

Good morning Pokemon,

I'm using the ZX-IDE for editing my assembly files.This brings editing limitations compared to using an external editor like Notepad++, but the very purpose of an IDE is to be integrated right ;-) ?

One question and one suggestion:

1/ Did you ever consider integrating an external editor (like Notepad++) into ZX-IDE? May be it is impossible, but it would definitely benefit from the power of the editor you would integrate.

2/ The use of the Search->Find function is not so convenient in my opinion:
  • - The button label, 'Find First' would probably benefit from a relabeling, something like 'Find Next' or 'Next'.
    - Once the button is hit and the instance is found, the window disappear. To continue searching for the next instance, you have to re-open the window. I would find it more practical to keep that window open until the user explicitly asks for it to be closed. I know that F3 can also find the next instance, but I like the window better, because I can always see the option I've selected for my find.
    - Now, let say that I am looking for the string "FRAMES":
    LD A, (FRAMES)
    After clicking 'Find First', the text is highlighted in blue background, and the cursor is placed below the next character (the right hand side parenthesis in our example). If I now select the 'backward' option, and redo a search, the cursor will simply move under the first character of the searched string (F in our example); sounds not so useful.
    I believe that the find function would benefit from always positioning the cursor under the first character of the found string. Doing so, the backward search would really jump to the previous instance, and not simply move the cursor.
I hope to read from you soon. Until then, have fun. Bruno.

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by PokeMon » Sun Jan 10, 2016 1:43 pm

Hi Bruno,
yes the goal was to have an integrated development tool.
I didn't write the editor myself as most of the engine was overtaken from FASM project.
You may build up a tool chain if you like with an external editor - up to you - and just choose the command line version.

The editor has in some case only basic functionality but for my purposes is okay. I am not planning to integrate other tools at this time, sorry not much time I can spend now on comfortability. But the vertical selection feature is great, did you ever use it ? Last time I converted an older listing with address and data on the left side by easily removing 20 columns or so in just one click. ;)

So hope you can get around with this.
Karl

nollkolltroll
Posts: 268
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: ZX-IDE Tutorial for programming assembler and ZX BASIC

Post by nollkolltroll » Fri Feb 05, 2016 6:36 pm

I've searched a good long time, reading this manual and the FASM documentation, finding no help.

I try to make some simple address arithmetic, where this works:
ld (hl),SomeLabel shr 8 ;get upper byte of address

But the following gives 'Error: extra characters on line':
ld (hl),SomeLabel and 255 ;get lower byte of address

Subtituting 'and' to '&' gives the same error.
What am I supposed to do to get the lower byte of an address?
/Adam

Post Reply