Loading video...

Video Failed to Load

Go Home

🧵1/2 MIT's Charles Leiserson lectures on how C code is compiled into assembly and machine code, leading to hardware-level execution. 👇 Full MIT Performance Engineering of Software Systems Course in C and Assembly👇

56,241 views • 1 year ago •via X (Twitter)

5 Comments

tetsuo.ai's profile picture
tetsuo.ai1 year ago

🧵2/2 Full yt video playlist: Performance Engineering of Software Systems is an 18-unit class where everything is done in the C programming language, and it also covers assembly:

Zeb's profile picture
Zeb1 year ago

This course is one of the best resource if someone wants to learn how to write high performance software.... thumbs up 👍

Rishi's profile picture
Rishi1 year ago

what is "just enough assembly" you need to know to watch these videos

Hovercar Mechanic's profile picture
Hovercar Mechanic1 year ago

This is so outdated

Siraj Florida's profile picture
Siraj Florida1 year ago

The AF (Adjust Flag) in the RFLAGS (or EFLAGS in 32-bit mode, FLAGS in 16-bit mode) register is a bit that indicates whether an arithmetic operation (typically addition or subtraction) has resulted in a carry or borrow between the lower four bits (nibble) of the result. Function of the Adjust Flag: Carry/borrow between bits 3 and 4: The AF is set (AF = 1) if there is a carry out of or a borrow into bit 3 (the low nibble) during an arithmetic operation, such as addition or subtraction. If no carry or borrow occurs, AF is cleared (AF = 0). Usage of the Adjust Flag: Binary Coded Decimal (BCD) operations: The Adjust Flag is primarily used in Binary-Coded Decimal (BCD) arithmetic, where each nibble represents a decimal digit. This type of arithmetic was more common in earlier computing systems, but it still exists for compatibility and specific use cases. The AF helps manage carry/borrow between digits in BCD operations, ensuring correct decimal results.For example:If you're adding two 4-bit numbers (nibbles) and the sum exceeds 9 (as the result would no longer be valid as a BCD digit), the AF will be set. This helps signal that an adjustment is needed to correct the result to stay within the bounds of valid BCD values (0–9). Example of AF behavior in binary addition: Suppose we are adding two 8-bit values: 0x19 + binary: 00011001 + 00001001 = 00100010 Here, there is no carry from the 4th bit (bit 3) to the 5th bit (bit 4), so AF = 0. Now suppose we add 0x19 + binary: 00011001 + 00001000 = 00010001 (carry occurs from the lower nibble) In this case, a carry occurs between the 4th bit (bit 3) and the 5th bit (bit 4), so AF = 1. Key Points: AF is used internally in the CPU for specialized cases like BCD correction but is not as commonly encountered in modern programming as other flags like CF (Carry Flag) or ZF (Zero Flag). The AF is checked after certain instructions that modify the flags, such as the ADD, SUB, and ADC (add with carry) instructions.

Related Videos