Benchmarking LLM Coding Ability Through UEFI Shell Game Development

    Developing a classic game in the UEFI Shell environment is a demanding test of a large language model's code generation ability, involving low-level hardware interaction, manual memory management, I/O handling, and UEFI-specific protocols. This article systematically reviews an evaluation of six mainstream Chinese LLMs using a unified Snake game benchmark, covering evaluation metrics, each model's actual performance, key findings about training data coverage and prompt engineering, and practical guidance for model selection.

    Developing a classic game in the UEFI Shell environment is a true “litmus test” for evaluating the code generation capabilities of large language models. This seemingly simple task actually involves a large number of professional details—low-level hardware interaction, memory management without an operating system, input/output handling, timer control, and assembly-level debugging—making it far more revealing of a model’s real ability than common web CRUD applications. Over the past period, I tested multiple Chinese LLMs against the same benchmark and accumulated some valuable observations. This article systematically reviews the evaluation process, extracts the key dimensions and conclusions, and presents a neutral, reusable evaluation methodology.

    1. Why UEFI Shell as the Unified Benchmark

    LLM coding evaluations typically rely on LeetCode problems or hand-written prompts, but these approaches often fail to reflect real engineering pain points—especially in resource-constrained embedded scenarios that depend on special runtime libraries. Whether a model understands low-level protocol differences and can infer environmental constraints on its own becomes the dividing line.

    The UEFI Shell environment presents the following unique challenges:

    • No standard library dependencies: Conventional C libraries like stdio and stdlib cannot be used. All input and output must be implemented through the system tables provided by UEFI (such as SystemTable->ConIn/ConOut).
    • Manual memory management: There is no malloc/free; you must call AllocatePool/FreePool and pass the correct memory type.
    • Simplified but non-trivial event model: Timers and keyboard interrupts must be implemented via Boot Services’ WaitForEvent or polling.
    • Special compilation and linking: A specific cross-compiler and linker script are required to produce an EFI executable.

    This environment requires a model not only to write “ordinary C code,” but also to understand the EFI specification, structure layouts, and calling conventions. Based on this, I chose the “Snake game” as the unified task, requiring fully runnable source code along with the necessary compilation instructions. The task covers data structures (snake body storage), algorithms (collision detection), input handling (direction control), and UEFI graphics output (or text-mode cursor movement)—moderate complexity with quantifiable results.

    2. Evaluation Dimensions and Quantitative Criteria

    To avoid subjective impressions, I designed six objective metrics:

    1. First-pass rate: The proportion of generated code that compiles and runs without modification.
    2. Number of compile-fix iterations: The number of modification rounds needed from the first compilation to success (including the depth of human hints).
    3. Runtime correctness: Whether the game satisfies basic rules (speed-up, boundaries, scoring, exit).
    4. Code readability: Naming conventions, comment density, function decomposition.
    5. Completeness of exception handling: Whether edge cases are handled—memory allocation failure, input buffer overflow, illegal key presses, etc.
    6. Environmental adaptability awareness: Whether the model proactively uses UEFI-specific APIs instead of calling non-existent library functions.

    All tests were executed on the same hardware platform (an x86_64 virtual machine) with the same toolchain (the open-source EDK2 build environment) to ensure fairness.

    3. Overview of Each Model’s Performance

    Six mainstream Chinese LLMs (the latest versions from different vendors) were tested. For objectivity, they are referred to below as “Model A through F.” A unified system prompt was used, describing the UEFI Shell environment constraints and game requirements, along with an explicit instruction to “use the UEFI protocol interfaces.”

    3.1 Model A: Strong Environmental Awareness, but Redundant Code

    This model proactively introduced UEFI’s gST->ConOut->SetCursorPosition and gBS->WaitForEvent on the first attempt, indicating that relevant documentation exists in its training data. However, the snake body data structure used a dynamic linked list, resulting in overly frequent memory allocation without handling allocation failures. The first-pass rate was only 20%; two rounds of fixes were needed, and a hint about missing “memory release” was required. The code was readable with detailed comments, but the overall size was bloated, showing a tendency toward “over-engineering.”

    3.2 Model B: Clear Logic, but Clinging to the Standard Library

    This model directly used #include <stdio.h> and printf in its generated code and did not proactively adapt to the UEFI environment. Even after the system prompt explicitly stated “standard libraries cannot be used,” it insisted on printf and getchar, requiring manual replacement with ConOut->OutputString and polled reads. This shows that UEFI-related code makes up a very small portion of its training corpus—the model exhibits “path dependency.” It took as many as 5 correction rounds, with new missing-header problems appearing in each round.

    3.3 Model C: High First-Pass Rate, but Insufficient Practicality

    Model C performed impressively: the first generated code was complete and could compile and run directly. However, the gameplay had flaws—the snake moved at constant speed, there was no self-collision detection, and scoring logic was missing. Further inspection showed it used the UEFI text mode’s ConOut->SetAttribute to change character colors (a correct approach), but ignored checking whether the keyboard buffer was non-empty, causing occasional input loss. The first-pass rate was 70%, but functional completeness was poor, requiring 3 additional rounds of functional fixes.

    3.4 Model D: Mediocre and Conservative

    Model D generated correct, runnable code, but used only basic APIs such as ReadKeyStroke and CreateEvent, with no error handling. The code style resembled a “textbook example” and lacked engineering robustness. It compiled on the first pass, but crashed after extended runtime due to unreleased memory. Two correction rounds were needed, both to add memory release. Overall performance was average—no highlights, no major defects.

    3.5 Model E: Well-Rounded, but Dependent on Prompt Engineering

    Model E’s initial version used global variables and large buffers; it built successfully and ran mostly correctly. However, its code did not distinguish line feeds from screen clearing in text mode, causing abnormal screen refresh. When I added “please refer to the ClearScreen function of EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL in the UEFI specification” to the prompt, it immediately produced the correct implementation—showing it possesses retrievable knowledge but lacks the ability to apply it proactively. Three total corrections were needed.

    3.6 Model F: Excellent Low-Level Details, but Verbose Code Style

    Model F deliberately wrote paired memory allocation/release for each function and checked return values one by one using a Status variable—the best defensive programming among the six models. However, its game logic implementation was roundabout; for example, it stored the entire map in a string array instead of directly manipulating the screen buffer, causing performance loss. The first-pass rate was 100%, but runtime was slow and the code volume was double what was necessary. Overall, its rigor is commendable, but its efficiency awareness is insufficient.

    4. Key Findings and In-Depth Insights

    4.1 Training Corpus Determines “Environmental Adaptability”

    Models A and F significantly outperformed B and D, and the core difference lies in whether the training data included UEFI-related technical documentation. This reveals a general rule: an LLM’s coding ability in vertical domains depends heavily on corpus coverage rather than general reasoning ability. For developers, if a task involves a specific framework or low-level interface, preference should go to models specifically optimized for that domain.

    4.2 Prompt Engineering Remains a Key Lever

    In testing, all models showed a significant drop in error rates after receiving explicit instructions such as “please use UEFI’s text output protocol.” Model E’s shift from “won’t use it proactively” to “immediately fixes it” demonstrates that models have potential in semantic understanding but need human guidance. In practice, writing environment constraints, prohibited items, and reference API lists directly into the system prompt can effectively improve the first-pass rate.

    4.3 Code Quality and Runnability Are Not Positively Correlated

    Although Model F passed on the first try, its code was redundant and inefficient; Model C also passed on the first try but had missing functionality. A truly “good model” should balance runnability with reasonableness. The test results show that no single model led across all dimensions, reminding us that selection priorities should depend on the project phase—prototype validation values first-pass rate, while long-term maintenance values readability and extensibility.

    4.4 Common Weakness: Exception Handling and Resource Management

    Among the six models, only one proactively handled memory allocation failure, and only two correctly released allocated memory. In embedded development or long-running services, such oversights are fatal. This may relate to the fact that most “sample code” in training data consists of one-off scripts that rarely involve production-grade resource management. When using these models, developers should explicitly require error-handling branches in the output or include resource-management checks in their code review checklist.

    5. Practical Selection Recommendations

    Based on the tests above, I summarize the following selection principles for teams with different needs:

    • For rapid prototype validation: Choose a model with a high first-pass rate (such as Model F) to reduce debugging time, but expect to refactor the code later.
    • For memory- and performance-sensitive projects: Choose a model with strong low-level detail awareness (such as Model A), and manually verify resource release logic.
    • If the team has ample time for iteration: Consider a model with clear logic but poor environmental adaptability (such as Model B), compensating for weaknesses through prompting to obtain cleaner code structure.
    • For long-term maintenance projects: Focus on code readability and comment quality; Models A and D scored higher here.
    • Multi-model collaboration strategy: Use Model C to generate the main logic, then use Model F for code review and exception-handling completion—their strengths complement each other.

    6. Release Cadence and Performance Expectations

    All models tested were the latest major versions from their respective vendors. Overall, however, progress in vertical scenarios like UEFI was not significant compared to versions from six months earlier. What is truly noteworthy is the improvement in “understanding constraints”—all models followed the hard rules in the prompt better in the second round of conversation, indicating stronger in-context learning. But there is still a considerable distance to the ideal state of “zero prompt engineering.”

    7. Conclusion: Choose Rationally Based on Real Needs

    The purpose of this test was not to rank models, but to use a unified benchmark task to help developers see the unique strengths and limitations of different models. When choosing a model, there is no need to believe “strongest ever” marketing claims; instead, match the decision to your hardware environment, task type, and team capabilities. I also encourage feeding test results back to model providers to drive continued improvement in vertical domains. As more developers are willing to “vote with their feet” in real-world scenarios, these models will achieve more solid iteration and broader prospects.