SongYZZZ/moon-firmware/srec does not have a README file

    AddressWidth

    pub(all) enum AddressWidth {
    Auto
    Bits16
    Bits24
    Bits32
    } derive(Eq,
    Debug
    )

    Automatic width considers both the highest payload byte and the entry point.

    Record

    pub struct Record {
    kind : Int
    address : Int64
    data : Bytes
    } derive(Eq,
    Debug
    )

    A validated S-record. S5/S6 use the address field as a record count.

    Record::encode

    fn Record::encode(self : Record, uppercase? : Bool) -> String raise
    FirmwareError

    Encode count and address in big-endian order with a one's complement checksum.

    Record::new

    fn Record::new(kind : Int, address : Int64, data : Bytes) -> Record raise
    FirmwareError

    Check address width, count capacity and no-data control records.

    WriterOptions

    pub(all) struct WriterOptions {
    data_length : Int
    address_width : AddressWidth
    uppercase : Bool
    line_ending :
    LineEnding

    emit_count : Bool
    flatten_segment_entry : Bool
    max_output_length : Int
    } derive(Eq,
    Debug
    )

    Configurable canonical single-block output. CS:IP flattening is opt-in.

    WriterOptions::default

    fn WriterOptions::default() -> WriterOptions

    Sixteen data bytes, the smallest safe width, S5/S6 count and termination.

    address_width

    fn address_width(kind : Int) -> Int raise
    FirmwareError

    S4 is reserved and is never treated as a data record.

    compute_checksum

    fn compute_checksum(body : Bytes) -> Byte

    Motorola S-Record one's complement of count, address and data bytes. This is deliberately independent of Intel HEX two's complement arithmetic.

    encode

    Serialize deterministic Motorola S-Record text. Missing entry becomes zero, because every standard termination record contains an address field.

    for_each_record

    Stream canonical records in address order without building text or record arrays.

    parse_document

    Parse a single S-record block. Strict mode enforces homogeneous data width, one leading S0, at most one count, and a matching termination record.

    parse_line

    fn parse_line(text : String, line? : Int) -> Record raise
    FirmwareError

    Parse a single line with mandatory count and independent SREC checksum checks.

    validate

    Validate record checksums, addresses, overlap policy and block structure.

    verify_checksum

    fn verify_checksum(record_bytes : Bytes) -> Bool

    A decoded S-record including its checksum sums to 0xFF modulo 256.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io