[HN Gopher] My first Z80 assembly language program
___________________________________________________________________
My first Z80 assembly language program
Author : elvis70
Score : 93 points
Date : 2021-06-12 10:39 UTC (1 days ago)
(HTM) web link (nanochess.org)
(TXT) w3m dump (nanochess.org)
| varyherb wrote:
| > I was 9 years old and I wanted to write amazing games...After
| four years of writing games in BASIC language, I felt like I was
| stopped by the slowness inherent to an interpreted language.
|
| Wasn't sure I was reading this correctly, so I navigated to the
| About Me page:
|
| > Born in 1978, I started programming at age 5 in BASIC, learnt
| assembly language by age 9
| kragen wrote:
| I was in a similar situation, and I think the slowness inherent
| to an interpreted language was a big frustration to all of us
| kids programming in BASIC in the 01980s.
|
| Unfortunately I didn't have the guidance and direction Oscar
| Toledo G. had--my father did what he could, but he's just not
| an educator, and he's also not the same level of wizard as his
| father Oscar Toledo E.--so I didn't learn assembly until I was
| about 13, and then I learned from a book. (Also, I suspect
| Oscar Toledo G. has more innate aptitude than I do, but I think
| that in this case my lack of practice and feedback is what was
| holding me back.) I didn't write my first playable game until I
| was 29, which was http://canonical.org/~kragen/sw/inexorable-
| misc/tetris. (I wrote some games earlier, but they were just
| unplayably bad.)
| KingOfCoders wrote:
| My first larger code was the towers of Hanoi on CPC, where I
| found the algorithm while experimenting with coins of different
| sizes, somewhere around 12. Still very proud that I found a
| solution algorithm.
| jkh1 wrote:
| This brings back memories. My first Z80 assembly program was a
| jetpac game for the Sinclair ZX80 around 1984 because I couldn't
| get a ZX Spectrum to play it. I don't think any written copy
| still exists but there's still a copy on a cassette tape.
| the_af wrote:
| His whole website is pretty cool and filled with retro gaming
| goodness. Thanks for sharing!
| thom wrote:
| Always like seeing Oscar's site pop up here, so that I can tell
| people to check out the lovely annotated source code for Toledo
| Nanochess, his IOCCC-winning tiny chess engine:
|
| https://nanochess.org/chess3.html#book
| canada_dry wrote:
| I have a very similar stack of lined graph paper with my Z80
| 'trek' game that I developed when I was ~15yo. I found this book
| [i] to be a fantastic resource - it taught me so much about
| microprocessor and computer architecture.
|
| [i] https://archive.org/details/programmingz8000zaks
| mark-r wrote:
| I'm really happy to see I wasn't the only one who got their
| programming start on graph paper. Lost all my old sources
| though.
| elvis70 wrote:
| The author has made his book freely available :
| http://www.z80.info/zaks.html
| tyingq wrote:
| If you download his MSX rom, from
| https://nanochess.org/archive/karate2.zip and then unzip, and
| extract the karate2_msx.rom file, you can play it online.
|
| https://webmsx.org/ is an online MSX emulator. Just click the
| "load files" link and give it the ROM file. Space bar and arrow
| keys for controls.
| JKCalhoun wrote:
| Yes, I found it is simplest to drag the 'karate2_msx.rom' to
| your browser and select 'Cartidge 1' from the popup.
| KingOfCoders wrote:
| If you do Z80, best book (one of the books I love most)
|
| "Z80 Assembly Language Subroutines"
| elvis70 wrote:
| I agree,
| https://archive.org/details/bitsavers_osborneboogeSubroutine...
| Schiphol wrote:
| I have a question for people reading this article. Where did you
| get ahold of the relevant docs, back in the 80s? I remember being
| dimly aware that there was something called 'machine code' which
| was like BASIC but much faster. But that was it.
| awwaiid wrote:
| IIRC my commodore 64/128 manual came with BASIC and some
| assembly documentation. Different world when your turn on the
| machine and ... Get basically a REPL.
|
| I did the same thing as the author, wrote BASIC until I needed
| a faster inner loop (doing some simulation like cellwar or
| something) and picked up asm to make it (just the inner loop)
| faster.
| tyingq wrote:
| For me, mostly from hobbyist magazines that led to BBS dial up
| numbers that had made copies of software and docs. Though that
| was tricky, since long distance calls were expensive. So you
| dealt mostly with whatever a local BBS had, which I assume
| varied in depth, breadth, quality, etc.
| jacquesm wrote:
| Leventhal's CPU series was pretty good, also every manufacturer
| makes reference manuals for their instruction sets. I still
| have mine (pretty dog eared, just for sentimental value,
| unlikely to ever be used again).
| pmontra wrote:
| Not the author but I bought a book about assembler for my
| Sinclair ZX81. I just discovered it's got a Wikipedia page
| https://en.wikipedia.org/wiki/Programming_the_Z80
|
| Edit: wow, see this comment of elvis70
|
| > The author has made his book freely available :
| http://www.z80.info/zaks.html
| Schiphol wrote:
| Thanks! I might just learn it, 35 years after the fact :)
| Doctor_Fegg wrote:
| The Sinclair ZX81 manual had the full list of Z80 opcodes in it
| - Appendix A in http://zxnext.narod.ru/manuals/ZX81_Manual.pdf
| . So with that you could start PEEKing and POKEing and
| experimenting.
|
| I never really did any Z80 coding on the ZX81 itself, but that
| section of the manual came in really useful when I got an
| Amstrad CPC, which is what I learned Z80 on. To that I added
| The Ins & Outs of the Amstrad
| (https://cpcrulez.fr/book_english-
| the_ins_and_outs_of_the_ams...), which documented the firmware
| and other CPC-specific stuff.
| elvis70 wrote:
| Personally, it was books!
| _joel wrote:
| Kudos, I think this trumps me writing my name in a goto loop in
| qbasic that I did when I was 9. Still the sense of accomplishment
| dictated the next 30 years of my life so not bad I guess :)
| zh3 wrote:
| Back in '78 or so, my first computer was a hand-assembled Nascom
| I (2MHz Z80)[0] with 1kb of RAM. No assemblers, no disk drives,
| not even a cassette tape. Just a keyboard and a simple ROM that
| let you load hex values in memory. The low-res video display was
| memory-mapped, so after much study of circuit diagrams,the Mostek
| Z80 manual and the ROM I got to understand memory addressing,
| where the screen was and how the hardware worked. So my first Z80
| program was just 3 instructions entered as hex opcodes; all it
| did was splat an asterisk on the screen but what a buzz I got at
| the time :) ld a,2a # Load ASCII '*' in to
| acc ld hl,d80 # Set HL to point to video-mapped RAM
| ld (hl),a # Put character on screen.
|
| Some years later I wrote one of the first multi-user games,
| picked up by British Telecom to run on their Prestel/Micronet
| network. By that time I've graduated to 4MHz Z80s, with home-made
| 2MB RAM disks and 256Kb of main RAM accessed with a crude TTL
| MMU; we got up to 64 users per Z80, albeit accessing the system
| via 1200/75 baud modems.
|
| [0] It graced the cover of Issue #1 of Personal Computer World; I
| still have a copy.
| JoeAltmaier wrote:
| My first 8080 game was 'fly', where an X would flit around the
| screen and turn 45 degrees left when you hit the space bar. You
| tried to keep it on the screen and not touching some obstacle (a
| wall that extended down the top about 1/3 the way across?).
| Pointless but fun to write!
___________________________________________________________________
(page generated 2021-06-13 23:01 UTC)