All Projects → maziac → z80-sample-program

maziac / z80-sample-program

Licence: MIT license
This is a small Z80 assembler program that just puts some colored lines on the ZX Spectrum's screen. The intention is to use this as a kind of tutorial for DeZog (Z80 debugger).

Programming Languages

scheme
763 projects
assembly
5116 projects

Projects that are alternatives of or similar to z80-sample-program

APISearch-Plugin-x86
APISearch Plugin (x86) - A Plugin For x64dbg
Stars: ✭ 46 (+228.57%)
Mutual labels:  asm
FutureDOS
A futuristic DOS
Stars: ✭ 46 (+228.57%)
Mutual labels:  asm
discovery
辅助Android开发者在多模块工程间跨模块获取接口(或抽象类)的实现类的开源库,可实现模块的顺序初始化、业务的动态组合等实现。基于AGP和ASM开发。
Stars: ✭ 46 (+228.57%)
Mutual labels:  asm
woodpecker-client
异常日志收集客户端 环境隔离版本
Stars: ✭ 51 (+264.29%)
Mutual labels:  asm
neskell
A Haskell 6502 Emulator
Stars: ✭ 56 (+300%)
Mutual labels:  asm
Uatu
Android方法调用跟踪 ; 方法耗时统计 ; 方法调用参数以及返回值跟踪 ; 方法调用替换;方法hook
Stars: ✭ 93 (+564.29%)
Mutual labels:  asm
Recaf
The modern Java bytecode editor
Stars: ✭ 3,374 (+24000%)
Mutual labels:  asm
DevSound
Game Boy sound driver
Stars: ✭ 48 (+242.86%)
Mutual labels:  asm
fastquery
FastQuery(Method of fast database query) 基于Java语言. 他的使命是:简化Java操作数据层.做为一个开发者,仅仅只需要设计编写DAO接口即可,在项目初始化阶段采用ASM生成好实现类. 因此,开发代码不得不简洁而优雅.从而,大幅度提升开发效率.
Stars: ✭ 63 (+350%)
Mutual labels:  asm
512-byte-vm
A VM image in 512 bytes. Yes, you read it right.
Stars: ✭ 29 (+107.14%)
Mutual labels:  asm
helloworld
Hello world and other commented GameBoy assembly examples for beginners.
Stars: ✭ 31 (+121.43%)
Mutual labels:  asm
kasm
Assembler library for Kotlin
Stars: ✭ 40 (+185.71%)
Mutual labels:  asm
APIInfo-Plugin-x86
APIInfo Plugin (x86) - A Plugin For x64dbg
Stars: ✭ 42 (+200%)
Mutual labels:  asm
8086-cheatsheet
8086 Microprocessor Cheat sheet with Programs
Stars: ✭ 81 (+478.57%)
Mutual labels:  asm
ArvernOS
💾 A minimal, experimental and "toy" monolithic kernel to learn about OS development // Work In Progress
Stars: ✭ 313 (+2135.71%)
Mutual labels:  asm
C.sh
Inline C/asm in Bash
Stars: ✭ 241 (+1621.43%)
Mutual labels:  asm
boot2flappy
Flappy Bird as bootable UEFI executable
Stars: ✭ 48 (+242.86%)
Mutual labels:  asm
cmake-nasm-test
Building a nasm hello world app with cmake
Stars: ✭ 18 (+28.57%)
Mutual labels:  asm
z80count
A tool to annotate Z80 assembler with cycle counts
Stars: ✭ 28 (+100%)
Mutual labels:  asm
dcc
Direct/Interactive C Compiler
Stars: ✭ 18 (+28.57%)
Mutual labels:  asm

z80-sample-program

Introduction

This is a small Z80 assembler program that just puts some colored lines on the ZX Spectrum's screen.

The intention is to use this as a kind of tutorial for DeZog (Z80 debugger).

Prerequisites

  • Visual Studio Code (vscode)
  • DeZog (>= v2.4.0)

The program runs in the internal Z80 simulator but you can optionally run it on another emulator:

If you want to build the Z80 binary yourself (not required if you just want to test debugging):

Building

First if you just want to test debugging with the 'DeZog' extension there is no need to build/assemble the required files. The binaries are included in this repository so that you could also directly start to debug.

However, if you would like to do some changes you need to compile. From the menu choose "Terminal->Run Build Task..." tasks.json is configured such that it will call sjasmplus with the required parameters.

There are several .asm files which are all included in the main.asm file. This file is the one being assembled.

After the build is ready a z80-sample-program.sna file is created which can be used with ZEsarUX.

Running the Debugger with the Internal Z80 Simulator

The project comes with 3 configurations. one for ZEsarUX, one for the internal Z80 simulator and one for Z80 unit tests.

Choose the Z80 simulator first:

Now start the debug session by pressing the green arrow:

You should be left with a stopped program.

To the right you see the Z80 simulator. The black rectangle is the ZX Spectrum screen.

From here you can:

  • step into, step over, step-out
  • click on the call stack: It will navigate directly to the asm file.
  • hover over register in the asm file: It will show the values and also (if available) the corresponding labels.
  • change register values: a double click on the value of a register in the REGISTER area will allow you to enter a different value.

The internal Z80 simulator does allow only basic Z80 or ZX 48K/128K debugging and is slow. For real emulation and other features (like ZXNext HW emulation) setup ZEsarUX.

The Program Itself

The program is only for educational purposes. It does nothing more than drawing colored lines on the screen.

It does so by manipulating the color screen area (0x5800).

The action takes place in the 'main_loop':

  1. it draws a one color line
  2. it waits for half a second
  3. it proceeds to the next line
  4. loop from 1

Debug with ZEsarUX

To debug the project first start ZEsarUx and enable the remote port (RCP) either by command line (--enable-remoteprotocol) or from the UI ('Settings->Debug->Remote protocol' to 'Enabled'). The debug adapter uses the port 10000 which is ZEsarUX default, so you can leave this unchanged.

When ZEsarUX is up and running start debugging from vscode. Select ZEsarUX and press the green triangle:

Now the following happens:

  1. A socket ZRCP connection is opened to ZEsarUX
  2. The snapshot (z80-sample-program.sna) is loaded to ZEsarUX
  3. The breakpoints are reset
  4. The .sld file is read
  5. vscode requests the 'CALL STACK' and the 'VARIABLES' from ZEsarUX

You should be left with a stopped program like before with the Z80 simulator.

From here you can:

  • step into, step over, step-out
  • click on the call stack: It will navigate directly to the asm file.
  • hover over register in the asm file: It will show the values and also (if available) the corresponding labels.
  • change register values: a double click on the value of a register in the REGISTER area will allow you to enter a different value.

Debug with CSpect

To debug the project first start CSpect together with the DeZog/CSpect Plugin. The plugin DLL needs to be placed in the same direct as the CSpect.exe.

Start CSpect from the console to verify that the DeZog/CSpect Plugin has started. You should see an output like "DeZog plugin started." followed by the port address the plugin is listening to.

When CSpect is up and running start debugging from vscode. Select CSpect and press the green triangle:

Now the following happens:

  1. A socket DZRP connection is opened to CSpect
  2. The snapshot (z80-sample-program.sna) is loaded to CSpect
  3. The breakpoints are reset.
  4. The .sld file is read
  5. vscode requests the 'CALL STACK' and the 'VARIABLES' from CSpect

You should be left with a stopped program like before with the Z80 simulator.

From here you can:

  • step into, step over, step-out
  • click on the call stack: It will navigate directly to the asm file.
  • hover over register in the asm file: It will show the values and also (if available) the corresponding labels.
  • change register values: a double click on the value of a register in the REGISTER area will allow you to enter a different value.

Debug with ZX Next Computer

To debug on a ZX Next you need serial cable to connect your PC/Mac with the ZX Next. There is also some setup required on the ZX Next. Please refer to the documentation in DeZog.

The launch.json must be modified to contain the serial interface of your PC/Mac:

	"zxnext": {
		"serial": "<your COM port>"
	}

For a list of serial ports available on your PC/Mac you can use the command palette (F1):

Here is an example result (for a Mac):

If everything is setup, start the ZXNext configuration (green triangle):

Unit Tests

The program also includes some unit tests to test the different memory fill subroutines. DeZog (as of v2.4.0) includes the functionality to run the unit tests from the vscode graphical UI (the test explorer).

Select the chemistry beaker icon on the left:

Further details how to setup unit tests can be found here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].