Click here to Skip to main content
15,886,664 members
Articles / Programming Languages / C++
Tip/Trick

A Full-Featured Z80/8085 Assembler in C++

Rate me:
Please Sign up or sign in to vote.
4.86/5 (8 votes)
14 May 2014CPOL1 min read 18.3K   561   12   3
A full-featured Z80/8085 assembler in C++

Introduction

The task of assembling an assembly language source file into a machine readable output is at the basis of modern computing despite all the modern compilers and interpreted languages that are now built on top of the basic machine language. The Z80/8085 is a basic but complete instruction set that allows conceptual learning and thinking about the topics of assembler without going in depth into special processor features.

Coming soon: A Windows program with editor and dialog (requested in comments), basic simulator for CP/M.

Background

Familiarity with C++, assembly language, Z80/8085, Backus Naur Form (BNF), parsing, tokenizing, semantic and syntactic checking are preferable.

Using the Code

Using the class is as easy as passing in a readable assembler file for input with a writeable listing file and writeable hex format file for output (both in "w" text format).

C++
Assemble(inputFile, listFile, hexFile, fileName);  

Points of Interest

Assertions are used for internal errors where execution can continue safely while blind throws are placed in for any critical internal errors generally representing a bug in the code as they should be impossible to reach if the design is correct. Thrown errors for syntactic and semantic errors are used.

Cycle checking is implemented using a form of depth first search algorithm through any symbol table expressions.

The Intel hex format is used. See: http://www.keil.com/support/docs/1584.htm. Opcodes and clock cycle information can be found at http://www.z80.info/z80code.htm and http://www.z80.info/zip/z80-documented.pdf.

Expressions are used extensively and due to the recursive use have allowed a greater set of possibilities in the assembler input than would ordinarily be seen.

History

  • Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCan someone send me the files that are needed please? Pin
Member 138582236-Jun-18 18:44
Member 138582236-Jun-18 18:44 
QuestionGreat Pin
Manikandan1018-May-14 3:12
professionalManikandan1018-May-14 3:12 
Generalmy vote of 5 Pin
Southmountain15-May-14 6:01
Southmountain15-May-14 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.