hawx Posted October 25, 2010 Posted October 25, 2010 (edited) I'm not sure how to work out the answer for these 2 questions: (1) Consider a byte address 0xDEAD on 16-bit machine. What is the corresponding word address? a) 0xDEAD b ) 0xDEAB c) 0xDEAE d) 0xDEAC e) 0xDEAA (2) Consider a byte address 0xDEAD on a 32-bit machine. What is the corresponding word address? a) 0xDEAC b ) 0xDEAB c) 0xDEAE d) 0xDEAD e) 0xDEAA I understand that 16-bit has 2bytes & 32-bit has 4-bytes. For question (1) would i take DE and AD, if so how do i convert is into word addr.? I don't understand the term "word" clearly.... Please explain this and question Thanks for your help:) Edited October 25, 2010 by hawx
vordhosbn Posted October 25, 2010 Posted October 25, 2010 "Word" is usually the definitive characteristic of a given computer architecture. For example, modern processors in PCs are 64-bit, which means they have 64-bit accumulators, in short - their word is 64 bit, they handle their calculation in 64 bit format. In contrast older computers had 32 bit words and even 16 bit words. However, handling data larger than bytes, requires it to be placed at special locations, which is called memory alignment. That means for example, that 4 byte (32 bit data) should be placed only on addresses divisible by 4. I hope, you have now enough information to answer these questions yourself. 1
hawx Posted October 26, 2010 Author Posted October 26, 2010 (edited) Ok so, for 1st questions. On a 16-bit CPU, the 2 byte should be placed on addresses divisible by 2. So I have to separate 0xDEAD into 2 bytes that is: DE AD where DE16 = 22210 & AD16 = 17310 So DE is divisible by 2 but AD is not. If so then, AE16=17410 ; AC16=17210 ; AA16=17010 are all divisible by 2, so which byte is the right one? And What I have understood from "Data structure alignment" theory is that for 16bit CPU the aligned address is 2-byte so there would be log2(2) = 1 least-significant zeros when expressed in binary: DE (1101 1110) & AD (1010 1101) Here the 1st byte has 1 least-significant zero where as the 2nd byte (AD) does not. So the only way a 2nd byte havs 1 least sig. zero is with: AE, AC or AA Same outcome as dividing by 2.... I don't think I have fully understood what a byte and word address is. Are the hex digits the byte addresses? I'm confused... Edited October 26, 2010 by hawx
vordhosbn Posted October 26, 2010 Posted October 26, 2010 (edited) Why are you separating the two bytes of the address? It is just a number. Imagine the computer memory as a very large street. It has houses only on one side, and those houses are numbered 1, 2, 3... and so on. 0xDEAD is just a hex number. Hex numbers are just presented in other counting system. You can say "Humans have 0x20 teeth in general, but I lost one, so now I have only 0x1F." So address 0xDEAD is just the 57005th consecutive byte in the memory (assuming they start at 0x0000 which is not always the case). To understand whether the previous or the next even address is the "corresponding one", you must learn a bit about memory organization. It can be big-endian or little-endian. For example, little-endian is the memory organization in PC processors. On little endian organized memory, the 32-bit integer 0x12345678 with address 0x1004 will be presented as: Memory address: 0x1000 0x1001 0x1002 0x1003 0x1004 0x1005 0x1006 0x1007 0x1008 Value: 0x78 0x56 0x34 0x12 On a big endian organized memory it will be: Memory address: 0x1000 0x1001 0x1002 0x1003 0x1004 0x1005 0x1006 0x1007 0x1008 Value: 0x12 0x34 0x56 0x78 I am not 100% sure what is meant by "corresponding", and I first assumed, the one that gives the word that contains the byte. If so, then in both endiannessess, the corresponding word address to the byte address 0x1005 is 0x1004, because the 32-bit number with address 0x1004 contains the four bytes ahead. Hope I is not very confusing. Maybe I explained a bit extra, but I believe partial understanding is not understanding. edit: Why the forum software is trimming the extra spaces? This is really anoying... Edited October 26, 2010 by vordhosbn
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now