I want to represent 13 instructions, use 1 register operand and an immediate value that represent at least the number 1048576 (2^20). I have 94 general purpose registers and 32 bit instructions. Will this be possible? My maths tells me the following. 4 bits for the opcode, 7 bits for the register operand, and 21 bits for the immediate. \$4 + 7 + 21 = 32\$

However, immediates are usually represented in 2's complement notation. So, I'm not sure if 21 bits is enough. Hence, I might need 22 bits. Which would then mean that 32 bits are not enough. Am I correct in my analysis?

  • \$\begingroup\$ "I want ... an immediate value that represent at least the number 1048576" - Why this particular number? \$\endgroup\$ – Bruce Abbott Apr 15 '17 at 6:35
  • \$\begingroup\$ I am to make an ISA and one of my constraints is to be able to access an address particularly that large. \$\endgroup\$ – Jonathan Apr 15 '17 at 7:10
  • \$\begingroup\$ The question is not only what the biggest number is, but also whether what your smallest number is – the total number of number determines the number of bits needed to represent that number of numbers :D \$\endgroup\$ – Marcus Müller Apr 15 '17 at 9:21
  • \$\begingroup\$ Addresses are generally unsigned, so a 20 bit address ranges from 0 to 1048575. 1048576 would need 21 (unsigned) bits. \$\endgroup\$ – Bruce Abbott Apr 15 '17 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.