Casey-isms
- Everything in computers is just numbers.
- As a general theme of Handmade Hero, we want to know what the machine is doing.
- It gives us a connection to the computer and is not that much more slower or complicated.
OutputDebugStringA() vs OutputDebugStringW()
- What does the A stand for?
- Windows used to work only with standard ASCII strings (or ANSI?)
- But the ASCII system didn't work for languages like Chinese, so Unicode became the standard, so Windows had to expand
- So Windows started using wide character strings called UTF-16
Debugging & the Breakpoint
- You set a "breakpoint" and run code, but when program reaches this point, it stops!
- It will freeze everything, the memory, variables, etc so i can look at it
- Press F9 in VS to set a breakpoint
- Breakpoint freezes RIGHT before the line that executes
- Step Into and Step Over
- Step Over, F10, do whatever's on the current line
- Step Into, not covered just yet
- Useful Debug Windows
- Watch: type in the name of something we want to see and show up corresponding value
- Registers: to see the assembly language CPU operates on
Assembly
- Appears to read right to left!
- This is important, BECAUSE WE ALWAYS WANT TO KNOW WHAT IS HAPPENING ON THE MACHINE
- In VS, Right click and select goto disassembly
- For debugging, bring up registers. you can right click and display in hexadecimal
(location in memory) (register mnemonic) (moves FF in code into byte pointer )
- By watching the registers, we know this is a memory to memory move and does not reach the registers)
- Hexadecimal notations
- VS will translate it for you if you hover over hex
- 0FFh : Assembly Notation
- 0xFF (0xcc) : C notation
- Even though EAX can hold 0000 0000, we can reference smaller parts of a register. we can pull out the bottom 8 bits...
- This is what "al" (references to EAX to pull only a byte) does!