0
\$\begingroup\$

When it is about an 16 bit microcontroller with 16-bit adress 0xFFFF(the largest 16-bit number is 0xFFFF in hex or 65535 in decimal) the following picture is given and total memory space is given as 64KB:

enter image description here

I take 1 byte as 8 bits. Above the blue is my calculation of the memory space. I calculate it as 128KB but it is given as 64KB. Where am I wrong?

\$\endgroup\$
5
  • \$\begingroup\$ Hm. You have 65536 addresses, while each one can contain one byte (you can see that each 16-bits line is occupying two addresses on your diagram). So 64KB in total. All the other stuff around if really unnecessary. \$\endgroup\$
    – Eugene Sh.
    Nov 5, 2019 at 19:07
  • \$\begingroup\$ Memory is usually byte-adressable and not word-adressable. Thus 64K x8 bit = 65535 bytes. \$\endgroup\$
    – Turbo J
    Nov 5, 2019 at 19:07
  • \$\begingroup\$ I dont get isnt 16 bit 2 bytes? 2 bytes per raw isnt it? \$\endgroup\$
    – floppy380
    Nov 5, 2019 at 19:08
  • 2
    \$\begingroup\$ And two addresses per row. One on the left, one on the right. \$\endgroup\$
    – Eugene Sh.
    Nov 5, 2019 at 19:11
  • \$\begingroup\$ According to international standards, a memory of 65536 bytes would be 64 kibibytes (64 KiB) rather than 64kB. \$\endgroup\$ Nov 6, 2019 at 0:49

1 Answer 1

4
\$\begingroup\$

The diagram is trying to show that within each 16-bit word the even byte address represents the least significant half while the most significant half is represented by the odd address.

There are 2^15 16-bit words (32,768) or 2^16 8-bit bytes (65,536).

Some processors such as the Atmel AVR series have 16-bit instructions so a 16-bit program counter can address 128kB of instruction space, but the 16-bit address from the general purpose registers can only access 64kB of data space.

Special instructions are used to access instruction space as data where an extra register has to be used to extend the addressing range - for example the ATMEGA128 has a single bit in the RAMPZ register to provide 17 bits in total.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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