English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 01 May 2023, 11:17   #1
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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

Last edited by bebbo; 01 May 2023 at 13:34.
bebbo is offline  
Old 01 May 2023, 12:09   #2
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,176
Interesting! Does it estimate best/worse cases for 68020+ or is it just for 68000 ?
Karlos is online now  
Old 01 May 2023, 13:34   #3
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
I updated the script to support the parameter "20" for 68020. Output is then
Code:
add.l   d0,d0 = 2
lsl.l   #2,d0 = 4
move.b  d0,(a0) = 4
move.w  d0,(a0) = 4
move.l  d0,(a0) = 4
move.l  d0,(a0)+ = 4
move.l  d0,-(a0) = 5
move.l  (a0)+,d0 = 6
move.l  -(a0),d0 = 7
move.l  d0,(2,a0) = 5
move.l  d0,(2,a0,d0) = 7
move.l  (a0),(a0) = 8
move.l  (2,a0),(2,a0) = 10
move.l  (2,a0,d0),(2,a0,d0) = 14
move.l  0x10000,d0 = 6
move.l  d0,0x10000 = 6
mulu    #0x2,d0 = 29
mulu    #0x3,d0 = 29
mulu    #0x101,d0 = 29
muls    #0x5555,d0 = 29
lea (a5,a5.l),a1 = 9
(fixed lsl for 020 too)

Last edited by bebbo; 01 May 2023 at 13:54.
bebbo is offline  
Old 01 May 2023, 14:03   #4
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,176
So does it just count cycles for each instruction or does it also take into consideration pipelining across a sequence of instructions?
Karlos is online now  
Old 01 May 2023, 16:01   #5
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by Karlos View Post
So does it just count cycles for each instruction or does it also take into consideration pipelining across a sequence of instructions?
As far as I can see, the script invokes the compiler and vamos separately for each line/instruction in the "asm" file.
hooverphonique is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Zorro slots Wrangler Coders. System 8 17 September 2022 12:06
[ARexx] Error while counting icons (bug?) mateusz_s Coders. Scripting 3 14 September 2021 11:14
Running AmigaOS 3.1.4 shell on vamos palaste support.Other 6 26 November 2020 11:19
Amitools / vamos project copse Coders. General 4 01 January 2014 20:59

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:37.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07226 seconds with 15 queries