ARM Angel SWI Instruction Usage: Version of 26 September 2012
ARM Angel SWI Instruction Usage: Version of 26 September 2012
ARM Angel SWI Instruction Usage: Version of 26 September 2012
.data
ReadParams:
.word 0 @ the file handle
.word InputBuffer @ address of input buffer
.word 80 @ number of bytes to read
InputBuffer:
.skip 80
OpenParams:
.word FileName
.word FileNameEnd-FileName @ length of filename
.word 0 @ File mode = read
FileName:
.ascii "MyData.txt" @ name without final NUL byte
FileNameEnd:
.byte 0 @ the NUL byte
Page 1 of 8
Version of 26 September 2012
Page 2 of 8
Version of 26 September 2012
The standard input, standard output and standard error output streams are automatically opened.
They are accessed with file handles of 0, 1 and 2 respectively.
As a special case, if the filename comprises the 3 characters ":tt", then the file handle refers to a
newly created ARMSim console window rather than to an actual file.
Result:
R0 contains a file handle (for use with other SWI calls) on success. If the operation fails, R0 holds
-1 and an error code can be obtained with the 0x13 ErrorNo SWI call.
1 a file handle
Result:
R0 holds 0 on success or an error code on failure.
Page 3 of 8
Version of 26 September 2012
1 a file handle
2 the address of a block of data in memory
3 the number of bytes to be written
Note: file handle values of 1 and 2 refer to the standard output and standard error output streams.
Result:
R0 holds the number of bytes NOT written. (I.e., if R0 is 0, the call was successful.) If R0 is non-
zero, then an error code can be obtained with the 0x13 ErrNo SWI call.
1 a file handle
2 the address of a buffer in memory to receive the input
3 the number of bytes to be read
1 a file handle
Result:
R0 holds 1 if the file handle refers to the ARMSim console, and 0 otherwise. If the call fails, then
R0 holds -1 and an error code can be obtained with the 0x13 ErrNo SWI call.
Page 4 of 8
Version of 26 September 2012
1 a file handle
2 the absolute position in bytes (i.e. offset from the file start) to seek to
Result:
R0 holds 0 if the seek is successful. If the call fails, then R0 holds -1 and an error code can be
obtained with the 0x13 ErrNo SWI call.
1 a file handle
Result:
R0 holds the length of the file in bytes (or 0 if the file handle refers to the ARMSim console). If
the call fails, then R0 holds -1 and an error code can be obtained with the 0x13 ErrNo SWI call.
Result:
On success, the buffer holds a null-terminated string which can be used as a temporary file name.
The leading part of the string is the same for all file names generated with this SWI operation. The
file name ends with the digits of the second parameter. Therefore the second parameter is impor-
tant if more than one temporary file is used in the program.
R0 holds 0 on success. If the call fails, then R0 holds -1 and an error code can be obtained with the
0x13 ErrNo SWI call.
Page 5 of 8
Version of 26 September 2012
Result:
R0 holds 0 if the file was successfully deleted. If the call fails, then R0 holds -1 and an error code
can be obtained with the 0x13 ErrNo SWI call.
Result:
An existing file specified by the first filename is renamed to have the second filename. If the oper-
ation is successful, R0 is 0. If the call fails, then R0 holds -1 and an error code can be obtained with
the 0x13 ErrNo SWI call.
Page 6 of 8
Version of 26 September 2012
Result:
The four word array is filled with the following four numbers: the address of the start of the area
of memory reserved for the heap, the address of the end of that heap area, the address of the area
of memory reserved for the stack, the address of the end of that stack area.
R0 holds 0 if the operation is successful. If the call fails, then R0 holds -1 and an error code can be
obtained with the 0x13 ErrNo SWI call.
Page 7 of 8
Version of 26 September 2012
Code and Unix Can
Name Description Occur?
Page 8 of 8