Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was looking at how Assembly Language works, because I want to learn how the complex and fancy things my computer does actually happen at the CPU register/hardware levels. Is there any way to see what's going on during normal computer use?

I want to learn like, what kind of things go in and out of the various registers while I'm say, browsing the internet or playing a game, etc. Though even if I could watch this I am not sure how I could correlate it to specific computations that I can see happening at a higher level. That is, I don't know how I would know if this hex code going into this register at this time is related to Firefox processing SSL encryption, etc.

share|improve this question
    
I dont think this is possible and even if it was how you would be able to see it. Even when your computer is idle, its doing a lot –  Keltari Sep 14 '12 at 17:55
add comment

2 Answers 2

up vote 4 down vote accepted

You realize that these CPUs run at 3GHz or so - if you wanted to run at real time, there's no way that your (or my) puny brain could keep up.

And a minor quibble: you don't look at assembler on the CPU, you strip away some info and go straight to machine code. There's no "branch to the print routine", it will be "branch to the location 227015ED42AB12F2 or whatever. You'll have to remember what that location does. Again, overwhelming your neural net. You'll have to "reverse assemble" what's happening to make sense of it. Very hard.

That said, you have a few options that don't do exactly what you want.

1) Get a debugger, run your program under the debugger. They usually show machine code/assembly (they use the C symbols like an assembler would). This will show some info, but remember that even a simple program can be millions, maybe billions of instructions. By the time you get to machine code, the source code has been compiled, optimized, and linked with system libs. This will be hard.

2) Look for simulators. These will show a subset of code and run slower, something you can keep up with. I had a C64 and an Atari 800, and played with Apples, so the Virtual 6502 seems fun to me.

Id also suggest, if you want to see the algorithms, seeing source code run, not machine code, is probably the level you want to try.

share|improve this answer
    
Of course I don't want to watch it in real time, reading a log would be the only sensible thing. Thanks for the info! –  ioSamurai Sep 14 '12 at 18:14
    
@libertas 1) a log would be huge, even for a minute you'd have 180 billion (3GHz * 60) rows 2) You'd have to dump full register state every instruction. say even 100bytes of data a row, and you'd have Terabytes of logs per minute. –  Rich Homolka Sep 14 '12 at 19:15
    
You may be able to get somewhere with an x86 emulator (NOT virtualizer) such as Bochs. I don't know if you can get a live real-time log or view of the CPU and emulation but there's quite a few tools for it. Of course you may not be able to run modern versions of Windows but I've successfully ran DOS/Windows 3.1 on Bochs before and the architecture is backwards compatible. –  ultrasawblade Sep 14 '12 at 19:37
    
@RichHomolka True! Fun to think about either way. –  ioSamurai Sep 14 '12 at 19:38
add comment

You can step through an individual program with debugger, one instruction at a time, examining register contents, but it won't be meaningful unless it's a program you wrote or understand pretty well. To watch everything a machine is doing, you need two machines, one running a kernel debugger against the other. But that also is unlikely to be meaningful or even practical for most users.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.