-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend some explanations #98
Comments
The part titled "Printing to Screen" also goes very quickly. The code fragments could use some more context: which file does it go in, is it top-level or inside a type? (E.g., the text doesn't state that write_str should be inside the Writer type definition.) Using Unique and sping also require changes to the crate attributes and Cargo.toml. The text could use some clarification there as well. |
Section "Printing Strings" talks about adding I suspect this part assumes more Rust knowledge than I have here on day 3 of my journey. :-) |
Thanks a lot! I'll try to clarify these things. |
I was going through the CPUID check myself to try to understand what was going on, and here's the version I ended up with, with some different comments: check_cpuid:
; Check if CPUID is supported by attempting to flip the ID bit (bit 21) in
; the FLAGS register. If we can flip it, CPUID is available.
; Copy FLAGS in to EAX via stack
pushfd
pop eax
; Copy to ECX as well for comparing later on
mov ecx, eax
; Flip the ID bit
xor eax, 1 << 21
; Copy EAX to FLAGS via the stack
push eax
popfd
; Copy FLAGS back to EAX (with the flipped bit if CPUID is supported)
pushfd
pop eax
; Restore FLAGS from the old version stored in ECX (i.e. flipping the ID bit
; back if it was ever flipped).
push ecx
popfd
; Compare EAX and ECX. If they are equal then that means the bit wasn't
; flipped, and CPUID isn't supported.
xor eax, ecx
jz .no_cpuid
ret
.no_cpuid:
mov al, "1"
jmp error |
@henrikhodne I had to do something similar. The comments in the original code didn't explain why the operations were being done that way. |
@henrikhodne This is very useful! Mind if I include it in the tutorial? I think you should also update the page in the OSDev Wiki. Your comments are way better! |
Not at all, go ahead. And I'll see if I can update the wiki page too. |
Some issues that were brought up by rylev on IRC:
cmp
andjmp
Update: below @mtnygard mentioned some issues with Printing to Screen:
impl
method?)lib.rs
andCargo.toml
changes required forUnique
andspin
write_str
The text was updated successfully, but these errors were encountered: