Table of contents
This section describes the Application Programming Interface (API) of the ARMSim own firmware, which provides arithmetic and display subroutines.
Please note that all the subroutines of this API follow the ARM convention for parameter passing and return. Thus, i) passed values use the registers from r0 to r3, and then the stack if required; ii) values are returned using r0, and r1 if required; and iii) all the subroutines modify only registers r0 to r3, while all the other are preserved.
Performs the 32 bits unsigned division dividend/divisor, where r0 holds the dividend and r1 the divisor. The quotient is returned in r0 and the remainder in r1.
If r1 is 0 both quotient and remainder will be 0xFFFFFFFF which is an impossible result for a correct 32 bit division.
Performs the 32 bits signed division dividend/divisor, where r0 holds the dividend and r1 the divisor. The quotient is returned in r0 and the remainder in r1. The remainder always has the sign of the dividend ─unless the division is exact─.
If r1 is 0 both quotient and remainder will be 0x7FFFFFFF which is an impossible result for a correct 32 bit division.
If the dividend is 0x80000000 and the divisor is -1 the quotient returned is 0x80000000 as the positive range is exceeded. All the other combinations work as expected.
Returns in r0 the positive, integer square root of the value passed in r0.
Clears the display by filling it with the space character. Does not require nor return any value.
Fills the display with the character passed in the LSB of r0. Does not return any value.
Shows the ASCIZ string whose address is passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
The number of characters printed, i.e., the length of the string, is returned in r0.
Does not verify if the coordinates are inside or outside the display; nor if the string is printed in two rows or finishes out of the display area.
Shows the signed decimal value passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
Only significant characters, plus a - sign if required, are printed. The number of characters printed is returned in r0.
Does not verify if the coordinates are inside or outside the display; nor if the number is printed in two rows or finishes out of the display area.
Shows the unsigned decimal value passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
Only significance characters are printed. The number of characters printed is returned in r0.
Does not verify if the coordinates are inside or outside the display; nor if the number is printed in two rows or finishes out of the display area.
Shows the hexadecimal value of the word passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
All 8 characters are printed, no value is returned.
Does not verify if the coordinates are inside or outside the display; nor if the number is printed in two rows or finishes out of the display area.
Shows the hexadecimal value of the half word passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
All 4 characters are printed, no value is returned.
Does not verify if the coordinates are inside or outside the display; nor if the number is printed in two rows or finishes out of the display area.
Shows the hexadecimal value of the byte passed in r2 starting at the display coordinates (column, row) where column is in r0 and row in r1.
All 2 characters are printed, no value is returned.
Does not verify if the coordinates are inside or outside the display; nor if the number is printed in two rows or finishes out of the display area.
The QtARMSim firmware includes Qfplib: an ARM Cortex-M0
floating-point library in 1 kbyte <https://www.quinapalus.com/qfplib.html>
, (c) Mark Owen.
Thanks to this library, IEEE 754 single precision floating point operations can be performed on the ARMSim
simulator.
Please note that all the subroutines of this API follow the ARM convention for parameter passing and return. Thus, i) passed values use the registers from r0 to r3, and then the stack if required; ii) values are returned using r0, and r1 if required; and iii) all the subroutines modify only registers r0 to r3, while all the other are preserved.
The next sections describe the basic floating point operations, the conversion subroutines, the mathematical subroutines, the string conversion subroutines,
Performs the floating point addition. r0 and r1 hold the operands, and the result is returned in r0.
Performs the floating point substraction. r0 holds the minuend and r1 holds the subtrahend, and the result is returned in r0.
Performs the floating point multiplication. r0 and r1 hold the operands, and the result is returned in r0.
Performs the floating point division. r0 holds the dividend and r1 holds the divisor, and the quotient is returned in r0.
Performs the comparison between the floating point numbers in r0 -f1- and r1 -f2-. Returns in r0 an integer whose value is 0 if both are equal, -1 if r0 < r1 and +1 if r0 > r1
Converts the float in r0 to signed integer, rounding towards -Inf. The integer is returned in r0.
Converts the float in r0 to signed fixed point, with the number of fractionary bits in r1. The fixed point value is returned in r0.
Converts the float in r0 to unsigned integer, rounding towards 0 if positive. Any negative float returns 0. The unsigned integer is returned in r0.
Converts the float in r0 to unsigned fixed point, with the number of fractionary bits in r1. Any negative float returns 0. The fixed point value is returned in r0.
Converts the signed integer in r0 to float. The floating point value is returned in r0.
Converts the fixed point value in r0, with the number of fractionary bits in r1, to floating point. The floating point value is returned in r0.
Converts the unsigned integer in r0 to float. The floating point value is returned in r0.
Converts the unsigned fixed point value in r0, with the number of fractionary bits in r1, to floating point. The floating point value is returned in r0.
Returns in r0 the cosine of the angle held in r0, expressed in radians.
Returns in r0 the sine of the angle held in r0, expressed in radians.
Returns in r0 the tangent of the angle held in r0, expressed in radians.
Returns in r0 the angle in radians whose tangent is given by r0/r1. r0 -y- can be viewed as the sin of the angle or the y coordinate of the end of a segment starting at the origin and whose angle with the x axis is returned by the subroutine. Accordingly r1 -x- can be viewed as the cosine or the x coordinate.
Returns in r0 the value of e raised to r0.
Returns in r0 the natural logarithm of r0.
Returns in r0 the square root of r0.
Stores in the address given in r1 the string representing the floating point value present in r0. No value is returned. When r2 is 0, a default format is used, otherwise the format is specified as follows (bxx is bit xx of r2):
The default format is 0x18060406.
Note that if b28 is set (as it is in the default format value) the code will write the trailing decimal point and zeros to the output buffer before truncating the string. Thus, it is essential that the output buffer is large enough to accommodate these characters temporarily.
Overall accuracy is sufficient to print all exactly-representable integers up to 10^8 correctly in 0x18160408 format
Converts the string starting at the address contained in r1 to a float and stores it to the address contained in r0. At the address contained in r2 is placed the address of the first non convertible character, unless r2 contains 0. The return value in r0 is 0 in case of success or 1 in case of failure, that is, the string is not convertible.