From 5a690a12d2367e759c09645174a6b7e9bb23c98d Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 31 Aug 2022 10:04:41 +0200 Subject: [PATCH] Meta: Add script to check for missing opcodes --- script/opcode-check.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 script/opcode-check.sh diff --git a/script/opcode-check.sh b/script/opcode-check.sh new file mode 100755 index 0000000..730dbec --- /dev/null +++ b/script/opcode-check.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# Get the full path to this script while handling spaces and symlinks correctly +scriptPath="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" +cd "$scriptPath/.." || exit 1 + +opcode_check() { + path="$1" + file="$(basename "$path")" + + max=255 + for i in $(seq 1 "$max") + do + opcode=$(printf "0x%.2x\n" "$i") + # Pattern: case 0x??: + if ! grep -q "case $opcode:" "$path"; then + echo "missing opcode: $opcode in $file" + fi + done +} + +opcode_check "src/cpu.cpp" +opcode_check "src/cpu-prefix.cpp"