Author Topic: reliving 30+ year old memories by building a Z80 assembler in Basic  (Read 553 times)

0 Members and 1 Guest are viewing this topic.

Offline eriktier

  • CPC464
  • **
  • Posts: 4
  • Country: nl
  • Liked: 11
During my recent vacation I decided to write a Z80 assembler in Locomotive Basic, with the specific goal of being able to assemble and run a simple program by the end of the vacation (ended up taking les s than 3 days :): https://erikvandertier.com/blog/coding/basm-basic-assembler-part-1/
The GitHub repo can be found here: https://github.com/eriktier/BASM
I've gotten quite a bit further on it since the end of my vacation. Next plans are to finish it (support full instruction set and at least support for labels), then built a simple game using it and finally porting the assembler to assembler and have it assemble that version ;)
Anyway, hope you enjoy and get inspiration for your own projects.


Cheers,
  Erik

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Liked: 342
Neat. I remember writing my first assembler in Locomotive BASIC and it taught me a fair deal about how the Z80 instruction set is arranged. It wasn't fast, but it worked. :-)

Offline tjohnson

  • Supporter
  • 464 Plus
  • *
  • Posts: 461
  • Country: gb
    • index.php?action=treasury
  • Liked: 129
nice one, you must be quite a talented programmer!

Offline menegator

  • CPC464
  • **
  • Posts: 13
  • Country: gr
    • index.php?action=treasury
  • Liked: 7
Wow,

I remember a disassembler that I wrote in basic as part of a memory monitor. It worked but it was sloooooow however I used it as proof of superiority both of locomotive basic and amstrad cpc 6128

In the end my program ended too big to be a useful monitir but the hell with it, i wrote it because i could!

I learned assembly in order to make a parser for a mini language used in my dbase like app, but in the end I abandoned it because the main program (writen in basic) became also too big to be usefull.

These were the days my friends...

Offline Sykobee (Briggsy)

  • 6128 Plus
  • ******
  • Posts: 657
  • Country: gb
  • Liked: 215
My first assembler was a BASIC program from CWTA.


You would write your ASM as BASIC comments in the assembler listing itself, which the assembler code would read from memory to assemble!

Offline eriktier

  • CPC464
  • **
  • Posts: 4
  • Country: nl
  • Liked: 11

Yeah, might have been the same as I used, and which is what I'm building now as well.

My first assembler was a BASIC program from CWTA.


You would write your ASM as BASIC comments in the assembler listing itself, which the assembler code would read from memory to assemble!

Offline SRS

  • Supporter
  • 464 Plus
  • *
  • Posts: 495
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 473
I used this one for ages:
Quote
10000 '********************************
10001 '*      CPC  International      *
10002 '*        Z 80-ASSEMBLER        *
10003 '*    c 1985 Matthias Uphoff    *
10004 '********************************


then switched to the advanced version:
Quote
10000 '***********************************
10010 '*****  CPC - Assembler V 2.0  *****
10020 '***** (c) 1987 DMV / M.Uphoff *****
10030 '***********************************

« Last Edit: 14:48, 11 May 18 by SRS »

Offline eriktier

  • CPC464
  • **
  • Posts: 4
  • Country: nl
  • Liked: 11

This might well have been the one I used as well. Hard to say after so many years ;)

I used this one for ages:

Offline eriktier

  • CPC464
  • **
  • Posts: 4
  • Country: nl
  • Liked: 11

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.413
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 683
I was too young to really understand what Machine Code was and what an Assembler did when I wanted to get back into typing in Type-ins. That occurred once I had typed in all the programs (mostly games), from the Magazines we had from 1985, which was a couple of ACUs and the Aussie The Amstrad User magazine. After that I was collecting Amstrad Action with Issue 44, the 1st program in that was the Game of Life with lengthy Machine Code loader. I remember making 2 mistakes in the data and the program stopped, so I removed the STOP command, fortunately the program didn't crash, unfortunately the program was corrected and the old version was wiped over. If there was ever a bad time to get into typing in programs AA44 presented challenges, after all I was using a 464, didn't know anything about Machine code, so the type-ins presented was Life, Binary Loader, Hacker extra which was just an explanation on using Hacker from AA43, the BASIC 1.1 Abstract program and the Discourse program. It was also the issue prior to AA launching their Typerwriter program!  :o
By AA48 I remember putting the magazine back on the stand at the newsagents because I missed AA45 with the Typewriter program and was so confused, it wasn't until my brother showed me that I didn't need the Typewriter program by typing in some checksummed programs in AA46, to get them working on our 464, I decided to buy more AA. That commenced with AA50, which was again another bad issue to be typing in programs from. Though on this occasion, most of the programs had bugs in them. I remember typing in Boggle and getting that to work by removing the BASIC 1.1 command that AA advised 464 users to do and then there was the Fireworks program & the David Hall screen demos. Later on when I got to understand the DATA being Machine Code, I used that to convert an early Assembly example from one of the early ACUs we had, which was of a simple game, you used your ship to shoot the other one down, though you also had to avoid the bombs it dropped in your direction. Anyhow, I remember the data it was coded in for the BASIC loader was in decimal, so I used the Data Creator in AA50 to make it Hexadecimal.

Though it wasn't until AA had permanent covertapes, I ever got into understanding Assembly language. The 3rd tape which had Spindizzy & Wizard's Lair, had a Toolkit program on it, which was the 1st Monitor program I had which had all these neat things for Disassembling, Viewing Memory and Poking to Memory as well as a Graphical Memory Representation of the memory being used and finally by the 5th Covertape, Devpac had arrived and that was when I started typing in Assembly programs!  :D