In my searching although this question seems to get answered a lot, the answers don't really cover what I want to ask.
I'm learning assembly and my question is, in higher level languages e.g C data types are defined as a certain length e.g
Char: 1 byte
Short: 2 bytes
Long: 4 bytes
Here's a block of memory, say I defined a variable of type Short in my high level language and it just so happenes to start at memory location 0x0002.
How does the generated assembly know what type it is and to only read 2 bytes. Is it the case that the compiler scans the code for any overflow errors when compiling then writes the assembly in such a way that when it accesses that memory location it only ever reads two bytes because it was defined as a Short at high level e.g
LDI r0, $0x0002
Or does it keep a lookup somewhere of memory locations and their types?
I'm hoping my question makes sense but please let me know if it doesn't and I'll do my best to clear any questions up.