Codes

1. Float Format (f)

Add format f to interpret the next 4 bytes as a 32-bit floating-point number.

case 'f': {
  float fv = *(float *)p;
  // xv6 printf usually requires doubles for float args
  printf("%f\n", (double)fv); 
  p += 4;
  break;
}

2. Octal Format (o)

Add format o to print the next 4 bytes as an octal (base-8) integer.

case 'o': {
  int v = *(int *)p;
  printf("%o\n", v);
  p += sizeof(int);
  break;
}

3. Binary Format (b)

Add format b to print the next 1 byte as 8 bits of binary (e.g., 01010101).

4. Hex without Prefix (x)

Add format x to print 4 bytes in hexadecimal without the standard 0x prefix.

5. Truncated String Pointer (s)

Modify the s (pointer) format to truncate and only print the first 8 characters of the string.

6. Address Tracking (A)

Add a format character A that prints the hex memory address of the current data pointer.

7. Skip Logic (k)

Implement a "skip" character k that advances the data pointer by 4 bytes without printing anything.

8. Item Delimiter

Modify memdump to print a custom delimiter (like a vertical bar |) between every parsed item.

9. Big-Endian Integer

Change the integer format i to print the 4 bytes in Big-Endian order instead of Little-Endian.

10. String Length Tracking (S)

Change format S (inline string) to print the string length in parentheses after the text.

Last updated