1
0

emualtor working

This commit is contained in:
Aiden
2026-05-25 21:00:25 +10:00
parent 3ab79648ff
commit 752148c585
22 changed files with 588 additions and 22 deletions

View File

@@ -7,6 +7,8 @@ from dataclasses import dataclass
from pathlib import Path
from typing import Any
from .consistency import is_byte_immediate_to_word_destination
JsonObject = dict[str, Any]
@@ -195,6 +197,8 @@ def _file_header(source_name: str, payload: JsonObject) -> list[str]:
"u8 CCR, BR, EP, DP, TP;",
"int C, Z, N, V;",
"",
"static inline u16 zero_extend8_to16(u8 value) { return (u16)value; }",
"",
]
@@ -648,6 +652,8 @@ def _translate_instruction(ins: JsonObject, labels: dict[int, str]) -> str:
if base in {"MOV", "MOV:G", "MOV:I", "MOV:E", "MOV:L", "MOV:S", "MOV:F"} and len(ops) == 2:
source = _format_operand(ops[0], size)
dest = _format_operand(ops[1], size, lvalue=True)
if is_byte_immediate_to_word_destination(ins):
return f"{dest} = zero_extend8_to16({source});"
return f"{dest} = {_cast(source, size)};"
if base in {"MOVFPE"} and len(ops) == 2:
@@ -908,6 +914,9 @@ def _metadata_comments(ins: JsonObject) -> list[str]:
if isinstance(item, dict) and item.get("comment"):
comments.append(str(item["comment"]))
if is_byte_immediate_to_word_destination(ins):
comments.append("byte immediate zero-extended into word destination")
board_profile = ins.get("board_profile")
if isinstance(board_profile, dict) and board_profile.get("comment"):
comments.append(str(board_profile["comment"]))