xiaohongshu
xiaohongshu
make-doom-for-mips
Guidance for cross-compiling complex C programs (like Doom) to run on custom MIPS virtual machines or emulators. This skill should be used when tasked with building software for non-standard MIPS targets that use custom syscall interfaces, require freestanding compilation (-nostdlib), or involve ...
Full skill instructions
This skill provides guidance for cross-compiling complex C codebases (such as Doom) to run on custom MIPS virtual machines or emulators. The primary challenge is bridging the gap between standard C library expectations and a custom runtime environment with its own syscall interface, memory layout, and instruction support.
Before writing any code, thoroughly analyze the target VM to understand its requirements:
Read the VM source code to extract the exact syscall interface:
Verify the target architecture details by examining the VM source:
From the VM source, extract:
Check for instruction limitations:
Before compiling, scan all source files to identify required headers:
# Find all included headers
grep -rh '#include' src/ | sort -u
Create stub headers for ALL identified system headers upfront rather than reactively fixing one error at a time. Common headers needed for complex C programs:
<stdio.h>, <stdlib.h>, <string.h>, <stdint.h><limits.h>, <stddef.h>, <stdarg.h><ctype.h>, <math.h>, <time.h><errno.h>, <assert.h>, <fcntl.h><unistd.h>, <sys/types.h>, <sys/stat.h>Create a comprehensive stdlib replacement with COMPLETE implementations:
Critical functions that must work correctly (not return 0 or stub):
printf, fprintf, sprintf, snprintf - Used for debug output and parsingsscanf, fscanf - Used for configuration parsingmalloc, free, realloc - Memory managementmemcpy, memset, memmove, strlen, strcmp, strcpy - String/memory operationsatoi, atol, strtol - Number parsingfopen, fread, fwrite, fclose, fseek, ftell - File I/OWarning signs of incomplete implementations:
Create a linker script that matches the VM's expectations:
.text, .data, .bss, .rodata placementAfter implementing syscalls, verify each one works:
// Test write syscall
const char *msg = "Syscall test\n";
write(1, msg, strlen(msg));
// Test read syscall
char buf[100];
int n = read(0, buf, sizeof(buf));
// Test file operations
int fd = open("/path/to/file", O_RDONLY);
// etc.
Confirm the entry point matches:
# Check the ELF entry point
mips-*-readelf -h output.elf | grep Entry
# Verify symbol is at expected address
mips-*-nm output.elf | grep __start
Generate and use map files to debug crashes:
# Generate map file during linking
-Wl,-Map=output.map
# When program terminates at specific PC, find the function:
grep "0x40b7b0" output.map
Test components in isolation before full integration:
Problem: Linking soft-float compiled code with hard-float libgcc produces warnings:
warning: linking soft-float module with hard-float module
Impact: Can cause runtime crashes when floating-point values are passed/returned.
Solution: Ensure consistent ABI across all compilation units:
-msoft-float -mfloat-abi=soft
Or provide soft-float libgcc, or implement soft-float routines.
Problem: Returning 0 or doing nothing in printf-family functions.
Impact: Configuration parsing fails silently; debug output disappears.
Solution: Implement at least these format specifiers:
%d, %i, %u, %x, %X - integers%s - strings%c - characters%p - pointersProblem: Compiler warnings about implicit function declarations.
Impact: Undefined behavior at runtime; usually crashes.
Solution: Treat ALL implicit declaration warnings as errors:
-Werror=implicit-function-declaration
Problem: Using standard Linux syscall numbers when VM uses different numbers.
Impact: Wrong operations executed; silent corruption or crashes.
Solution: Extract exact syscall numbers from VM source before implementation.
Problem: Program terminates early; assuming it's due to missing data files.
Impact: Real bugs (unimplemented instructions, invalid memory access, failed syscalls) go undiagnosed.
Solution: Always investigate termination:
Problem: Creating stub headers one-by-one as compilation errors appear.
Impact: Slow iteration; easy to miss dependencies.
Solution: Analyze all includes upfront and create comprehensive stubs before first compile attempt.
Essential flags for freestanding MIPS compilation:
-nostdlib # No standard library
-ffreestanding # Freestanding environment
-mips32 # MIPS32 instruction set (or appropriate variant)
-EL # Little-endian (or -EB for big-endian)
-msoft-float # Software floating-point
-mno-abicalls # No PIC/GOT (if VM doesn't support)
-fno-pic # No position-independent code
-static # Static linking
-Wl,-Map=output.map # Generate map file for debugging
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience