using-cmhg
Skill4 starsChanged 7 months agoMITView on GitHub
Describes the CMHG file format and CMunge usage. Use when CMHG files are required for RISC OS modules.
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 69
All of these use the same CMHG mechanism:
- Distinctive: line 107
Don't remove the comment sections that describe the file.
- Very specific: line 131
If services are required for the module, use the symbolic names where possible from the include file riscos/Services.h.
- Very specific: line 149
If you need to post-process the vector results after it is passed on, see the vector-traps docuemnt for a worked example in …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CMunge Skill Summary
Purpose
CMunge is an enhanced, free alternative to the Acorn C Module Header Generator (CMHG). It generates ARM assembly "veneers" that allow RISC OS relocatable modules to be written in C or C++. It supports 26-bit, 32-bit, and 64-bit ARM architectures.
Command Line Usage
CMunge [options] <infile>
Key options:
-o <file>: Output object (AOF) file.-s <file>: Output assembly file.-d <file>: Output C header file.-26bit: Target legacy 26-bit ARM (default).-32bit: Target 32-bit compatible ARM.-64bit: Target 64-bit (AArch64) ARM for GCC.-p/-px: Pre-process input file (standard / extended).-throwback: Enable error reporting to editors.-zoslib/-zoslibpath: Use OSLib header styles.
CMHG/CMunge Directives Summary
title-string: Internal module name.help-string: Descriptive name and version.initialisation-code: C function called on load.finalisation-code: C function called on unload.module-is-initialised-early: (CMunge) Requests early initialization for ROM.service-call-handler: C function for service calls.swi-chunk-base-number: Base SWI number.swi-handler-code: Central SWI handler C function.swi-decoding-table: Lists SWI names and optional specific handlers.command-keyword-table: Defines*Commandsand their handlers — see references/command-tables.md.generic-veneers: General purpose C wrappers.vector-handlers: Wrappers for claiming RISC OS vectors - see references/vectors.mdevent-handler: Wrappers for RISC OS events.error-base(CMunge): Base error number for the module.error-identifiers(CMunge): Automatically generates error definitions.vector-traps(CMunge): Advanced vector chaining handlers — see references/vector-traps.md.library-initialisation-code/library-enter-code: Override C library entry symbols.
Generic veneers reference index
These files describe common generic veneer usage patterns:
- Timers:
OS_CallEvery,OS_CallAfter, andOS_RemoveTickerEvent. OS_AddCallBack/OS_RemoveCallBackdeferred work.OS_SetVarValtype 16 read/write code variables.- FilterManager and Internet filter callbacks.
- ImageFileConvert converter and miscellaneous-operation entries.
- ImageFileRender render, bbox, info, declare, start, and stop entries.
- colour-map
workspace, functiondescriptors. - DBResultManager provider callbacks.
OS_DynamicAreahandlers.- Vectors claimed with
OS_Claim. OS_ClaimOSSWIhandlers.- PPP, WebFTP, AUN, and network driver callback entries.
- SCSI provider operation callbacks.
- abort traps and
ErrorVhandling. - hand-built callback trampolines and
carry-capable:.
All of these use the same CMHG mechanism:
generic-veneers: EntryName/HandlerNameCMHG generates EntryName, which is the address passed to the OS or another module. The C function HandlerName is called by the veneer with:
_kernel_oserror *HandlerName(_kernel_swi_regs *r, void *pw);The handler reads and writes the register block according to the owning API's ABI, not according to CMHG itself.
Service call reference index
General information on CMHG syntax, C handler ABI, claiming, and filtering is in the Service Calls overview.
These files describe common CMHG service-call-handler usage patterns:
- startup, shutdown, reset, and manager started/dying notifications
- ResourceFS related registration services
- Toolbox object/task lifecycle, Wimp start/shutdown, submenu mediation
- filing-system redeclaration, filer lifecycle, disc dismount, and MultiFS format negotiation
- mode changes, display changes/status, screen mode enumeration, and blanking
- SCSI, USB, buffers, sound, and other device/provider registrations
- DCI driver/protocol, Internet state, PPP, Freeway, and statistics services
- ImageFileConvert and ImageFileRender registry lifecycle services
- services used as synchronous extension interfaces by claiming and returning register values
Service_UKCompressionandService_ModulePreInitpatching hooks- desktop banners, Wimp shutdown, TaskManager acknowledgements, and shutdown services
Service_APCSBacktracediagnostic extension and minidump hooksService_ErrorStartingand related Wimp error-report monitoring hooks
Service information may often also be found through the riscos-prm --url Service_... command.
CMHG style guidelines
- Don't remove the comment sections that describe the file. They are useful for humans to know how to add new sections.
- Any definition which may be split across lines if the definition is incomplete. For example, a list of SWIs like:
swi-decoding-table: JUnitXML Create/SWI_Create TestSuite/SWI_TestSuite TestCase/SWI_TestCase Close/SWI_CloseCan be comma separated, thus:
swi-decoding-table: JUnitXML Create/SWI_Create, TestSuite/SWI_TestSuite, TestCase/SWI_TestCase Close/SWI_CloseAnd the comma separated parts can be split if the comma is the last entry on the line:
swi-decoding-table: JUnitXML Create/SWI_Create,
TestSuite/SWI_TestSuite,
TestCase/SWI_TestCase,
Close/SWI_CloseWhich makes for nice aligned text.
- If services are required for the module, use the symbolic names where possible from the include file
riscos/Services.h. This can be included using C preprocessor includes, like this:
#include "riscos/Services.h"
service-call-handler: Mod_Service Service_ModeChangeReferences
For more information on the CMHG file format, see references/cmhg-syntax.md.
For examples and detailed syntax of the *Command tables, see references/command-tables.md.
Vectors
- Vectors can be claimed or passed on. For detailed information on
vectorsincluding a worked example, see references/vector-traps.md. - If you need to post-process the vector results after it is passed on, see the
vector-trapsdocuemnt for a worked example in references/vector-traps.md.
In this repository47 other files it gives its agents.
- allocating-resourcesSkill
- ci-testingSkill
- creating-pull-requestsSkill
- designing-modulesSkill
- porting-to-riscos-cSkill
- reading-assemblySkill
- riscos-commandsSkill
- riscos-desktop-fileractionSkill
- riscos-filer-likeSkill
- riscos-filesystemSkill
- riscos-graphics-convertersSkill
- riscos-network-dcistatisticsSkill
- riscos-network-resolverSkill
- riscos-outputSkill
- riscos-reSkill
- riscos-styleSkill
- riscos-throwbackSkill
- riscos-urls-fetchingSkill
- riscos-urls-launchingSkill
- riscos-wimp-appSkill
- riscos-wimpSkill
- riscos-wimp-templatesSkill
- updating-robe-skillsSkill
- using-bbcbasicSkill
- using-ghSkill
- using-gitSkill
- using-libasmSkill
- using-libgcontextSkill
- using-liboslibSkill
- using-libriscoslibSkill
- using-libtoolboxSkill
- using-makefilesSkill
- using-perlSkill
- using-stronghelpSkill
- using-toolbox-imagefilegadgetSkill
- using-tooltesterSkill
- writing-assemblySkill
- writing-assembly-testsSkill
- writing-cmodulesSkill
- writing-cplusplusSkill
- writing-cSkill
- writing-fortranSkill
- writing-oslib-defsSkill
- writing-pascalSkill
- writing-prminxmlSkill
- writing-pymodulesSkill
- writing-pyromaniac-integration-testsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

