armips
armips copied to clipboard
Gameboy/Z80 architecture
This adds the Z80 architecture and instruction set, as well as the Game Boy (Color) and Nintendo e-Reader instruction sets, which are based on Z80.
The following directives can be used:
-
.z80
- Full Z80 instruction set -
.gb
- Game Boy (Color) instruction set -
.ereader
- Nintendo e-Reader instruction set
The syntax is based on the official Z80 documentation and Pan Docs (for Game Boy), but I've also added some other aliases I've commonly seen. I also made some personal additions:
-
jp hl
,jp ix
, etc. are accepted as alternatives forjp (hl)
,jp (ix)
etc. Reason: unlike what the official syntax implies,pc
is set to the value of the register directly, and no memory access is done. -
sub a,b
,sub a,c
etc. are accepted as alternatives forsub b
,sub c
etc. This also applies forand
,xor
,or
andcp
. Reason:add
,adc
andsbc
all have the destination (a
) as part of their operand list, so this allows for better consistency with those opcodes. - For e-Reader I added a
rst 0,n
andrst 8,n
shorthand for calling the e-Reader API functions more easily, so you don't have to write a.db
after everyrst
.
I love this PR, I know the tool is armips and not armipz80, but still a remarkable patch, what do you think @Kingcom ?
I don't see an issue tab on the fork's page, so I guess I'll report it here. I've been using this fork for quite a while now, and I've gotten a good amount of use with it. However, it unfortunately doesn't seem to support all opcodes, which seems to mostly be indirect addressing related. For example, this line of Z80 code doesn't compile.
ld (0xC115),hl
So I have to substitute it with this.
.db 0x22
.dh 0xC115
It is a valid instruction, per here: https://baltazarstudios.com/webshare/A-Z80/Z80-Opcode-Tables.pdf
For example, this line of Z80 code doesn't compile.
The following compiles fine for me:
.z80
.create "output.bin",0
ld (0xC115),hl
.close
Which outputs 22 15 C1
as you would expect.
This opcode is also included in the instruction set tests: https://github.com/Prof9/armips/blob/gameboy/Tests/Z80/Z80%20Opcodes/Z80%20Opcodes.asm#L39
Side note: I originally created this fork as I was planning to work on some Game Boy projects, but ended up not going through with that. So I haven't really used this fork much personally.
Thanks so much for the timely reply! I was missing the .z80
tag. I had .gb
originally. I overlooked the fact the GB has a limited instruction set.