Quantcast
Channel: The Old New Thing
Browsing all 3085 articles
Browse latest View live

The WMI root node is just a node in the WMI namespace

A security vulnerability report arrived that went roughly like this: There is a serious zero-day security vulnerability in the WMIC.EXE program. It does not check whether the user has administrative...

View Article


When I memcpy a struct into a std::atomic of that struct, why does the result...

Consider the following code: // Code in italics is wrong. struct Point3D { float x, y, z; }; std::atomic<Point3D> currentPoint; bool LoadCurrentPointFromFile(HANDLE file) { DWORD...

View Article


What’s up with compare_exchange_weak anyway?

Last time, I left you with a homework assignment: Watch this video on std::atomic. At time code 33:03, the presenter notes the weak version of compare-exchange (which is permitted to fail even if the...

View Article

Geology throwdown: The whisper of the rocks

The Proceedings of the National Academy of Sciences is a serious scientific journal, whose published papers undergo rigorous peer review. This week's issue shows that this doesn't mean that the titles...

View Article

How do I choose between the strong and weak versions of compare-exchange?

Last time, we left with the question of when you should prefer the strong version of compare-exchange as opposed to the weak version. It comes down to whether spurious failures are acceptable and how...

View Article


Why is it cheaper to fly out of Vancouver for spring break instead of...

Some relatives from Vancouver, British Columbia came to visit, and we mentioned that when we fly out on vacation for spring break, we found that the airplane tickets are much cheaper if we drive up to...

View Article

The MIPS R4000, part 1: Introduction

Continuing in the "Raymond introduces you to a CPU architecture that Windows once supported but no longer does" sort-of series, here we go with the MIPS R4000. The MIPS R4000 implements the MIPS III...

View Article

The MIPS R4000, part 2: 32-bit integer calculations

The MIPS R4000 has the usual collection of arithmetic operations, but the mnemonics are confusingly-named. The general notation for arithmetic operations is OP destination, source1, source2 with the...

View Article


The MIPS R4000, part 3: Multiplication, division, and the temperamental HI...

The MIPS R4000 can perform multipliction and division in hardware, but it does so in an unusual way, and this is where the temperamental HI and LO registers enter the picture. The HI and LO registers...

View Article


The MIPS R4000, part 4: Constants

Since the MIPS R4000 has a fixed 32-bit instruction size, it cannot have a generalized "load 32-bit immediate constant" instruction. (There would be no room in the instruction for the opcode!) If you...

View Article

The MIPS R4000, part 5: Memory access (aligned)

The MIPS R4000 has one addressing mode: Register indirect with displacement. LW rd, disp16(rs) ; rd = *( int32_t*)(rs + disp16) LH rd, disp16(rs) ; rd = *( int16_t*)(rs + disp16) LHU rd, disp16(rs) ;...

View Article

The MIPS R4000, part 6: Memory access (unaligned)

Unaligned memory access on the MIPS R4000 is performed with pairs of instructions. LWL rd, n+3(rs) ; load word left LWR rd, n(rs) ; load word right This is easier to explain with a diagram rather than...

View Article

The MIPS R4000, part 7: Memory access (atomic)

Atomic memory access on the MIPS R4000 is performed with the load-linked and store-conditional instructions. This pattern shouldn't be much of a surprise because we already encountered it on the Alpha...

View Article


The MIPS R4000, part 8: Control transfer

Let's just get this out of the way. The MIPS R4000 has branch delay slots. Ugh. When you perform a branch instruction, the instruction after the branch instruction is executed, even if the branch is...

View Article

The MIPS R4000, part 9: Stupid branch delay slot tricks

Last time, we learned about the MIPS branch delay slot. Today, we'll look at some tricks you can play with the branch delay slot. First trick: It is legal to jump into a branch delay slot. Of course,...

View Article


The MIPS R4000, part 10: Trampolines and stubs

We saw earlier that the relative branch instructions have a reach of ±128KB, but what if the function you want to call is further away than that? The linker detects that the branch target is too far...

View Article

The MIPS R4000, part 11: More on branch delay slots

There seems to be a lot of confusion over branch delay slots. Instead of addressing each comment, I'll just make a post out of it. The branch delay slot is a dynamic concept. An instruction is in a...

View Article


The MIPS R4000, part 12: Calling convention

The Windows NT calling convention for the MIPS R4000 is similar to the other major MIPS calling conventions, but calling conventions for the MIPS are like snowflakes: Despite being made of the same...

View Article

Whoa, that fitness tracker is a really expensive watch

My mom saw that her friend was wearing a new watch. Her friend said, "It also counts how many steps I took today, keeps track of my exercise, even monitors my sleep." My mom replied, "I used to have a...

View Article

The MIPS R4000, part 13: Function prologues and epilogues

We saw last time how functions are called. Today we'll look at the receiving end of a function call. As noted earlier, all functions (except for lightweight leaf functions) must declare unwind codes...

View Article
Browsing all 3085 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>