m8pple / arch2-2019-cw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ADDR_GETC and ADDR_PUTC

szymonkobus opened this issue · comments

What should happen if the binary tries to read from ADDR_GETC but its not word aligned (i.e. using sh or sb)? and similarly when writing ADDR_PUTC?

commented

How you deal with sub-word access to ADDR_GETC and ADDR_PUTC is, to a large extent, up to you. Three things to keep in mind:

  • Valid accesses within [0x3000000, 0x30000007] should trigger I/O.
  • Endianness should be respected.
  • You should be able to distinguish EOF (-1) from 0xFF.

Note that word alignment and sub-word access are not synonymous; it's possible for you to issue word-aligned SHs, for example.

See also #14 for a fuller discussion.