0

The main problem we encountered is that one number is saved as a byte, the other is saved as a word and we realize that there's a built in XOR in PDP-11.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Sam12
  • 1,805
  • 2
  • 15
  • 23
  • https://stackoverflow.com/questions/4749585/what-is-the-meaning-of-xor-in-x86-assembly – Postica Ðenis Dec 17 '17 at 21:10
  • @PosticaÐenis I think the user's problem is that he wants to do this on PDP-11 architecture. – Martin Rosenau Dec 17 '17 at 21:12
  • So zero-extend the shorter one or truncate the longer one. – Peter Cordes Dec 17 '17 at 21:12
  • Bytes on PDP-11? – Martin Rosenau Dec 17 '17 at 21:13
  • @MartinRosenau: What's weird about that? [PDP-11](https://en.wikipedia.org/wiki/PDP-11_architecture) has 8-bit bytes and 16-bit words. It's not one of those old architectures with a non-power-of-2 word size. – Peter Cordes Dec 17 '17 at 21:15
  • @PeterCordes OK. Thanks. I just read your link. I was thinking that PDP-11 works like other "pre-CPU" computers or the modern TMS320 where the memory does not store bytes but 16-bit words (so there are no instructions that can handle bytes). – Martin Rosenau Dec 17 '17 at 21:27
  • @MartinRosenau: Ah yes, right some machines only have word-addressable memory ([the most recent mainstream CPU example being early DEC Alpha in the early 90s](https://stackoverflow.com/questions/46721075/can-modern-x86-hardware-not-store-a-single-byte-to-memory/46818162#46818162), but also including some modern DSPs) But they still have bytes, you just have to load + shift&mask if you want them separately. (But in that case the OP would already know how to deal with bytes using full registers to have stored a byte in the first place) – Peter Cordes Dec 17 '17 at 21:56

1 Answers1

4

The XOR instruction on the PDP-11 only works on 16-bit words.

You will have to make a 16-bit word out of the byte operand first. Whether that is zero-extension or sign-extension (maybe SXT can help?) is up to you.

Then apply XOR to the two word arguments.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Ray Toal
  • 86,166
  • 18
  • 182
  • 232