[NSWI004] dump function question

Vojtech Horky horky at d3s.mff.cuni.cz
Fri Oct 9 15:11:17 CEST 2020


Hello.

Dne 09. 10. 20 v 11:54 Georgii Ekserdzhian napsal(a):
> My dump_function works correctly with one exception: it doesn't print 
> leading zeros. I use printk.
> Should I provide an option for a user to specify a padding in printk?

You do not need to implement generic padding functionality.

You can use something like this to print the instruction with leading 
zeros (you can use a similar approach for %pF too).

uint32_t instr = ...;
printk("%x%x%x%x%x%x%x%x",
   instr >> 28,
   (instr >> 24) % 16,
   ...


It is not a very nice solution (maintenance and readability-wise) but 
acceptable for a function that is used only for debugging.

Hope this helps,
- VH


More information about the NSWI004 mailing list