last day (27 days later) » 

10:06 PM
9
A: Why do x86 FP compares set CF like unsigned integers, instead of using signed conditions?

Peter CordesModern x86 SSE/AVX scalar FP compares set EFLAGS the same way as original 8086 + 8087 fcom + fstsw ax 1 + sahf. fcom since 8086 fcomi new in PPro, sets EFLAGS directly [u]comis[sd] new in SSE/SSE2, also sets EFLAGS directly. After ruling out "unordered", the "above" (>), "below" (<), and "equ...

 
@St.Antario: yes, "above" and "below", and "equal" all have the expected semantic meaning after an FP compare, just no implication of unsigned.
@InstructionPointer : thanks for the edits. I don't always take the time to go back and proof-read the whole answer so I do sometimes end up with a stray phrase or broken grammar from moving stuff around or rephrasing during editing.
 
@PeterCordes I have discovered "submitting edits" as a very useful part of my learning process. I do not think I am a naturally intelligent person, I have to see the same information restated and shown in a variety of ways before I really internalize it, editing just helps me do that. Plus I imagine I improve the overall quality of the site for future learners.
 
@InstructionPointer: yeah, most of your edits look good. Just be careful not to introduce mistakes with stuff you're not sure about / are still learning. You didn't here, it was just wording, but some of your other edits have had mistakes. The way reviews for suggested edits work, the people approving them often don't know anything about the language. This works for formatting / English edits, but some people just click approve and just assume that any technical changes are correct. (Stack Overflow does allow reviewers to filter on some tags, but not everyone does that.)
 
You're right, I learned the hard way with a particularly embarrassing edit(regarding an assembly syntax question), I will be sure not to make that mistake again. I'm still learning a lot about this site, for example, on Aug 11th (after the 30 day time limit) I'll change this username to my real name, I didn't know that was apropos.
 
@InstructionPointer: lots of people use aliases; real name vs. a fun alias as your username is totally up to you. But anyway, welcome to Stack Overflow, glad to have more people around that are interested in making it a valuable collection of information, not just getting an answer to yet another variation on a common question.
 
10:06 PM
@PeterCordes Thx! In my current position I have a teacher's schedule/calendar so lots of time to improve the world one tiny bit at a time and improve myself along the way :)
 
@InstructionPointer I removed my chat comments from the original answer; they're not relevant to anyone else.
 
sounds good I've never used this chat feature before but what a great idea this is! Regarding the edits, I once spent a year teaching language arts at a middle school so I can't promise any improvements higher than an 8th grade level lol
Can I ask, how did you get so great with these low level concepts? Do you have a particular learning strategy? Was it just years of study, or maybe a particular position you held or a combination of all these?
 
10:33 PM
@InstructionPointer When I was a teen, I was interested in electronics, and built some digital-logic hobby projects. (Like a speed-trap for an electric race-car set with LED / photo-diodes and some TTL counter chips and 7-segment LED displays). And I've always liked understanding how/why things worked, especially physics. I don't still design or build electronics, but I still understand the physics.
I've also been interested in CPU architecture for a long time. Even when I mostly did sys-admin stuff instead of low-level programming, I liked to read about new CPU designs and how they worked.
 
My original major was physics, then I dropped out and when I went back it was economics. Now I teach networking, programming, and computer information system class for a community college. As you can tell I'm a little all over the place but learning is the real point, and the fun.
 
@InstructionPointer The first programming language I really learned was C. I had a Mandelbrot program from a paper magazine (had to type in the source by hand!) which I played around with some on my Atari STe.
My dad already had a unix-like text shell and gcc installed on it, but gcc on a 16MHz m68k took a long time to compile. After a few edit/compile/benchmark cycles trying to speed up the program, I started looking at the asm the compiler was making and basically taught myself asm from some m68k books my dad had.
I knew in theory that computers worked by running 1 instruction at a time, so I never found it hard to grok the fact that C compilers just make asm that implements the program logic.
 
16MHz... wow.
 
Yeah, and we had a hard drive for our Atari Mega 4 STe. Like a 20 or 80MB hard drive! So much better than floppies :P
IIRC, standard Atari ST desktops were 8MHz 68000, vs. Mega STe with 16MHz 68020.
 
I'm learning more C than I want right now, just in my pursuit to better understand asm and the general low level. I'm on page 161 of the intel developers manual and I'm just tackling anything I find that is unfamiliar. Sometimes I'll spend days on just a single sentence... finding Godbolt recently has REALLY REALLY helped my process.
80MB, and I bet it was expensive?
 
10:40 PM
So anyway, I've always been good at practical applications of math and stuff like that, and I tend to think about things in terms of how they work under the hood. The C pointer / memory model basically matches asm: pointers are just numbers, not like higher level Java Object references. So I'm glad I learned C first.
@InstructionPointer Yeah probably, obviously my dad bought it so IDK.
 
I watch a you tube channel called "8 bit guy" and enjoy learning about computer history
 
@InstructionPointer Yeah I found just looking at compiler-generated code was a pretty good way to learn asm. Reading the vol.2 manual for instructions when there's any mystery is good, but I found Agner Fog's guide (optimizing asm, and especially microarch guide) more useful than Intel's other manuals. Once you grok the basic mental model of giving the appearance of executing 1 instruction at a time, you don't need Intel to spell out every last detail for normal user-space stuff.
 
yea so far pointers have been the hardest thing for me to understand... Python is my strongest language and even then I get frustrated with high level abstractions I crave to know what's really happening. Even if other ppl find the 1s and 0s boring, not me. I want to know where every electron is going.
 
Only if you want to learn how all the possible weird stuff works (like segmentation, memory regions other than WB, privilege levels, serializing instructions, etc.) do you need to get into Intel's manuals. Otherwise just assume the OS takes care of giving you a usable machine state and ignore segmentation.
 
yea as I learn I don't want to fall into traps where I spent days or weeks understanding something (like segmentation?) just to find out everyone is using something else (like a flat memory model now?) I don't know if that's total true...
 
10:46 PM
@InstructionPointer I didn't really learn about segmentation until I was already pretty good at optimizing normal 32/64-bit code with SIMD and stuff, and understood how the pipeline worked from Agner's microarch pdf. It's very much a relic and these days is only useful to keep the CPU happy and tell it whether to execute in 32 or 64-bit mode. Unless you're a masochist and want to write your own 16-bit legacy-BIOS MBR code or DOS program that runs under multiple levels of firmware emulation. (Of devices)
 
I have enjoyed reading Agner Fog's blog, he cleared up the differences between AMD and Intel for me and their petty wars, but haven't touched the optimization guide yet.
 
@InstructionPointer Yes segmentation is totally irrelevant except for OS-development (machine-mode stuff), and for thread-local storage. (Non-zero base for fs or gs). You can and should ignore segmentation until you have a solid understanding of everything else.
gtg for supper
 
I am a masochist (long distance runner) but don't think I'll be writing anything legacy related, I'm a star trek fan so I'm anxious to bring about a better future already!
ok take care, thanks for the chat
 
11:33 PM
@InstructionPointer yeah, that's my feeling about asm. The only reason I know much about 16-bit real mode crap and legacy-BIOS interrupts / DOS system calls is that people keep asking SO questions about that stuff. Apparently some schools teach assembly with emu8086 and confuse their students with segmentation. x86-style segmentation was a solution to a problem that no longer exists (addressing more memory with a 16-bit CPU).
 

  last day (27 days later) »