Skip to content

Instantly share code, notes, and snippets.

@Lerc
Lerc / RegTest.hx
Last active August 29, 2015 14:10
A Haxe Macro example. Allows class properties to be added that map to an array entry. I made this for a project using JavaScript typed arrays for speed.
import js.html.Uint8Array;
@:build( RegisterMacro.memoryMappedRegister("r0",123) )
class RegTest
{
var ram : Uint8Array;
public function new() {
ram = new Uint8Array(65536);
}
switch (instruction & 0xf000) {
case 0x0000: { //nop movw muls mulsu fmul fmuls fmulsu cpc sbc add
switch (instruction & 0x0c00) {
case 0x0000: {
switch (instruction & 0xff00) {
case 0x0000: { //nop
}
case 0x0100: { //movw