News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
J

Learning Z80 Assember

Started by Jase, 15:15, 05 September 11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jase

 :-\


Ok, many moons ago, I was fairly competent at x86 asm under DOS, and managed piss off my university lecturer by handing in a large chunk of my computer studies dissertation in, yes, x86 asm :) Imagine a huge print out of mov rol ror inc dec xor al ax bx rep movsb... I bet it never got read!


I now have, on it's way, a "Learn z80 asm" type tutorial kit, with half a thought of using it. I know it is very retro, but is knowledge of Z80 anything that can assist in future career moves? Is there any natural progression from Z80 that could help?


Just thinking really that VB/WPF/WCF is driving me nuts at the moment :( Such a nasty, broken framework. Microsoft certainly do know how to polish a turd.




steve

I think the z80 is still widely used in industry, and there is now the compatible eZ80 which is much faster.
Of course the PIC and other microcontrollers are used in far higher numbers, so don't count on z80 ability to get you a job.

redbox

I think that learning Z80 will definitely make you a better programmer as you lean to produce lean, mean code  :)

And this helps if you're looking to work with embedded systems (like PIC etc) because you'll be used to limited resources.

I've found it challenging but extremely satisfying.  The programming section of this forum is great as it's frequented by many talented coders who are always willing to help you out, plus there is a lot of Z80 and CPC source code on the net to get you started.

AMSDOS

I'm mainly using Assembly for specific routines which may benefit. I posted a few on this forum though found that sometimes when you post an earlier version of something, you can spot small ways of improving it.

Even with Assembly before you start diving into writing a routine (and in my case a small routine), writing it in Pseudocode (or something like Pseudocode which you can understand), helps put together a structure for how your routine works.

I tend to use Assembly a bit like a high level language and suck up to Firmware (cause it works in CP/M), that way it's a form of assembly. PUSHing and POPing are great, though you kind of have to know what values your placing into your registers. My Assembly book recommends using HL as a Pointer for instance and from that you can easily place a value from that address into your accumulator.

Z80 Assembly offers a wide range of Loops as well, I'm not sure why, I guess some ways have benefits over others as they vary in Clock Cycles. A DJNZ loop maybe slightly slower than a JR loop though DJNZ has a built-in Decrementer where it Decrements the B register by 1 until it has reached 0. JR Loops you have to tell it to Decrement a Register, though JR Loops offer other Conditions which DJNZ won't have. I guess since the Z80 incorporates the Instruction set from Intels 8080 processor though incorporating it's own set of instructions for more power this maybe the main reason why there's some variety.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Jase

Quote from: steve on 15:42, 05 September 11
I think the z80 is still widely used in industry, and there is now the compatible eZ80 which is much faster.
Of course the PIC and other microcontrollers are used in far higher numbers, so don't count on z80 ability to get you a job.
I wasn't going to rely on it to get a job. I was more wondering if it would help with a side-step. I hate to sound miserable, but I think there is only so far you can go programming windows/mac/linux apps. I am currently stuck with VB.net. Yes, its a fairly easy language for 95% of tasks - its just the other 5% of stuff that needs to be done. I really need to be in the 5% group. I think to start with, more of a hobby, then to job.


Quote from: redbox on 19:15, 05 September 11
I think that learning Z80 will definitely make you a better programmer as you lean to produce lean, mean code
And this helps if you're looking to work with embedded systems (like PIC etc) because you'll be used to limited resources.
Hey! I program in VB. I already write lean mean code! But I know what you mean. I remember the old days being in competition with friends trying to optimise the heck out of routines, going through the 386 opcode bible looking for shortcuts... (shr ax + shr bx instead of mul etc). Yeah, it was fun. I think embedded systems looks much more fun, far more specialised... it's just getting there.


Quote from: CP/M User on 23:44, 05 September 11I tend to use Assembly a bit like a high level language and suck up to Firmware (cause it works in CP/M), that way it's a form of assembly. PUSHing and POPing are great, though you kind of have to know what values your placing into your registers. My Assembly book recommends using HL as a Pointer for instance and from that you can easily place a value from that address into your accumulator.

Z80 Assembly offers a wide range of Loops as well, I'm not sure why, I guess some ways have benefits over others as they vary in Clock Cycles. A DJNZ loop maybe slightly slower than a JR loop though DJNZ has a built-in Decrementer where it Decrements the B register by 1 until it has reached 0. JR Loops you have to tell it to Decrement a Register, though JR Loops offer other Conditions which DJNZ won't have. I guess since the Z80 incorporates the Instruction set from Intels 8080 processor though incorporating it's own set of instructions for more power this maybe the main reason why there's some variety.
I am not really sure what I want to program. I think learning some basics would be useful, but I need a way of using them. I may need to get hold of the CPC firmware guide to work out basic screen access & sound access etc. I don't really want to write a demo or game (tried too much of that in years gone by), I just want to mess around and learn new skills. The Z80 seems like a really good "back to basics" mental reboot. I see what you mean about the various looping methods. Yay for cisc processors hey! But, as has been mentioned, embedded systems sounds far more interesting than application writing. I used to work for a comms hardware (backbone comms) company, and was in awe of what some some guys there were doing. Most of the stuff they did was way above my head... (well, everything was tbh) It's a shame they shut up shop and moved most of the intellectual stuff to China...


Well, the book/tutorial/etc should be arriving in a day or so. I get the feeling I can't really loose out, especially as Z80 is still being used. If anything, it should give me a mental workout  ;D 


Thanks,
Jason


MaV

Quote from: Jase on 00:24, 06 September 11
I wasn't going to rely on it to get a job. I was more wondering if it would help with a side-step. I hate to sound miserable, but I think there is only so far you can go programming windows/mac/linux apps. I am currently stuck with VB.net. Yes, its a fairly easy language for 95% of tasks - its just the other 5% of stuff that needs to be done. I really need to be in the 5% group. I think to start with, more of a hobby, then to job.

I can fully understand your motivation.
To program a current machine even at low level is usually a few abstractions above the bare metal.

May I suggest you acquire Rodney Zaks' Programming the Z80,  the Z80 bible? A tutorial may be good as first entry, but since you already know x86 assembly you will not have any problems at all mastering Z80 assembly.

Good luck!
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

ralferoo

Despite learning on Z80 myself, I'm not sure I'd particularly recommend it unless you have a particular application in mind (like, obviously CPC given this is the CPC wiki!)

If it's just learning assembler for the sake of it, I'd probably steer you towards 68000 (so ST or Amiga) or more esoterically something like PowerPC (Macs from a few years ago, GameCube, etc). That's not to discourage you from Z80, but the thing with the Z80 is you have limited registers and they all have specialised uses, whereas 68k and powerpc both have very nice and regular register usages. So, with the exception of the stack register on both, every register is more or less equal.

And another option still, if you can find a PS3 with an old enough firmware, the SPU processor (easily programmable under Linux) has probably the nicest instruction set I've *ever* programmed in assembler with. 128 registers and you can basically do what you want with them... :)

That said, I just got back into Z80 programming about 6 months ago after 22 years away and I'm absolutely loving the challenge. Z80 is definitely still fun... :)

Oh yeah, and there's a whole load of chips made by Rabbit which are based on Z80 and run at 50MHz or so with built in network ports etc, so Z80 is definitely not dead by any means...

TFM

68k doesn't even has I/O instructions. Bad!
Registers are unspecialized. Bad!
You can't use 16 or 8 bit parts of 32 bit registes properly (like in Z80). Bad!

No Thanks! (since 1987 ;-))
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Powered by SMFPacks Menu Editor Mod