agentsclimarketplace

Using cmhg

Skill gerph/riscos-agent-skills/skills/using-cmhg

Skills repository for RISC OS agents

Install
npx -y skills add gerph/riscos-agent-skills --skill using-cmhg

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Describes the CMHG file format and CMunge usage. Use when CMHG files are required for RISC OS modules.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

7.8 KB, as published. Nobody here has run it

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 *Commands and their handlers — see references/command-tables.md.
  • generic-veneers: General purpose C wrappers.
  • vector-handlers: Wrappers for claiming RISC OS vectors - see references/vectors.md
  • event-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:

All of these use the same CMHG mechanism:

generic-veneers: EntryName/HandlerName

CMHG 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:

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_Close

Can be comma separated, thus:

swi-decoding-table: JUnitXML Create/SWI_Create, TestSuite/SWI_TestSuite, TestCase/SWI_TestCase Close/SWI_Close

And 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_Close

Which 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_ModeChange

References

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 vectors including 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-traps docuemnt for a worked example in references/vector-traps.md.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.