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,393 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

** Sega Genesis 3D Engine Day 3 ** Blast Processing kicks In !! Converted the Line Drawing and Triangle drawing to 68k Assembly and gained 25% in the line drawing and 33% speedups in the triangle drawing vs C ( so far ) . The scheduler calculating the vertexs is still in C , just the drawing routines are now are in assembly . Possibly 5-10 % gains will come from the scheduler being in ASM also. The Line and Triangle drawing C code took some beating , it was surprising - particularly the line drawing to get a speed up over the C code in ASM. I guess its not too surprising as the C code was basically handling pointers and integers so I had to get exotic to find the speedups. Initially my ASM Line draw was 100% slower than the C code - the first pass conversion from C to ASM is always rough as its more about getting it working then refine later , but yeah 100% slower on first pass was brutal, after 4 hrs tweaking it was 25% faster than the C code so thats a good start - might get more yet. So added more squares and more triangles for load testing at the same frame rate. Its still not anything cohesive but right now focussing on performance in rendering to see how much can be pushed. As rendering will be the biggest cpu soak the faster that goes the better. The smaller triangles take about 1/3 the CPU time of the larger triangles at present so theres definately a fill rate limit vs the setup time to consider. The same would go for the squares been line framed - smaller ones would allow al lot more . #SGDK #SegaGenesis #SegaMegadrive

Shannon Birt

21,306 views • 5 months ago