Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

This is a question on a hand out, it asks:

What is the machine code that corresponds to the AVR Assembly Language Instruction inc r22? Enter your answer as a 16 bit binary number. There must be no spaces or punctuation marks - just enter sixteen 1's or 0's.

I found the corresponding machine code which is 1001 010d dddd 0011. I added the binaries together for 22 which is 16 + 6 so:

10000 + 110
= 010110

I assume from here that you just sub it into the d's hence,

1001 010d dddd 0011
1001 0101 0110 0011

And there's the 16 bit answer. Is this correct, or have I done this the wrong way?

share|improve this question
Where did you find 1001 010d dddd 0011? – jippie Apr 14 at 9:08
@jippie avr assembly documents – james kensington Apr 14 at 9:11
Do you have a link to it? – jippie Apr 14 at 9:23
You want the AVR Instruction Set document - doc0856.pdf – Leon Heller Apr 14 at 9:26
Did your teacher work in web design? "Enter your credit card with no spaces, because we can't figure out how to remove them before handing them to the processing API ...". – Kaz Apr 14 at 15:59

1 Answer

up vote 1 down vote accepted

Check it with the assembler!

The code I get for inc r22 is 0x9563, which is 1001010101100011. You are correct!

share|improve this answer
I have no idea how to use the assembler yet, i suck! Thank you – james kensington Apr 14 at 9:39
@jameskensington: Maybe you can improve your answer by describing how to "check it with the assembler"? – Rev1.0 Apr 14 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.