How to access undocumented z80-instructions in SDCC (sdasz80)?

Pagina 1/2
| 2

Door Bengalack

Hero (590)

afbeelding van Bengalack

16-08-2020, 10:59

I've tried to find an easy way to enable the undocumented instructions. Is there a way? An option like "-enable_undocumented" would be preferable. I need it as I develop the "foundation" in C and then mix this highly with assembly code.

I figured out a workaround though, making my own macros, but it's a bit more work and not as "clean" Smile

.macro ld____d_iyh
	.db 0xFD, 0x54	; 10 MSX cycles
.endm

.macro ld____e_iyl
	.db 0xFD, 0x5D	; 10 MSX cycles
.endm

.macro ld____iyh_d
	.db 0xFD, 0x62	; 10 MSX cycles
.endm

...etc
Aangemeld of registreer om reacties te plaatsen

Van Giangiacomo Zaffini 2

Champion (265)

afbeelding van Giangiacomo Zaffini 2

16-08-2020, 15:15

If only SDCC assembler could synch/catch-up its upstream ASxxxx cross assemblers, ASxxxx's asz80 assembler has some undocumented Z80 instructions. See BP.4.11 Z80 Undocumented Instructions paragraph of ASxxxx Cross Assembler Documentation.

Van Bengalack

Hero (590)

afbeelding van Bengalack

16-08-2020, 20:11

Nice. I got hopeful now, but as you say, that version is not included in SDCC. From the new documentation (2019), it seems like one can just add ".z80u" as a directive in the code. Nice. But not nice that SDDC includes a version from 2012 Sad

F:\tool\SDCC\bin>sdasz80.exe

sdas Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180 / ZX-Next / eZ80)


Copyright (C) 2012  Alan R. Baldwin

Van ARTRAG

Enlighted (6845)

afbeelding van ARTRAG

14-03-2022, 18:11

Use this in your inline ASM code in SDCC

	.z180
	.allow_undocumented

The SDASZ80 version with SDCC is buggy. The .allow_undocumented directive should be supported also with .z80
It happens instead that it is supported only by the .z180

Van Bengalack

Hero (590)

afbeelding van Bengalack

14-03-2022, 19:53

ARTRAG wrote:

The SDASZ80 version with SDCC is buggy.

Buggy in what way? Producing non-optimal code, or producing wrong (assembly) code?

Also, IIRC, some of the guys are working on bringing the asxxxx version included up to date (but I'm not aware of any target date for this)

Van ARTRAG

Enlighted (6845)

afbeelding van ARTRAG

14-03-2022, 20:11

If you use .allow_undocumented with .z80 it simply doesn't allow you to use undocumented instructions.
If you use .z180 and .allow_undocumented it will accept and correctly compile all ixh/l,iyh/l opcodes

Van Grauw

Ascended (10604)

afbeelding van Grauw

14-03-2022, 21:32

But the Z180 is the one Z80 variant that doesn't support IX and IY H and L! (Afaik.)

Van ARTRAG

Enlighted (6845)

afbeelding van ARTRAG

14-03-2022, 22:23

But asz80 works with it

Van ARTRAG

Enlighted (6845)

afbeelding van ARTRAG

16-03-2022, 10:22

Also using the directive
.zxn
will enable all undocumented opcodes. Only the reported CPU timings will be wrong (because computed on the Z80n)

Van Ped7g

Resident (57)

afbeelding van Ped7g

16-03-2022, 11:18

z80n has same timings as z80 (plus it has 29 extra instructions in the ED prefix area).
(thinking about my post twice.. wait, this is MSX forum, so you have all those extra wait states to round regular Z80 timing to divisible by 4, right? Ok, then z80n timing does differ, if you had previously msx/cpc timings for z80)

Van Grauw

Ascended (10604)

afbeelding van Grauw

16-03-2022, 17:48

MSX has an M1 wait cycle to relax the timing requirements of instruction fetch (see figure 21 of the Z80 manual), but no rounding to multiples of 4 cycles. RAM is not shared with the VDP so there’s no need for rounding (at least I presume that’s what the CPC’s rounding is for).

MSX instruction cycle timings are shown in the second column here.

Pagina 1/2
| 2