Thread: help me in this code

  1. #1
    Registered User
    Join Date
    Jul 2019
    Posts
    4

    help me in this code

    hi guys Can you explain the code below for me ? the three segments display :
    the longest string of 1’s
    the longest string of 0’s.
    the longest alternating 1’s and 0’s.
    the results are displayed on 7 segment displays called HEX0,....HEX6 on a chip with the addresses as shown in the link

    Capture — imgbb.com

    #define HEX3_HEX0_BASE 0x10000020
    #define HEX7_HEX4_BASE 0x10000030

    char seg7[10] = {0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110,
    0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01100111}; /* first number to display 0,second1,2,3.....9*/

    /* display count of number of 1's */
    for (i = 0; long_1s > 9; i++)
    long_1s -= 10;
    *HEX3_HEX0_ptr = seg7[i] << 8;
    *HEX3_HEX0_ptr |= seg7[long_1s];


    /* display count of number of 0's */
    for (i = 0; long_0s > 9; i++)
    long_0s -= 10;
    *HEX3_HEX0_ptr |= seg7[i] << 24;
    *HEX3_HEX0_ptr |= seg7[long_0s] << 16;


    /* display count of number of alternating 1's and 0's */
    for (i = 0; long_alt > 9; i++)
    long_alt -= 10;
    *HEX7_HEX4_ptr = seg7[i] << 8;
    *HEX7_HEX4_ptr |= seg7[long_alt];
    Last edited by monther; 07-10-2019 at 12:35 AM.

  2. #2
    Registered User
    Join Date
    Jul 2019
    Posts
    4
    thx guys .
    i modified the code in a simpler way

    can i delete the post?

  3. #3
    Registered User
    Join Date
    Feb 2019
    Posts
    436
    You may enjoy Henry S. Warren Jr book "Hacker's Delight"

  4. #4
    Registered User catacombs's Avatar
    Join Date
    May 2019
    Location
    /home/
    Posts
    71
    Please format your code next time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-19-2012, 01:58 PM
  2. Replies: 1
    Last Post: 03-10-2010, 11:28 AM
  3. Replies: 14
    Last Post: 04-01-2008, 02:23 AM
  4. Having trouble translating psudeo-code to real-code.
    By Lithorien in forum C++ Programming
    Replies: 13
    Last Post: 10-05-2004, 07:51 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

Tags for this Thread