16.16 fixedpoint was used widely for 3d math on 68000 back in the day. I decided to revisit some code I wrote 40 years ago and see if I could improve it - shave a few cycles off. I just recall we did lots of cute tricks to re-shift the result so I (stupidly) decided to ask AI for a refresher..
Now my experience of using AI for any coding has been 100% failure so far. It produces total dogshit every time but I know there are peeps that say its good.
But this did make me laugh..
Question: 68000 assembly fixpoint 16.16 multiply
Answer:
; Assume number1 and number2 are in registers D0 and D1
; Result will be stored in D2
; Load the fixed-point numbers
MOVE.L number1, D0 ; Load first number
MOVE.L number2, D1 ; Load second number
; Perform multiplication
MULS.L D1, D0 ; D0 = D0 * D1 (64-bit result in D0:D1)
; Shift right to convert to 16.16 format
LSR.L #16, D0 ; Shift right by 16 bits
MOVE.L D0, D2 ; Store result in D2
I have ca 50-90 % failure. depends on the day.
And worse part, it didn’t learn and didn’t save.
Some pdp8 opcodes are still wrong as the page bit is not considered.
Even when explained, making the same errors soon again.
there is no such instruction to do 32bit multiply giving 64bit result.
on 68000 each bitshift costs 2 cycles, so shifting right 16 costs 32 cycles (!) - but the 68000 provides an instruction (swap) that does the same thing in 4 cycles - which everyone uses to get the top word into the bottom word.
It does seem that one needs to set up a load of tests to test what the AI did in the first place so it can correct itself…which just looks like pushing all the crappy test coding onto the human while the AI gets to do the bit that I actually enjoy doing!
The solving problems and designing things to work nicely together is ALL the enjoyment of programming for me. Why anyone would want to do the tedious job of correcting some piece of crap written by an AI is beyond me!
I did go back to the AI pointing out all its errors and and slowly it improved - but how is this more productive? Let alone cheaper once the actual cost to deliver AI starts being charged.
I have no idea of cost, but AI’s give me the software bloat feeling for this topic. I think general understanding
things on computers still has a long way to go. AI searching does not work, if the database is not there
like IMP and FRED for computers or how name a CAT for life skills.