re: 6502, ai
I'm running an experiment to see if it can evolve an 8-bit * 8-bit = 16-bit multiplier. It seems to have evolved a solution that gets the least significant byte right at least. I'll run it for a while (I could code multithreading but I have other things to do atm).
re: 6502, ai
https://pastebin.com/3EGbMnMU if you're interested in the galaxy brain solution (arguments in $00 and $01, result in $02,$03 little-endian)
re: 6502, ai
@kiilas are you using an emulator (or a 65C02) that ties undefined opcodes to NOP, or a real 6502? because some of the undefined opcodes scattered around there will have very different effects on a real 6502... including a couple of instances of $02, which will kill the processor:
l8000:
. ldx 1,y
. sax $61B
. adc ($71,x)
. eor $D0CA
. sbc $285,y
. adc ($71,x)
. eor $D0CA
. asl $285,y
. lsr $8A,x
. dec $ABAE,x
. and $9C
. lsr a
. tas $BF58.y
. nop ; $DA
. arr #$71
l8023:
. lax ($1B,x)
. isc $4A6A,y
. adc ($19),y
. kil
. nop
. slo $6ACB,y
. beq l804A
. stx $D101
. eor $A059,y
. bit $C1
. dcp ($36),y
. ora ($36,x)
. slo ($90,x)
. nop
l8040:
. sbc #$F4
. lda #$5C
. eor $F459,y
. arr #3
. db $1C ; → nop $19CD,x; kil
l804A:
. cmp $219
. rol $01,x
. eor #$45
. pha
. rts
(opcodes as suggested by https://problemkaputt.de/pagezero.htm#cpu65xxmicroprocessor )
re: 6502, ai
@millihertz I'm using this emulation library https://github.com/redcode/6502.
I know the invalid opcodes will cause undefined behaviour/crash, but for the sake of simplicity (I don't intend to use the generated code anywhere... yet ) I'm treating them as NOPs (or whatever the emulator treats them as). I suppose I can treat it like I currently treat PC ending at 0000 ie give a ginormous penalty to the program, and maybe I'll do that next.
re: 6502, ai
@millihertz looks like the problem solved itself after running it overnight (the programs are rewarded for shortest execution time)!
* = 8000
8000 A6 01 LDX $01
8002 18 CLC
8003 65 00 ADC $00
8005 CA DEX
8006 D0 FA BNE $8002
8008 85 02 STA $02
800A 60 RTS
re: 6502, ai
Looks like its (partial) solution is "let me add X number Y times"