I am including some syscall functions:
int _fstat(int file, struct stat* st) {
register int value asm("r0");
uint32_t p[] = { file };
R0(0x0C);
R1(p);
BKPT();
return value;
}
int _read(int file, char* ptr, int len) {
register int value asm("r0");
uint32_t p[] = { file, (uint32_t)(ptr), len };
R0(0x06);
R1(p);
BKPT();
return value;
}
int _write(int file, char* ptr, int len) {
register int value asm("r0");
uint32_t p[] = { file, (uint32_t)(ptr), len };
R0(0x05);
R1(p);
BKPT();
return value;
}
Also the interruption output from execution:
$ qemu-system-arm -M netduino2 -nographic -semihosting -kernel vp2.bin -d int
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x1
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x1
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x1
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x1
Taking exception 16 [Semihosting call]
...handling as semihosting call 0xc
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x5
What is your name?
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x5
Reading from file...
Taking exception 16 [Semihosting call]
...handling as semihosting call 0xc
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x6
Taking exception 16 [Semihosting call]
...handling as semihosting call 0xc
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x6
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x5
My name is Turing
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x5
I am alive!!!
Taking exception 16 [Semihosting call]
...handling as semihosting call 0xa
Taking exception 16 [Semihosting call]
...handling as semihosting call 0xa
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x2
Taking exception 16 [Semihosting call]
...handling as semihosting call 0x20
Could you please provide any working example using ARM semihosting on stdin?
Thanks,
----
Bruno Prado