![]() |
![]() |
![]() |
|
|
|||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
show the bit configuration of a 24bit register which its contents represents
the decimal number of 295 in binary code?????????? i dont know where to start this thing what stuff should i read in order to know how to solve this stuff ??? |
|
|
|
|
|
|
(permalink) |
|
Here is the 3 different links telling you about binary system and representation of numbers in binary and other numeral systems.
Representation of numbers Binary numeral system - Wikipedia, the free encyclopedia A tutorial on binary numbers you can get some basics about numeral systems here: Numeral system - Wikipedia, the free encyclopedia as for your question ... 24bit register contain, well, 24 binary digits, so all you need to do is convert 295(10) in to x(2) so it is: 000000000000000100100111 hope that helps
__________________
http://www.it4um.com |
|
|
|
|
|
|
(permalink) |
|
ah, now, depending on the CPU that holds the data, you have 2 groups, big endian (motorolla for e.g.) and little endian (intel for e.g.)... for little endian the representation is "normal" so the number will be arranged in memory as follows:
Base Address+0 Byte0 Base Address+1 Byte1 Base Address+2 Byte2 Base Address+3 Byte3 for big endian it is bit different: Base Address+0 Byte3 Base Address+1 Byte2 Base Address+2 Byte1 Base Address+3 Byte0 so in your case with 24bit register (3 bytes) it would be Base Address+0 Byte2 Base Address+1 Byte1 Base Address+2 Byte0 so for big endian cpu the solution to your question is 001001110000000100000000
__________________
http://www.it4um.com |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Edit, to the OP, the answer given above is wrong. The correct answer is 100100111. The (digit) columns are numbered 256,128,64,32,16,8,4,2,1 and if you add up the columns with a one then you will get 295. Mike. Last edited by Pommie; 20th May 2008 at 01:59 PM. |
||
|
|
|
|
|
(permalink) |
|
Mike, I might be wrong here as it was reeeeeeaaaaaaly long time ago since I did some ASM programming but if I remember correctly, big endian CPU's store data in registers the same way they store them in RAM .. as the question was show the bit configuration of a 24bit register if I recollect correctly (and please correct me if I'm wrong as I'm not 100% sure) the big endian CPU will have register storing number 295(10) as
Code:
bit23 bit0 | | v v 001001110000000100000000
__________________
http://www.it4um.com |
|
|
|
|
|
|
(permalink) |
|
When we write down the value of a (24bit) register we can do it in any base that we like. Whichever base we choose, we put the most significant digit first. What you are saying is that on a little/big endian computer that pi would be 1.3149562 when we all know it's 3.1415926. The reason I put little/big is because the endianess is simply an argument over which way around the bytes should be stored. Everyone writes 0x123456 to represent a 24 bit number. Nobody switches it around to 0x563412 because of endianess.
Mike. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
I agree with Mike's solution. To show the working of how to convert that 295 decimal number. Subtract the largest 2^n power from the number so: 295 - 256 = 39..............1 39 cant subtract 128......0 39 cant subtract 64.... .0 39 - 32 = 7..................1 7 cant subtract 16........0 7 cant subtract 8..........0 7 - 4 = 3.....................1 3 - 2 = 1.....................1 1 - 1 = 0.....................1..........lsb The correct answer is 1,0010,0111 To normalise for a 24 bit pattern, add leading zero's 0000,0000,0000,0001,0010,0111[lsb] the comma's are for clarity only.!
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
||
|
|
|
|
|
(permalink) | |
|
Quote:
I agree that value of any number has nothing to do with endian, nor with cpu itself ... 0x0f0f(16) is same value however the endian philosophy of the CPU is, but, (now this is the part where I believe I'm making a mistake and you please be so kind to make it right) if we do following (now, I have to use C as my ASM is non existing attm) Code:
unsigned int32 *x[1]; //32 bit int
unsigned int8 *y; //8 bit int
x[0]=0x01020304;
y = x;
// for little endian
if (y[0] == 0x01) { this is true }
if (y[1] == 0x02) { this is true }
if (y[2] == 0x03) { this is true }
if (y[3] == 0x04) { this is true }
//for big endian
if (y[0] == 0x04) { this is true }
if (y[1] == 0x03) { this is true }
if (y[2] == 0x02) { this is true }
if (y[3] == 0x01) { this is true }
now, I might be off here, but I'm pretty sure I'm right as I remember I had load of problems when I switched from 8051 to HC... ages ago
__________________
http://www.it4um.com Last edited by arhi; 20th May 2008 at 02:52 PM. Reason: typo |
||
|
|
|
|
|
(permalink) |
|
hi,
Its just the Byte order thats different, not the byte bit pattern/weighting order. HB,LB...............LB,HB The bit weighting is always leftmost = highest weighting,, rightmost = lowest. Does this help.?
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
|
|
|
|
|
|
(permalink) | |
|
Quote:
the bit weight is clear ... binary number is binary number it has nothing to do with byte order. - this part I do not have problem with, from the start. What I am talking about, and that confuses me now (and never before this conversation if you look at the code I wrote .. (it should be correct) .. you can see that for same value, different endian will store in ram same value with different byte order. Can we agree on that? Now, let us look at the register, it is also "memory location" only within CPU. and the number is stored in that register (24bit register is 3 bytes) in same order as it is stored in RAM. so, physical location of the highest significant bit of the 3byte binary value will not be on the leftmost physical position of the register that is 3byte big on the big endian box. so, in theory, if we have 2byte register that can be also addressed as 2 single byte registers Code:
| BX | | BH | BL | on low endian BH=0xff; BL=0x00; and on big endian BH=0x00 BL=0xFF so the difference is how the value (value is always same) stored physically inside the register/RAM it does not mean that binary representation of that number is different ... as 0x010101 is allways 0x010101 no matter what CPU/MCU/device is used .. now, where do I make mistake ... for little endian, if AX = 0xFF00
__________________
http://www.it4um.com |
||
|
|
|
|
|
(permalink) | |
|
Quote:
I think the misunderstanding could lie in the fact, that the cpu 'accumulator' is 8 bits wide and the processing is on 8 bit bytes. Its just the order which the 'acc' accesses the 8 bit bytes, hi thru lo or vice versa. So the bit weighting is always the same.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 20th May 2008 at 04:36 PM. |
||
|
|
|
|
|
(permalink) |
|
the register of 24bit
says only that we need to represent it using number of length of 24 digits so what you did is just transform it into a binary numbers with length 24 and the value of 295 know if i understand you correctly in order to represent 295 into BCD i need to add six 295+6=301 which is 301-256=45 1 45-128 0 45-64 0 45-32 1 13-16 0 13-8 1 5-4 1 1-2 0 1-1 1 which is 000000000000000100101101 am i correct ?? |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
You are going to convert a decimal number into BINARY, NOT BCD! Where did this idea of adding six come from?? WRONG!! Quote:
Eric Gibbs showed the correct solution several posts ago. JimB
__________________
Experience is directly proportional to the value of the equipment ruined. |
|||
|
|
|
|
|
(permalink) |
|
i transformed it into BCD thats why i added six
is it ok regarding the 24bit register ?? |
|
|
|
|
|
|
(permalink) |
|
How does adding six transform it into BCD?
JImB
__________________
Experience is directly proportional to the value of the equipment ruined. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| how to solve this question | transgalactic | Electronic Projects Design/Ideas/Reviews | 3 | 6th May 2008 08:43 PM |
| semicondutor material | shermaine | General Electronics Chat | 4 | 15th September 2007 07:49 PM |
| Layout Question -- need good reference material | Brocktune | General Electronics Chat | 2 | 12th May 2004 06:13 PM |
| Question about reading bits from ports. | Blueteeth | Micro Controllers | 5 | 5th January 2004 01:08 PM |
| Reading material frm Texas Inst. | mozikluv | Datasheet/Parts Requests | 5 | 11th October 2003 01:34 AM |