- case 1:
- case 2:
- case 4: /* long, float */
- val = extract_unsigned_integer (valbuf, len);
- regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
- break;
- case 8: /* long long, double and long double are all defined
- as 4 byte types so far so this shouldn't happen. */
- error ("I don't know how to return an 8 byte value.");
- break;
+ case 1:
+ case 2:
+ case 4: /* long, float */
+ val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
+ regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
+ break;
+ case 8:
+ val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
+ regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
+ (val >> 32) & 0xffffffff);
+ regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM,
+ val & 0xffffffff);
+ break;
+ }
+}
+
+static enum return_value_convention
+h8300_return_value (struct gdbarch *gdbarch, struct value *function,
+ struct type *type, struct regcache *regcache,
+ gdb_byte *readbuf, const gdb_byte *writebuf)
+{
+ if (h8300_use_struct_convention (type))
+ return RETURN_VALUE_STRUCT_CONVENTION;
+ if (writebuf)
+ h8300_store_return_value (type, regcache, writebuf);
+ else if (readbuf)
+ h8300_extract_return_value (type, regcache, readbuf);
+ return RETURN_VALUE_REGISTER_CONVENTION;
+}
+
+static enum return_value_convention
+h8300h_return_value (struct gdbarch *gdbarch, struct value *function,
+ struct type *type, struct regcache *regcache,
+ gdb_byte *readbuf, const gdb_byte *writebuf)
+{
+ if (h8300h_use_struct_convention (type))
+ {
+ if (readbuf)
+ {
+ ULONGEST addr;
+
+ regcache_raw_read_unsigned (regcache, E_R0_REGNUM, &addr);
+ read_memory (addr, readbuf, TYPE_LENGTH (type));
+ }
+
+ return RETURN_VALUE_ABI_RETURNS_ADDRESS;