27 March 2003

Share

Well, I’ve got that maths test this afternoon, and then the local LUG meets tonight. Apart from that, not much on. It will be good to have the test out of the way, because it will free up some time for more interesting coding again. I have an assignment due next week (and a test the week after), but they’re for Statistics, so I am not too worried about them.

The other hard thing is deciding which thing to work on next. I think I might finish playing with my first x86 assembly project, because it is interesting, and easy to get out of the way.

Then probably back to FAT filesystem parsing code.

Share

26 March 2003

Share

Well, with the article out of the way I am meant to be worrying more about studying for this maths test. It’s not too bad — group theory isn’t too ugly (except for calculating inverses in some instances), and GCD stuff is ok once you get your head around some of the funny table representations they use for stuff.

On the new maths front, we were playing with decrypting messages in the number theory class today. Very cool.

Share

25 March 2003

Share

Doing one last final proof read on the article now, then I’ll send it. This will be a good thing, because it will mean that I can then move on and start studying for the maths test I have in three days from now. I don’t think the test is too bad though — it’s on group theory, with a bit of greatest common divisor theory thrown in for good luck.

Share

24 March 2003

Share

Wow! I’m still fussing over that article. It’s due in two days time (US time). I need to get it out of the way so I can study for my maths test. I vow to have it finished by bed tonight, dispite having to work through a Law and Order backlog.

Share

23 March 2003

Share

More work on the article. Also had a play with a simple hello world linux kernel module. I can’t get it to compile because of MODVERSIONS though. I am going to have to think about it more…

Share

21 March 2003

Share
Vasantha’s farewell at work today — it took the vast majority of the afternoon… Hopefully she’ll get well soon and her urge to go to the UK will subside. For those interested, the the pictures are here. Higher resolution copies are available on request.
Share

22 March 2003

Share

Well, working at home on a Saturday again. I’m still finishing off the article for the unnamed journal, I should be studying for a maths test I have next week, and generally procrastinating. Utah Saints still rock too…

I also downloaded heaps of free TrueType fonts, in order to assist my wife with her cross stich endevours.

Suffered through a bush dance because it one of those things we do to stay happily married. In actual fact, it wasn’t as bad as I first thought it would be…

Share

20 March 2003

Share

Wrote my first x86 assembly last night (I’ve only done M68000 until now). It’s nothing special, it just calls the CPUID instruction, which is available from kernel and userspace, and decodes one of the possible outputs:

#include <stdio.h>

/*
 * Generic CPUID function (stolen from Linux 2.5.59)
 */
static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
{
       __asm__("cpuid"
              : "=a" (*eax),
                "=b" (*ebx),
                "=c" (*ecx),
                "=d" (*edx)
              : "0" (op));
}

void registerToAscii(int reg)
{
  printf("%c", reg);
  reg = reg >> 8;
  printf("%c", reg);
  reg = reg >> 8;
  printf("%c", reg);
  reg = reg >> 8;
  printf("%c", reg);
}

int main(int argc, char *argv[])
{
  int a, b, c, d;

  printf("Calling cpuid with an input operand of zero\n\n");
  cpuid(0, &a, &b, &c, &d);

  printf("Got back: 0x%08x 0x%08x 0x%08x 0x%08x\n", a, b, c, d);
  printf("This decodes to: ");
  registerToAscii(b);
  registerToAscii(d);
  registerToAscii(c);
  printf("\n");
}

This gives the following on my Pentium III laptop:

#./cpuid
Calling cpuid with an input operand of zero

Got back: 0x00000002 0x756e6547 0x6c65746e 0x49656e69
This decodes to: GenuineIntel

I had no trouble finding instruction references for the Intel x86 chips. Where do I find the same documentation for the various AMD, Via, Cyrix et al chips floating around?

All of this was prompted by having a look at the x86info code, and the cpuid function in the 2.5.59 kernel tree I have been poking around in and deciding that I would like to understand at least a little more about what was happening. The hardest bit (and it isn’t very hard) is to determine what the GCC inline assembly syntax means. I recommend this IBM DeveloperWorks article…

Share