ZXSpin assembler not working

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

What errors were you getting with the original code [mention]MrPixel[/mention] .

Have you started with that Shaun Bebbington tutorials I linked for you. They are a perfect beginners starting text.

http://shaunbebbington.blogspot.co.uk/2 ... i.html?m=1
Ralf
Rick Dangerous
Posts: 2283
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: ZXSpin assembler not working

Post by Ralf »

What errors were you getting with the original code @MrPixel .
I believe things like JR NZ to Loop2 is some rare syntax not supported by modern crosscompilers

By the way, it's not weird that code written in one assembler doesn't compile in other. I would say it's pretty normal. Machine code under it is always the same but then there are macros, shortcuts, labels, start addresses, blocks of data, hex numbers and other stuff which may have a different notations between tools.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

[mention]MrPixel[/mention] you will find the whole tutorial series from ZX Computing typed out here:

http://www.users.globalnet.co.uk/~jg27p ... 1st_mc.zip

[mention]Ralf[/mention] is right that some assemblers had slightly different syntax, but you will learn to get around this as you learn. The error messages given by Pasmo or any other assembler will always help you along.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

[mention]MrPixel[/mention] here is the code tested in Pasmo (This is the scroll left version). Taken directly from the Jim Grimwood document sent earlier.

Code: Select all

org $6000
	LD HL,22527
        LD BC,192
loop    PUSH BC
        LD BC,-31
        ADD HL,BC
        LD A,(HL)
        LD D,H
        LD E,L
        INC HL
        LD BC,31
        LDIR
        DEC HL
        LD (HL),A
        LD BC,-32
        ADD HL,BC
        POP BC
        DEC BC
        LD A,B
        OR C          
        JR NZ,loop
        LD BC,24
        LD DE,22528
        LD HL,22529
loop2   LD A,(DE)
        PUSH BC
        LD BC,31
        LDIR
        DEC HL
        LD (HL),A
        INC DE       
        INC HL     
        INC HL
        POP BC 
        DEC BC 
        LD A,B
        OR C 
        JR NZ,loop2 
        RET  


END $6000
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: ZXSpin assembler not working

Post by Nomad »

The need to carefully check the syntax of the assembly listing from the books & magazines is actually a good thing. *ducks*

Just hear me out..

First never forget that...
Spoiler
Learn to think like the computer hates you, because it does. - Zed Shaw
Also its supposed to be hard - especially at first. Its going to be a struggle. But the journey is very rewarding because of this. You learn so many skills that help every other language you go on to learn after this. That kind of self reliance, attention to detail, research skills its all wonderful stuff. Nothing in high level languages comes close to the feeling you get when you see a non-trivial program actually working in zx80 assembly because almost everything with the spectrum is stacked against you.

Its natural to get disheartened but just stick with it. It makes the point where you start to bend the assembler to your will, to master the spectrum memory map, figure out the ROM. each step is a major achievement on the road to speccy enlightenment.

You learn not to trust the listings, not just uncritically copy and pasting stuff. You actually learn what each line is doing. It might take longer but you gain a whole lot more from the process. As the guys have said once you learn how your assembler works you just do a lot of these steps automatically.

Pick your assembler, then read its manual. This will hopefully give you most of the information you need. (Ok pasmo documentation could be a lot better, and Zeus is kind of a learn through examples deal but documentation is something that tools for spectrum fail hard on.) But its good enough to do all but the most complex of tasks. If you get to a point where you are stuck just ask here. People are very friendly.

The basics are usually the same, but beyond that its very much a matter of design choice. What systems they had worked on before and what the needs of the user of that assembler were.

I think with the modern tutorials that is something that gets lost is the analysis phase is often overlooked.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: ZXSpin assembler not working

Post by MrPixel »

i need help with 2 errors

