Repository navigation
content: fix factual errors in chapters 2-7 - #97
dajiaohuang wants to merge 2 commits into
Conversation
- asm_2: name the ecx register in the compiler output comment - asm_3: pass the fourth function argument in rcx and restore rbp in the epilogue - asm_4: not takes one operand; name the lodsb instruction correctly - asm_5: use the %define directive and show the actual REPX expansion - asm_6: correct the CMPSS ordered predicate and the comparison result location - asm_7: the greeting including the newline is 14 bytes
0xAX
left a comment
There was a problem hiding this comment.
@dajiaohuang thank you for your PR! I've left two minor comments
| | 5 | >= | | ||
| | 6 | > | | ||
| | 7 | Checks that both operands are [Nan](https://en.wikipedia.org/wiki/NaN) | | ||
| | 7 | Checks that neither operand is [NaN](https://en.wikipedia.org/wiki/NaN) | |
There was a problem hiding this comment.
@dajiaohuang good catch. This table on the line 3 also has Nan, can you please update it to NaN as well
| ### Floating-point control instructions | ||
|
|
||
| As we already know, the main goal of these instructions is to manage the control flow of our programs. For integer comparisons, we used the `cmp` instruction. However, this instruction does not work with floating-point values, even though the result of the comparison is controlled by the same `rflags` registers that we saw in the [Data manipulation](./asm_4.md#control-transfer-instructions) chapter. The general instruction to compare floating-point numbers is `cmpss`. Instead of setting the value of the flag based on the result comparison, the instruction stores the result of the comparison in the destination register. | ||
| As we already know, the main goal of these instructions is to manage the control flow of our programs. For integer comparisons, we used the `cmp` instruction. However, this instruction does not work with floating-point values: unlike an integer comparison, whose result is recorded in the `rflags` register, a floating-point comparison stores its result in the destination register. The general instruction to compare floating-point numbers is `cmpss`. Instead of setting the value of the flag based on the result comparison, the instruction stores the result of the comparison in the destination register. |
There was a problem hiding this comment.
This paragraph now doubles information about the storing the result of the comparison in the destination register.
Maybe something like this:
As we already know, the main goal of these instructions is to manage the control flow of our programs. For integer comparisons, we used the
cmpinstruction from the Data manipulation chapter. However, this instruction does not work with floating-point values. To compare floating-point numbers, we can use thecmpssinstruction. Unlikecmp, this instruction does not set any flags. Instead, it stores the result of the comparison in the destination register.
Fixes several objective factual errors in the course text. All changed files are Markdown and are covered by the repository's CC BY-NC-SA 4.0 license; no example sources were modified.
Changes proposed in this pull request:
content/asm_2.md: the comment next tomov ecx, 4referred to anexcregister. It now saysecx.content/asm_3.md: the function-argument list gaver10for the fourth argument. The System V AMD64 ABI passes the fourth integer/pointer argument inrcx(the same chapter's example and chapters 2 and 7 already useecx/rcxfor function calls). Also,popwithout an operand is not a valid epilogue afterpush rbp; it now restoresrbpwithpop rbp.content/asm_4.md:nottakes one operand and inverts its bits; the "result is stored in the first operand" sentence applies toand,or, andxor. The prose also called thelodsbinstructionloadsb.content/asm_5.md: the single-line macro example saiddefine argcinstead of%define argc. TheREPXexample said it expands topmulhuw m0, m7..., but the macro and the shown invocation expand topsrlw m0, 8,psrlw m1, 8, and so on.content/asm_6.md: CMPSS predicate 7 is the ordered predicate ("neither operand is NaN"), not "both operands are NaN". The paragraph also said a floating-point comparison's result is controlled byrflags; unlike an integercmp,cmpsswrites its result to the destination register.content/asm_7.md:msgis"hello, world!\n", i.e. 14 bytes, which matchesmov rdx, 14and the comments in the other chapters.CONTRIBUTORS.md: addeddajiaohuang, as requested byCONTRIBUTING.md.Checks performed:
REPXexpansion withnasm -E(psrlw m0, 8...).-O0output (movl %ecx, -16(%rbp)for the fourth parameter).VCMPORDSS/ORD_Q).No example programs were changed, so the examples workflow is unaffected.