09 April 2021, 15:36 | #1 |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
68kcounter - ASM cycle and size calculator
I've built a tool to calculate cycle and size information from 68k ASM source. Currently it's available as a web app and an NPM package with CLI tool. Eventually I'd like to make a VSCode extension for editor integration. I'm pretty new to ASM and I've based the implementation on the available documentation as far as possible. I'd be interested to see:
|
09 April 2021, 16:22 | #2 |
Registered User
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 171
|
nice tool, would be cool to have sum of all cycles (also without selecting a range)
|
09 April 2021, 16:26 | #3 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,411
|
That's pretty cool. I'll be sure to check it out!
|
09 April 2021, 16:33 | #4 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
Thanks! I initially included that but I disabled it as I thought it was a bit confusing. I was thinking that total cycles across a whole file doesn't really make sense due to branching, loops etc. and I imagined it would only be useful for continuous blocks of instructions. I'll put it back if it's useful. |
|
09 April 2021, 22:04 | #5 | |
German Translator
Join Date: Aug 2018
Location: Drübeck / Germany
Age: 49
Posts: 183
|
WinUAE Debugger can calculate the cycle and bus usage.
Code:
start: move.w #$4000,$dff09a ; Interrupts disable waitmouse: btst #6,$bfe001 ; left mousebutton? bne.s Waitmouse lea Table,a0 ; 12 cycles move.w #1200-1,d7 ; 8 cycles CleaLoop: clr.b (a0)+ ; 12 cycles dbne d7,CleaLoop ; 10 cycles (+14 false) nop move.w #$C000,$dff09a ; Interrupts enable rts Table: blk.w 1200,$FFFF end start 12+8=20 cycles , clr.b 1200 * 12 = 14400 cycles dbne 1199 * 10 = 11990 cycles, dbne (false) 14 cycles sum = 20 + 14400 + 11990 + 14 = 26424 1. first assemble the programm and run 2. programm waits now for left mousebutton 3. Shift+F12 opens the debugger 4. make d PC - shows the disassembled program 5. f adress - set breakpoint on line lea table,a0 6. x - leave debugger 7. press left mousebutton - reopens the debugger 8. fi nop (WinUAE 4.5) or fi 4E71 - step forward until nop 9. now you can see all cycles 10. x - leave the debugger 11. (with t and t number - you can step one or more instructions) Code:
>d PC 00027638 0839 0006 00bf e001 BTST.B #$0006,$00bfe001 00027640 66f6 BNE.B #$f6 == $00027638 (T) 00027642 41f9 0002 765e LEA.L $0002765e,A0 00027648 3e3c 04af MOVE.W #$04af,D7 0002764C 4218 CLR.B (A0)+ [ff] 0002764E 56cf fffc DBNE.W D7,#$fffc == $0002764c (T) 00027652 4e71 NOP 00027654 33fc c000 00df f09a MOVE.W #$c000,$00dff09a 0002765C 4e75 RTS 0002765E ffff ILLEGAL >f 27642 Breakpoint added. >x Quote:
in my opinion it would be better to rename following commands: f - f <address> Add/remove breakpoint. --> b fl - fl List breakpoints. --> bl fd - fd Remove all breakpoints. --> bd That makes more sense and the next point ist there are a lot of f - commands. |
|
09 April 2021, 23:18 | #6 |
Registered User
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 171
|
|
13 April 2021, 10:50 | #7 |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
I've now created a VS Code extension which provides live annotations on your code as you type.
|
13 April 2021, 14:29 | #8 |
Registered User
Join Date: Feb 2020
Location: Germany
Posts: 178
|
@gigabates: NICE ONE! The extension works fine with label too.
Same lines with different cycles. Last edited by JoeJoe; 13 April 2021 at 15:04. |
13 April 2021, 16:20 | #9 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,801
|
Suggestions from Twitter:
1) One idea that comes to mind, is to have the tool automatically suggest (as comments) faster alternatives, like if you type "move.l #8,d0" it would show the clock cycles that takes, but point out that "moveq" would do the same faster 2) Pushing the idea further, it would be useful for beginners to actually show the details of where the cycles come from, like fetching of the instruction, plus memory accesses, addressing mode, internal computations (like the 2n cycles for rotates or the mul/div). 3) Interesting, but to be useful to me it needs to get two improvements: - it needs to actually recognize "nop" - on the Atari ST clock cycles are rounded to multiple of 4 due to the way the bus is accessed, so this EXG would take 8 cycles instead of 6 in most situations. |
13 April 2021, 18:27 | #10 | |
Registered User
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 171
|
Quote:
http://pasti.fxatari.com/68kdocs/Ata...eCounting.html Last edited by Cyprian; 13 April 2021 at 18:44. |
|
13 April 2021, 19:31 | #11 |
AmigaMan
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 760
|
Damn! This extension seems great. It a shame I use a private asm extension and seems it is not compatible with this one.
I get this error: El comando "68kcounter: Count selection" dio lugar a un error (command '68kcounter.countSelection' not found) |
13 April 2021, 21:11 | #12 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
It should be pretty trivial to get this working with your extension. My extension gets activated based on the language of the active document. This is what it looks for in order to support a few different implementations: Code:
"onLanguage:m68k", "onLanguage:amiga-assembly-debug.disassembly", "onLanguage:as", "onLanguage:vasmmot", "onLanguage:vasmstd", "onLanguage:codewarrior" |
|
13 April 2021, 21:17 | #13 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
I was just reading up on this. It would be pretty simple to add an 'Atari mode' which follows the 'Round up to a multiple of four' rule, but it gets more complicated when it comes to the pairing/alignment stuff. Am I right in thinking there would be no way to know how the instructions align with bus cycles from the pre-assembled source? |
|
13 April 2021, 21:32 | #14 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
Thanks a lot for sharing and providing feedback. 1) I'd also thought about this and it's something I'd like to explore. To me it seems like there are two categories of suggestions. There are the ones where the result is exactly equivalent and are probably already applied by your assembler. I could probably have a look at what rules vasm follows. There are others where they might be equivalent depending on your use case e.g. whether you rely on the CCR. This sounds like it could end up like a linter tool, which would certainly make an interesting project. 2) This shouldn't be hard to do. I might give it a go. 3) Lack of NOOP support was a bug in my timing table. I've since fixed this along with a couple of others. |
|
13 April 2021, 22:04 | #15 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
Thanks! Is 'SP' a valid synonym for a7 in addition to 'SR' or is this a typo? What's happening here is that it defaults to interpreting '-(SP)' as an absolute address as it doesn't match any other known patterns. edit: Ignore me, I'm an idiot! Last edited by gigabates; 13 April 2021 at 23:08. |
|
13 April 2021, 22:24 | #16 |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 388
|
I tried this with Bartman's GCC setup and it didn't work.
I think you need to add language modes: amiga.assembly and amiga.disassembly |
13 April 2021, 22:49 | #17 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,411
|
|
13 April 2021, 22:54 | #18 | |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
Quote:
Ok it should work now. I just pushed an update that activates on amiga.disassembly (amiga.assembly didn't seem to exist), but more importantly it also activates when you run either either of the commands: '68kcounter: Toggle counts' or '68kcounter: Count selection' on any file regardless of language. This is what it should have done all along but I'm a bit of a VS Code extension n00b! |
|
13 April 2021, 23:04 | #19 |
Registered User
Join Date: Jan 2021
Location: Watford, UK
Posts: 57
|
|
13 April 2021, 23:07 | #20 |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 388
|
That works but it would be nice to have the little icon to click.
amiga.assembly must be part of Bartman's extension. I don't have any of the other ones you mentioned because I don't have those other extensions that are exclusively for assembly only. What do the different colors for your output indicate? |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
horiz. size & vert. size greyed out in some configurations | honx | support.WinUAE | 3 | 15 August 2020 21:14 |
ASM: Asm-ONE or AsmPro - how to set a Hello amiga coders, I hope it is ok to hijack ? | Fireball | Coders. Asm / Hardware | 2 | 24 April 2020 21:16 |
Hex2 - my little calculator | ALB42 | News | 0 | 11 November 2018 11:46 |
Amiga calculator | cla | Coders. Releases | 35 | 30 December 2017 15:00 |
Speccy on Ti-89 calculator | Fred the Fop | Retrogaming General Discussion | 3 | 27 January 2007 02:30 |
|
|