Question

I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 assembler.

However, I don't have a Z80 processor to hand, and would like to do it on my PC (I have windows or linux so either is good). I've found various assemblers around on the internet, but I'm not particularly interested in assembling down to a hex file, I want to just be able to assemble it to something that some kind of simulator on the PC can run. Preferably this simulator would show me the contents of all the registers, memory locations etc, and let me step through instructions. I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? If there are good simulator/IDE things available for another type of assembler then I could try that instead (assuming there is a good online reference manual available).

Was it helpful?

Solution

I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions?

Write one. You're best off picking a nice, simple instruction set (Z80 should be perfect). I remember doing this as a first-year undergraduate exercise - I think we wrote the simulator in C++ and simulated 6800 assembly, but really any language/instruction set will do.

The idea of "learning assembly language" these days is to get the idea of how computers work at the lowest level, only a select few (compiler writers, etc.) have any real reason to actually be writing assembly code these days. Modern processors are stuffed full of features designed to be used by compilers to help optimise code for speed/concurrent execution/power consumption/etc., and trying to write assembly by hand for a modern processor would be a nightmare.

Don't fret about getting your application production-ready unless you want to - in all likelihood the bits of software you've found so far were written by people exactly like you who wanted to figure out how assembly works and wrote their own simulator, then realised how much work would be involved in getting it "production ready" so the general public could use it.

OTHER TIPS

You might want to check out the open source 8085 simulator "GnuSim8085", it's specifically meant to be used for educational purposes, and it was in fact written by student while preparing for his exams. It runs on both, Linux and Windows.

If Your are on windows 8085 Simulator is the best choice. 8085 Simulator by J-tech Softwares

It user interface is excellent than any other simulator. Also this simulator provide live view of memory map very time(also while in the execution).

But this one does not support Windows 98 or lower for that you need to check other simulators like "GnuSim8085".

MipSim is FREE

http://www.mipsim.com

Main Features of MIPSim 2

  • Built-in code editor with features like syntax highlighting and folding
  • Display register and memory values in different representations (signed integer, unsigned integer, hexadecimal and ASCII)
  • Set the block size (full-word, half-word, byte) of the memory cells for easier examination of the memory values
  • Change values of registers and memory cells with a single click even during simulation and debugging
  • Realtime user-interface updating allows you to see how values of registers and memory cells change during execution
  • Built-in debugger with step-by-step instruction execution, instruction skipping and breakpoint features
  • Tools for inserting ASCII, UNICODE strings and integer values to memory for testing of your code
  • Tools for checking duplicate or missing labels and instruction parameters
  • Save computer state (values of all registers and memory cells) so that next time you run the simulator you can continue from where you left!
  • Set the simulation speed - low speeds are great to trace your code and to see how it behaves
  • Encode instructions - produce machine code in either binary or hexadecimal representation
  • Catch assembly time and runtime errors
  • Easier debugging with descriptive error messages
  • Multi-threaded design - MIPSim doesn't get stuck (hopefully ;) even if the assembly code executed is erroneous or contains infinite loops
  • MIPSim API - make your own programs that can read from and write to the registers and memory of MIPSim, great flexibility for powerful testing!

Aim higher! Try and get a simulator for a more powerful assembly language. Remember, Z80 and 808x were low-end processors with low-end and awkward instruction sets.

Something like VAX from DEC was regarded as the Rolls-Royce of instruction sets. And then there are crazy Risc instruction sets that do some really strange things. Maybe you can find definitions of those so that you can have a crack at implementing them.

You may be interested in this for a Z80 simulator, and I've had good experiences with WinAsm.

You might also consider learning x86 assembly language, which you could do using in-line assembler in Visual Studio - although it's a larger instruction set than Z80, you would have the advantage of being able to use much better tools than would be available for the Z80.

I've also just remembered that the Keil 8051 and Arm tools have a simulator in the IDE - there are size-restricted versions of these available for free download from www.keil.com

If you happen to already know .NET, then this may be of use:

http://www.viksoe.dk/code/asmil.htm

It's a little bit limited, and may only work with .NET 1.1, but you could atleast use a "modern" IDE for it, and there are plenty of docs around for it.

<%@ page language="Asm80386" %>
<%
Str:  DB "Testing...", 0

  mov eax, -2
  cmp eax, 2
  jle Label1
  xor eax, eax
Label1:
  lea esi, Str
  push esi
  call "Response.Write(string)"
  pop esi
%>
<br>EAX: <%= eax %>

Another option, if you want to go "hard core" is get something like FreeDOS and VMWare, and use that. I'm sure a garage sale (car boot sale? yard sale?) or second hand book shop would have a copy of Peter Norton's old DOS interrupts bible. :)

Personally, I learned x86 asm by using Turbo Pascal (which I think is now free from Borland?), which had the ability to embed assembly instructions inside a function. Made it easier to setup the app, and I could focus on the stuff I wanted to do. I later used MacVAX at Auckland Uni, which was ok, but the VAX is very much dead - you may as well learn x86 :)

SimpSim is definitely worth a look. It's Windows only, but the feature set is pretty decent:

  • Main memory and register display
  • Built-in editor with syntax highlighting
  • Run, step, and break functions

WinApe is a good emulator of an Amstrad CPC. The Amstrad CPC was a Home Computer produced in the 80's. It used a Z80 as its CPU. Using the emulator you can display a lot of the internals while programming. It includes a debugger and a disassembler for Z80 code.

This wouldn't make any meaning to you now but just for people stopping by. This is the best assembly code simulator I have come across with. Truly worth it!

http://www.emu8086.com/

Take a look at Thomas Scherrer Z80 Emulators for a listing of potential emulators you could use.

I write z80 asm for the ZX Spectrum (still, I know :) ) and use SJasmPlus to link to a spectrum emulator file. Lots of of the better Spectrum emulators like Fuse and ZXSpin have built in editors as well for on the fly debugging and patching.

When I was in college we used PIC microprocessors. They are made by a company called Microchip. They also have a great IDE with a chip emulator/simulator that can allow you to do things without actually having the chips.

Why use an emulator?

Download MASM or NASM and write good old 80386 architecture. Plenty of online samples and learning tools.

Plenty of real-world reason to use assembler!

there is a simulator which is Visual6502 for teaching fundemental of microprocessor architecture. It has a editor, assembler, I/O operation and animation of how to work a microprocessor. I is available at the following link.

http://www.pcsistem.net/visual/index.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top