cycle counting with vamos
Here is a simple bash script to get the cycle count for instructions in vamos:
Code:
#!/bin/bash
[ "$1" != "" ] && cpu=-C$1
case $1 in
20)
rts=10
;;
*)
rts=16
;;
esac
readarray -t f < asm
for i in "${!f[@]}"; do
line="${f[$i]}"
echo " $line" >x.s
echo " rts" >>x.s
/opt/amiga/bin/m68k-amigaos-gcc x.s -o x -nostdlib
r=$(vamos -v $cpu x |& grep cycles)
r=${r#*cycles:}
r=$[r - $rts]
echo "$line = $r"
done
now put the statments into the file `asm` and run the script. Sample `asm`file:
Code:
add.l d0,d0
lsl.l #2,d0
move.b d0,(a0)
move.w d0,(a0)
move.l d0,(a0)
move.l d0,(a0)+
move.l d0,-(a0)
move.l (a0)+,d0
move.l -(a0),d0
move.l d0,(2,a0)
move.l d0,(2,a0,d0)
move.l (a0),(a0)
move.l (2,a0),(2,a0)
move.l (2,a0,d0),(2,a0,d0)
move.l 0x10000,d0
move.l d0,0x10000
mulu #0x2,d0
mulu #0x3,d0
mulu #0x101,d0
muls #0x5555,d0
lea (a5,a5.l),a1
and my output based on my vamos fork:
Code:
add.l d0,d0 = 6
lsl.l #2,d0 = 12
move.b d0,(a0) = 8
move.w d0,(a0) = 8
move.l d0,(a0) = 12
move.l d0,(a0)+ = 12
move.l d0,-(a0) = 12
move.l (a0)+,d0 = 12
move.l -(a0),d0 = 14
move.l d0,(2,a0) = 16
move.l d0,(2,a0,d0) = 18
move.l (a0),(a0) = 20
move.l (2,a0),(2,a0) = 28
move.l (2,a0,d0),(2,a0,d0) = 32
move.l 0x10000,d0 = 20
move.l d0,0x10000 = 20
mulu #0x2,d0 = 44
mulu #0x3,d0 = 46
mulu #0x101,d0 = 46
muls #0x5555,d0 = 72
lea (a5,a5.l),a1 = 12
|