symbol redefined (for new functions and

invalid combination of opcodes and errors for this:


DI ; 4 clocks F3
LD HL, $8002 ; 10 21 02 80
a: DEC HL ; 6 2B
b: DEC HL ; 6 2B
c: INC (HL) ; 11 34
JR NZ, c ; 7/12 20 FD (they appear on this line)
INC HL ; 6 23
INC (HL) ; 11 34
JR NZ, b ; 7/12 20 F8
INC HL ; 6 23
INC (HL) ; 11 34
JR NZ, a ; 7/12 20 F3
EI ; 4 FB
RET
this forces me to find workarounds, ruining the code. it's pissing me off
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: ZXSpin assembler not working

Post by Seven.FFF »

a, b, and c are registers. You can’t use them as label names. You wouldn’t be able to use other reserved words like ld, add, org, equ or numbers either.

Not sure what you mean by symbol redefined without an example. Generally you can’t reuse label names (unless your assembler has a local label facility), because that would be assigning two different addresses, and therefore different values, during the same assembly run.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

[mention]MrPixel[/mention] where did you find this piece of code?
User avatar
R-Tape
Site Admin
Posts: 6400
Joined: Thu Nov 09, 2017 11:46 am

Re: ZXSpin assembler not working

Post by R-Tape »

What SevenFFF said, just to expand on it:
MrPixel wrote: Sat Mar 31, 2018 2:53 am i need help with 2 errors

symbol redefined (for new functions and
You have used the same label name more than once.
invalid combination of opcodes and errors for this:
You can't use assembler terms that you use to manipulate code (e.g. a,b,c,and,or,rlca etc) as labels. With ZX-Spin for example these things are colour coded, cyan for opcode, and magenta for labels. So if your label is not magenta, you can't use it.

It needs to be something like this, and now you've used "namea" you cannot use it to label another routine.

Code: Select all

	DI ; 4 clocks F3
	LD HL, $8002 ; 10 21 02 80
namea:	DEC HL ; 6 2B
nameb:	DEC HL ; 6 2B
namec:	INC (HL) ; 11 34
	JR NZ,namec ; 7/12 20 FD (they appear on this line)
	INC HL ; 6 23
	INC (HL) ; 11 34
	JR NZ, nameb ; 7/12 20 F8
	INC HL ; 6 23
	INC (HL) ; 11 34
	JR NZ, namea ; 7/12 20 F3
	EI ; 4 FB
	RET 
this forces me to find workarounds, ruining the code. it's pissing me off
Chin up chef, you'll get there :D
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: ZXSpin assembler not working

Post by Nomad »

MrPixel wrote: Sat Mar 31, 2018 2:53 am this forces me to find workarounds, ruining the code. it's pissing me off
What kinda hero journey would it be without struggle, personal growth/development? This ain't no Disney star wars! :lol:

Especially at the beginning it will be hard going but you got to take your beatings like a man and come back for more. :lol: Think about a training montage. This is the beginning phase where the protagonist is getting his ass handed to him and it all seems hopeless. You got to go through the training to get the skills to overcome the challenge. :lol:

The main thing is to have patients to stick with it, even though its frustrating. To know it won't all come easy or at once. Respect the journey, follow the path and realize the goal.
Respect the burden. - Napoleon
Last edited by Nomad on Sat Mar 31, 2018 2:05 pm, edited 1 time in total.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: ZXSpin assembler not working

Post by Ast A. Moore »

MrPixel wrote: Sat Mar 31, 2018 2:53 am this forces me to find workarounds, ruining the code. it's pissing me off
“I don’t like cats.”
“You just don’t know how to cook them.”

:D
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: ZXSpin assembler not working

Post by MrPixel »

R-Tape wrote: Sat Mar 31, 2018 12:51 pm
You can't use assembler terms that you use to manipulate code (e.g. a,b,c,and,or,rlca etc) as labels. With ZX-Spin for example these things are colour coded, cyan for opcode, and magenta for labels. So if your label is not magenta, you can't use it.

It needs to be something like this, and now you've used "namea" you cannot use it to label another routine.

Code: Select all

	DI ; 4 clocks F3
	LD HL, $8002 ; 10 21 02 80
namea:	DEC HL ; 6 2B
nameb:	DEC HL ; 6 2B
namec:	INC (HL) ; 11 34
	JR NZ,namec ; 7/12 20 FD (they appear on this line)
	INC HL ; 6 23
	INC (HL) ; 11 34
	JR NZ, nameb ; 7/12 20 F8
	INC HL ; 6 23
	INC (HL) ; 11 34
	JR NZ, namea ; 7/12 20 F3
	EI ; 4 FB
	RET 
everything works fine with your code save for the ORG bit. nothing i do is working. a little help? i try 6000, 2000, hell i even did 100

this assembler is broken!

**Post edited by Admin (PJ). One potty mouth word removed.
User avatar
Guesser
Manic Miner
Posts: 641
Joined: Wed Nov 15, 2017 2:35 pm
Contact:

Re: ZXSpin assembler not working

Post by Guesser »

MrPixel wrote: Sat Mar 31, 2018 11:12 pm this assembler is broken!
If you're doing ORG 6000 (decimal) rather than ORG $6000 (hexadecimal) then you're asking it to assemble to ROM not RAM.

**Post edited by Admin (PJ). Potty mouth word removed from [mention]MrPixel[/mention] section.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: ZXSpin assembler not working

Post by MrPixel »

Guesser wrote: Sat Mar 31, 2018 11:36 pm
MrPixel wrote: Sat Mar 31, 2018 11:12 pm this assembler is broken!
If you're doing ORG 6000 (decimal) rather than ORG $6000 (hexadecimal) then you're asking it to assemble to ROM not RAM.
how do i run the code in zxspin window (not the assembler) :?:
User avatar
R-Tape
Site Admin
Posts: 6400
Joined: Thu Nov 09, 2017 11:46 am

Re: ZXSpin assembler not working

Post by R-Tape »

MrPixel wrote: Sat Mar 31, 2018 11:12 pm everything works fine with your code save for the ORG bit. nothing i do is working. a little help? i try 6000, 2000, hell i even did 100
It's not broken!

If you're using SPIN and starting out here are some tips:

These numbers are in DECIMAL.

1 - In the emulated Spectrum put the stack in a safe place. Do this by typing CLEAR 32767 in BASIC. You can go lower than this but don't worry about that yet. The stack will now safely build below your code.
2 - assemble your code at ORG 32768. This is the start of fast (uncontended) memory. The highest byte you can go to is 65535.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: ZXSpin assembler not working

Post by Nomad »

Senor pixel, its going to hurt worse the longer you put off using a dedicated assembler...

Look up the zx spectrum memory map.. Your figure out what has gone wrong. What the guys tell you is true also. Check your number base. Its nice if you want to start with hexadecimal number values but its important to stick to it, mixing and matching makes its hard to debug later. Doing it decimal is a legit choice its totally a personal thing. Just pick and stick.

What I tend do do is go for C350 (hex)/50000 (dec), most small programs your going to do for a long while yet are going to be wee titdlers. No need to max out available memory. :lol: Your soon figure out when you run out of memory anyhow.
Spoiler
Now fella not to belabor the point... but I see this in your future...
Image
Last, do yourself a favor. Time to empower yourself with some book learning. Read the following chapter. Once you get it your understand what happened and what ya need to do.

http://www.worldofspectrum.org/ZXBasicM ... hap24.html

Write the notes out longhand, draw your own diagrams and your remember the memory map a whole lot faster. That copy and paste stuff does not work half as well. Something about writing the information down with your own hand helps it go in & seeing your notes in your own hand.
Spoiler
But I gotta feeling that ain't going to happen somehow. :lol: Well up to you.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

[mention]Nomad[/mention] is right, you need to spend some time reading through some of the beginner books and tutorials to get you started. I know its a pain, but it really is the only way. Its well worth it!
AndyC
Dynamite Dan
Posts: 1404
Joined: Mon Nov 13, 2017 5:12 am

Re: ZXSpin assembler not working

Post by AndyC »

Yeah, I think you're just hitting one of the biggest speed bumps when transitioning from BASIC to machine code, notably that the number of decisions the tools make for you are significantly less. In BASIC you don't have to worry about where your code is, you don't have to worry about where your variables are but machine code is the exact opposite end of the spectrum (so to speak). You have to make every decision, the assembler you use isn't going to do it for you. So you have to understand how the memory map work, which bits you can use and which bits are in some way "special" - for example the screen memory.

One result of giving you all that power and pretty much requiring you to understand it, is that the tools are not ever likely to be quite as "helpful" as BASIC is. The error messages can tend to be a little more vague and often you won't get entirely helpful (if any) error message for certain kinds of mistake. There is an implicit assumption you won't tend to try and name label the same as assembly reserved words and registers, so those kinds of error tend to lead to cryptic messages. Likewise many assemblers will let you do seemingly crazy things just because it's assumed you know what you are doing. So LD A, 257 will often assemble just fine as LD A,1 - because the tools are assuming you implicitly wanted only the lower 8 bits of a number. This kind of thing can be handy and infuriating in equal measures, but ultimately you tend to just have to live with it.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: ZXSpin assembler not working

Post by MrPixel »

Ast A. Moore wrote: Wed Mar 28, 2018 10:26 am
R-Tape wrote: Wed Mar 28, 2018 5:59 am I still make my TAP files in the emulator using 'insert tape' and SAVE""CODE from speccy BASIC.
Wow, dude . . . That’s, like, not cool, man. :lol:

Glad I spent some time creating a syntax highlighter and a few scripts and templates for the TextMate+zasm combo.
and after? i use real tape mode and save but all it says is press play on tape, shows a flashing border, than nothing.
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: ZXSpin assembler not working

Post by Seven.FFF »

Post the tap file, and we’ll be able to see if it’s ok or if you have a loading problem.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: ZXSpin assembler not working

Post by Nomad »

Hey Pixel, get yourself a dropbox or github. That way you can post your tap's/dsk/tzx files to. That way when you have a problem, or want to share your work you can link people to it.

What helped me was putting a development log on this website - that way you got one place to ask all your questions, strut your stuff, and it keeps you 'accountable to your goals'.

People were real good to me and helped a whole bunch. Its very different to other communities. You put the effort in and people will teach you what you need. None of that elitist BS you find in other places, with the spectrum people for the most part its the opposite (usually).
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZXSpin assembler not working

Post by Alessandro »

I'll put it bluntly: Do not use the ZX Spin in-built assembler. It's buggy and has not been updated for ages.

With due respect to Dunny's work (I'd really like to see an updated version of his emulator), I strongly recommend everyone wishing to write and assemble their Z80 Assembly code to stick to their favorite text editor and assembler; my personal choices are Notepad++ and Pasmo respectively.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

Alessandro wrote: Mon Apr 02, 2018 10:59 am my personal choices are Notepad++ and Pasmo respectively.
Do you use any of the external command tools in Notepad++ [mention]Alessandro[/mention]? I can never work out how they work, so any tips appreciated.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: ZXSpin assembler not working

Post by Alessandro »

PeterJ wrote: Mon Apr 02, 2018 3:33 pm Do you use any of the external command tools in Notepad++ @Alessandro? I can never work out how they work, so any tips appreciated.
Do you mean the plugins? Actually not, I even turned autocompletion off because it interfered too much with composition.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZXSpin assembler not working

Post by PeterJ »

Alessandro wrote: Mon Apr 02, 2018 5:19 pm
Do you mean the plugins? Actually not, I even turned autocompletion off because it interfered too much with composition.
Sorry, I mean automating the task of compiling with Pasmo from within Notepad++, or do you just use the command line?
Post Reply