0

For example, if I have the number #1020h represented in hexadecimal, the most significant part is the 10 and the least is the 20. Is there an easy way of doing this? I'm using a 8 bit risc assembly simulator

Edit: I was told I had to use the JC conditional

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • @Jonas please don't leave questions without any ISA tags at all. [8-bit] and [risc] aren't good, but at least 8-bit should probably stay. I agree with your edit to the usage-guidance of [tag:risc], but removing it from existing questions one at a time is mostly just going to be edit noise except where you're adding a correct tag like arm, avr, mips, or risc-v that was previously missing. (But I guess removing it from everywhere is a good way to filter out questions you've already looked at.) – Peter Cordes Jan 04 '21 at 10:09
  • @PeterCordes fair enough, I agree that every assembly question should have a tag for the specific ISA. – Jonas Jan 04 '21 at 10:16
  • @Jonas: AVR is the only 8-bit RISC I know of, so I'll take a wild guess on that. Not that it matters much. – Peter Cordes Jan 04 '21 at 10:17
  • @PeterCordes sure, but I don't agree that [bigint] or [8-bit] is its own topics - that e.g. can serve as an alone tag to represent the content, see e.g. https://meta.stackoverflow.com/questions/399160/what-is-considered-a-meta-tag-and-should-meta-tags-be-banned-burninated-remo – Jonas Jan 04 '21 at 10:20
  • @Jonas: [8-bit] would be a more relevant tag if the question actually mentioned 16-bit numbers in the title; the answer applies to all 8-bit ISAs in general, but agreed it's kind of a meta tag. But [bigint] is relevant because the question is about techniques for working with numbers larger than 1 register, which are often similar across ISAs (e.g. like how to do a 2x2 chunk multiply including the cross-multiplies of low x high as well as low x low full multiply.) Although the intent of the tag might be for variable-length types in higher-level languages. – Peter Cordes Jan 04 '21 at 10:23

1 Answers1

1

In an 8-bit system (like 8-bit RISC AVR for example) a 16-bit number is already stored as 2 separate bytes. You don't have to do anything special; it's already in separate registers so you literally already have the 0x10 high byte isolated in a register with zero instructions.

Or you already need to deal with its storage in memory as 2 separate bytes, e.g. using 2 separate load instructions.

Also, if you need to branch then there's some other part of the problem you aren't mentioning, like maybe adding two other numbers to get this 16-bit number.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847