CPCWiki forum

General Category => Programming => Topic started by: eriktier on 12:02, 08 May 18

Title: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: eriktier on 12:02, 08 May 18
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
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: andycadley on 18:58, 08 May 18
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. :-)
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: tjohnson on 19:16, 08 May 18
nice one, you must be quite a talented programmer!
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: menegator on 19:53, 08 May 18
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...
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: Sykobee (Briggsy) on 13:00, 10 May 18
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!
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: eriktier on 18:44, 10 May 18

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

Quote from: Sykobee (Briggsy) on 13:00, 10 May 18
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!
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: SRS on 11:10, 11 May 18
I used this one for ages:
Quote10000 '********************************
10001 '*      CPC  International      *
10002 '*        Z 80-ASSEMBLER        *
10003 '*    c 1985 Matthias Uphoff    *
10004 '********************************


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

Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: eriktier on 11:55, 11 May 18

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

Quote from: SRS on 11:10, 11 May 18
I used this one for ages:
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: eriktier on 19:51, 16 May 18
I've just posted part II on my blog: https://erikvandertier.com/blog/personal/basm-basic-assembler-part-2/


Cheers,
  Erik
Title: Re: reliving 30+ year old memories by building a Z80 assembler in Basic
Post by: AMSDOS on 12:33, 20 May 18
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
Powered by SMFPacks Menu Editor Mod