+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 19

Thread: i am looking for reading material to solve this question..

  1. #1
    Banned transgalactic Bad transgalactic Bad transgalactic Bad
    Join Date
    Apr 2008
    Posts
    240

    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
    ???


  2. #2
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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

  3. #3
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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

  4. #4
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,815

    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 02:00 PM.

  5. #5
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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
    

  6. #6
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,815

    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.

  7. #7
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,853
    Blog Entries
    13

    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 "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

    Link to my Articles: http://www.electro-tech-online.com/a...icgibbs-55450/

  8. #8
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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

  9. #9
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,853
    Blog Entries
    13

    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 "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

    Link to my Articles: http://www.electro-tech-online.com/a...icgibbs-55450/

  10. #10
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    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

  11. #11
    ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent ericgibbs Excellent
    Join Date
    Jan 2007
    Location
    Hampshire. England.
    Posts
    10,853
    Blog Entries
    13

    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.
    Last edited by ericgibbs; 20th May 2008 at 04:37 PM.
    Eric " Good enough is Perfect "
    I will NOT answer PM's requesting technical help, please use the Forum
    PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

    Link to my Articles: http://www.electro-tech-online.com/a...icgibbs-55450/

  12. #12
    Banned transgalactic Bad transgalactic Bad transgalactic Bad
    Join Date
    Apr 2008
    Posts
    240

    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
    ??

  13. #13
    JimB Excellent JimB Excellent JimB Excellent JimB Excellent JimB Excellent JimB Excellent
    Join Date
    Sep 2004
    Location
    Peterhead, Scotland
    Posts
    1,947

    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.

  14. #14
    Banned transgalactic Bad transgalactic Bad transgalactic Bad
    Join Date
    Apr 2008
    Posts
    240

    Default here i did..

    i transformed it into BCD thats why i added six

    is it ok regarding the 24bit register ??

  15. #15
    JimB Excellent JimB Excellent JimB Excellent JimB Excellent JimB Excellent JimB Excellent
    Join Date
    Sep 2004
    Location
    Peterhead, Scotland
    Posts
    1,947

    Default

    How does adding six transform it into BCD?

    JImB
    Experience is directly proportional to the value of the equipment ruined.

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. how to solve this question
    By transgalactic in forum Electronic Projects Design/Ideas/Reviews
    Replies: 3
    Latest: 6th May 2008, 08:43 PM
  2. semicondutor material
    By shermaine in forum General Electronics Chat
    Replies: 4
    Latest: 15th September 2007, 07:49 PM
  3. Layout Question -- need good reference material
    By Brocktune in forum General Electronics Chat
    Replies: 2
    Latest: 12th May 2004, 06:13 PM
  4. Question about reading bits from ports.
    By Blueteeth in forum Micro Controllers
    Replies: 5
    Latest: 5th January 2004, 01:08 PM
  5. Reading material frm Texas Inst.
    By mozikluv in forum Datasheet/Parts Requests
    Replies: 5
    Latest: 11th October 2003, 01:34 AM

Tags for this Thread