aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/target/semihosting_common.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c
index 2c7f4a1..cae6afb 100644
--- a/src/target/semihosting_common.c
+++ b/src/target/semihosting_common.c
@@ -1641,17 +1641,11 @@ static int semihosting_common_fileio_end(struct target *target, int result,
*/
switch (semihosting->op) {
case SEMIHOSTING_SYS_WRITE: /* 0x05 */
+ case SEMIHOSTING_SYS_READ: /* 0x06 */
if (result < 0)
- semihosting->result = fileio_info->param_3;
+ semihosting->result = fileio_info->param_3; /* Zero bytes read/written. */
else
- semihosting->result = 0;
- break;
-
- case SEMIHOSTING_SYS_READ: /* 0x06 */
- if (result == (int)fileio_info->param_3)
- semihosting->result = 0;
- if (result <= 0)
- semihosting->result = fileio_info->param_3;
+ semihosting->result = (int64_t)fileio_info->param_3 - result;
break;
case SEMIHOSTING_SYS_SEEK: /* 0x0a */