Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


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.

Reply
 
Thread Tools Display Modes
Old 20th May 2008, 01:09 PM   (permalink)
Default i am looking for reading material to solve this question..

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
???
transgalactic is offline   Reply With Quote
Old 20th May 2008, 01:26 PM   (permalink)
Default

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
arhi is offline   Reply With Quote
Old 20th May 2008, 01:37 PM   (permalink)
Default

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
arhi is offline   Reply With Quote
Old 20th May 2008, 01:52 PM   (permalink)
Default

Quote:
Originally Posted by arhi View Post
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
That is one way to confuse people. Representing numbers in binary has nothing to do with endian. Numbers in any base have the most significant digit first. Your above example is in base 256 and even in that base we put the most significant digit first. How it is stored in memory is a completely different thing.

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.
Pommie is offline   Reply With Quote
Old 20th May 2008, 01:57 PM   (permalink)
Default

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
arhi is offline   Reply With Quote
Old 20th May 2008, 02:12 PM   (permalink)
Default

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.
Pommie is offline   Reply With Quote
Old 20th May 2008, 02:36 PM   (permalink)
Default

Quote:
Originally Posted by transgalactic View Post
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
???
hi,
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/
ericgibbs is offline   Reply With Quote
Old 20th May 2008, 02:51 PM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
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.
Mike, I believe you managed to confuse me, but I want to get this clear in my mind so I will try to explain what I think and allow myself to learn from the master.

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 believe we can agree with this code ? the value of x is always 0x01020304 but it is stored in RAM differently in big endian then in little endian cpu. same thing should be with the register. Register itself is hold same value on both CPU's but the bit configuration of the register on one and the other CPU is not same. On little endian CPU the bit0 (the rightmost one) have LSB of the value and on big endian CPU that is not the case. As question was how the value affect bit configuration of the register, I assume question is, what is the value of every particular bit in the register and not what is the binary representation of the decimal number, 295 = 0b0100100111 = 0x127, the question was (if I understood it correctly) what would be the actual bit's in the register that will store this value

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
arhi is offline   Reply With Quote
Old 20th May 2008, 03:16 PM   (permalink)
Default

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/
ericgibbs is offline   Reply With Quote
Old 20th May 2008, 03:34 PM   (permalink)
Default

Quote:
Originally Posted by ericgibbs View Post
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.?
to be honest, no

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 ) is "hardware presentation" ...

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 |
then if BX = 0xFF00;
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
arhi is offline   Reply With Quote
Old 20th May 2008, 04:36 PM   (permalink)
Default

Quote:
Originally Posted by arhi View Post
to
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?
I agree its stored in 4 different 8 bit registers, one set in ascending the other in descending byte order.

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)
Its not a 24bit register, but three separate, 8 bit registers.

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 |
then if BX = 0xFF00;
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
Hi arhi,
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.
ericgibbs is offline   Reply With Quote
Old 20th May 2008, 07:30 PM   (permalink)
Default if i understand you correctly..

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
??
transgalactic is offline   Reply With Quote
Old 20th May 2008, 08:27 PM   (permalink)
Default

Quote:
Originally Posted by transgalactic View Post
know if i understand you correctly in order to represent 295
into BCD
NO!!
You are going to convert a decimal number into BINARY, NOT BCD!


Quote:
Originally Posted by transgalactic View Post
i need to add six 295+6=301
Where did this idea of adding six come from?? WRONG!!

Quote:
Originally Posted by transgalactic View Post
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
??
Your process is correct, apart from adding this silly six.
Eric Gibbs showed the correct solution several posts ago.

JimB
__________________
Experience is directly proportional to the value of the equipment ruined.
JimB is offline   Reply With Quote
Old 20th May 2008, 08:44 PM   (permalink)
Default here i did..

i transformed it into BCD thats why i added six

is it ok regarding the 24bit register ??
transgalactic is offline   Reply With Quote
Old 20th May 2008, 11:23 PM   (permalink)
Default

How does adding six transform it into BCD?

JImB
__________________
Experience is directly proportional to the value of the equipment ruined.
JimB is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 09:08 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.