-
Notifications
You must be signed in to change notification settings - Fork 1
6809 assembly language routine to find the length of a C-style string (with test suite in Disk Extended Color BASIC and 6809 assembly) (Version 1.7, released 30 March 2019)
License
richardcavell/6809-strlen
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
6809 Assembly Language C-Style String Length Calculation Routine by Richard John Foster Cavell (c) 2017, 2018, 2019 Version 1.7 (30 March 2019) https://github.com/richardcavell/6809-strlen A 6809 assembly language routine to find the length of a C-style string. The 6809 is an 8-bit CPU originally manufactured by Motorola. This project is intended only for serious students of computer programming. $FFFF means hexadecimal FFFF. Inputs: register X = (unsigned 16-bit) pointer to the string. Outputs: register D = (unsigned 16-bit) length of the string. (A value of $FFFF means there was a "no end" error) All other registers, including X, are preserved. A C-style string, for the purposes of this routine, is a sequence of non-zero 8-bit bytes, followed by a zero byte. The sequence may have zero length. A "no end" error will occur if the string continues past memory location $FFFF. The default error handler returns a value of $FFFF. You should check for this. You can also write your own error handler. The code is position-independent and re-entrant. Interrupts are allowed to occur during execution. The code uses 2 bytes of the S stack, in addition to the 2 bytes used for the return PC value when calling this routine. The code assembles to 21 bytes of object code using asm6809. Issues: If X does not point to a valid string, the behaviour is undefined. If there is no terminating null byte, the code might access forbidden areas of the memory map. The folder "Test suite" contains a method of testing this routine to be sure that it works. Another version of the routine is included, called "no_error_strlen.s". This routine is smaller in code size. It assembles to 15 bytes of object code and will complete faster in most cases. It does not detect the "no end" condition and will simply wrap from $FFFF to $0000 while searching for the end of the string. You should only use no_error_strlen.s if: * you can be quite sure that the string passed into the routine is valid and: * that the "no end" condition will never occur As a benefit, it will give you: * reduced code size, and * (under some circumstances) extra performance All of this is licensed to you under the MIT License. Published and maintained at: https://github.com/richardcavell/6809-strlen This project is complete, and is actively maintained by me. The last review was in March 2019.
About
6809 assembly language routine to find the length of a C-style string (with test suite in Disk Extended Color BASIC and 6809 assembly) (Version 1.7, released 30 March 2019)
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published