LalSalaamComrade

Yup, that’s me, President of the agAdbefdsds…what, where am I?

  • 91 Posts
  • 383 Comments
Joined 1 year ago
cake
Cake day: October 3rd, 2023

help-circle
  • This worked for me - I think %p fixed the issue of incorrect representation, as well as input. I also tried unsigned long int, which works in place of uintptr_t, but I’m assuming that it isn’t portable.

    Resolved code snippet
    /* Allows the user to view regions of computer memory */
    
    #include <ctype.h>
    #include <stdint.h>
    #include <stdio.h>
    
    typedef unsigned char BYTE;
    
    int
    main (void)
    {
      uintptr_t addr;
      int i, n;
      BYTE *ptr;
    
      printf ("Address of main function: %p\n", (void *) &main);
      printf ("Address of addr variable: %p\n", (void *) &addr);
      printf ("\nEnter a (hex) address: ");
      scanf ("%p", &addr);
      printf ("Enter number of bytes to view: ");
      scanf ("%d", &n);
    
      printf ("\n");
      printf (" Address               Bytes             Characters\n");
      printf (" ------- ------------------------------- ----------\n");
    
      ptr = (BYTE *) addr;
      for (; n > 0; n -= 10)
        {
          printf ("%8X  ", (uintptr_t) ptr);
          for (i = 0; i < 10 && i < n; i++)
            printf ("%.2X ", *(ptr + i));
          for (; i < 10; i++)
            printf ("   ");
          printf (" ");
          for (i = 0; i < 10 && i < n; i++)
            {
              BYTE ch = *(ptr + i);
              if (!isprint (ch))
                ch = '.';
              printf ("%c", ch);
            }
          printf ("\n");
          ptr += 10;
        }
    
      return 0;
    }
    






  • I don’t know the specifics, but why would 5 bits be a problem on a 16bit machine?

    Because I’m assuming that there’s only 16 bits, right, and hence these have to be divided between hours, minutes and seconds:

    • 5 bits for the hours (25 = 32, to represent numbers from 0-23)
    • 6 bits for the minutes (26 = 64, can represent numbers from 0-59)
    • the 5 bits for the seconds (25 = 32, can only represent numbers from 0-31, what about seconds 32-59?)

    5 + 6 + 5 = 16 bits in total. This is why the last one makes no sense, unless the timeformat precision was restricted to 2 seconds?



  • This seems to be the likely answer. I’m assuming that it has something to do with the technological limitation of 16 bit. 1981 saw the first 32-bit non-x86 microprocessor (Intel iAPX 432), and MS-DOS was released for 16-bit in mind, like the 8086. Perhaps, the highest size of the integer was limited to 16 bit as well, and with that in mind, they had to make sure to create a non-padded struct for time, in which the hour were allotted 5 bits (= 32 ≈ 24hour), minutes were allotted 6 bits (= 64 ≈ 60mins). The last remaining 5 bits were assigned to seconds, and with the remaining bit-fields, the best precision they could come up with gave a 2-second interval. Is that a fair reasoning?



  • Since there’s no answer from Guix users over here, well, I use Guix as my main distro. The language choice is superior to Nix’s half-Haskell DSL. However, the bigger issue with Guix is the lack of maintainers. NodeJS hasn’t been updated since the last five year and Zig lacks a lot of packages. Another big issue is the centralized GNU server, which can fail at any moment. Their servers are all located in either the USA, or Europe, and for Asia, downloading NARs with such slow speed is a pain in the ass.








  • It’s not a success. Two-state solution is a failure. Be it India-Pakistan, East-West Germany, North-South Korea or Sudan-South Sudan.

    As someone from India, the two-state solution for India-Pakistan was a massive disaster. One of the worst man-made catastrophe. Rape, murder and violence between different ethnic groups, it was horrible. People were forcibly displaced to the other side of the country, leaving behind their ancestral village and belongings. This destroyed their culture and their language, stripped their identity.

    These states were divided to satisfy the egoes of the two major political dynasts, Nehru and Jinnah, and as typical of pretend-socialist liberals, they were supported by the Hindu Mahasabha and the All India Muslim league.

    Pakistan forced the use of Urdu, an Indian language, because their native languages had Devanagari-resembling script, and for that strong Muslim identity they went for a language with a Farsi script… except that the language was Khadi Boli (a language from UP) with borrowed Farsi words.

    Well, what about India? They went ballistic sub-nationalist. State majoritarians forced language on vulnerable groups, including mine (obligatory middle-finger to the Basel Mission and Kannada chauvinists).

    Later, Pakistan’s ethnic cleansing and rape of Bengalis, especially Hindus in East Pakistan (East Bengal) backfired, and the country broke into three. Cut to 2024, the people of Kashmir suffer even to this day.

    If only the Indian communists from the HSRA had not been betrayed by the INC, a greater India with none of the communal B.S. would have existed. There would have been no Hindutva or Deobandi extremists jump around and squirming like cockroaches. And we have two countries armed to the brim with nuclear weapons.