rzumer / dez80

A Z80 instruction decoding and (dis)assembly library.
MIT License
4 stars 1 forks source link

Enforce instruction validity #1

Closed rzumer closed 5 years ago

rzumer commented 5 years ago

It is currently easy to generate and format invalid instructions. Since this can result in oddly-formatted output or crashes due to hitting unimplemented!() match arms, it would be best to restrict instructions to standard ones.

One way would be to make the fields pub(self) with public accessors, add validation through the new() constructor, and ensure that from_bytes() generates instructions directly to prevent redundant validation.

rzumer commented 5 years ago

It is no longer possible to create invalid instructions, as the inner members of an Instruction are private, and there is no longer a public constructor besides from_bytes().

There are some concerns regarding exposing a constructor, so it is not supported for now.