QtARMSim: a graphical interface for the ARMSim simulator
Author: Sergio Barrachina Mir and Germán Fabregat Llueca

# QtARMSim User Manual

Table of contents

1. ARMSim firmware API

## 1. ARMSim firmware API

This section describes the Application Programming Interface (API) of the ARMSim firmware, which provides arithmetic and display functions.

Please note that all the functions of the API follow the ARM convention for parameter passing and return. Thus, i) passed values use the registers from r0 to r3, then the stack if required; ii) values are returned using r0 and r1 if required; and iii) all the functions modify only registers r0 to r3, while all the other are preserved.

### 1.1 Arithmetic functions

#### `divide(unsigned int dividend, unsigned int divisor)`

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.

#### `sdivide(int dividend, int divisor)`

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.

#### `sqrt(unsigned int val)`

Returns in r0 the positive, integer square root of the value passed in r0.

### 1.2 Display functions

#### `cls()`

Clears the display by filling it with the space character. Does not require nor return any value.

#### `fill(char c)`

Fills the display with the character passed in the LSB of r0. Does not return any value.

#### `printString(int column, int row, char *str)`

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.

#### `printInt(int column, int row, int val)`

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.

#### `printUInt(int column, int row, unsigned int val)`

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.

#### `printWord(int column, int row, unsigned int val)`

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.

#### `printHalf(int column, int row, unsigned int val)`

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.

#### `printByte(int column, int row, unsigned int val)`

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.