I asked Gemini to write a simple bit of assembly for the Game Boy.
>Register <c> contains four 2-bit bitfields. Write a subroutine that increments each bitfield, clamping to avoid overflow. The result should be left in the <a> register.
In a real-world scenario, this kind of code might be used when fading the screen to black. This can be done efficiently using only six instructions:
ld a, c
rrca
and a, c
cpl
and a, %01_01_01_01
add a, c
The AI's solution can be seen in pic related. I haven't fully checked it for correctness, but it's clearly much less efficient. On the bright side, it's much better than what I was getting a couple of years ago. The syntax is correct, and it's not making up instructions that don't exist. It even noticed that the additions can be done in parallel-- something that a lot of real programmers miss. Not bad for such an obscure use-case, but it's still far away from being any good.