Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic Code Tidier MkII

Status
Not open for further replies.

Pommie

Well-Known Member
Most Helpful Member
I wrote this a while ago. It takes code that has had all formatting removed and turns it into nicely tabulated code.

It turns this,

Reset ORG 0x000 ; processor reset vector
nop
goto main ; go to beginning of program
ISR ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move STATUS register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,W ; move PCLATH register into W register
movwf pclath_temp ; save off contents of PCLATH register


Into,
Code:
Reset		ORG     0x000             ; processor reset vector
   		nop
		goto    main              ; go to beginning of program
ISR		ORG     0x004             ; interrupt vector location
		movwf   w_temp            ; save off current W register contents
		movf	STATUS,w          ; move STATUS register into W register
		movwf	status_temp       ; save off contents of STATUS register
		movf	PCLATH,W	  ; move PCLATH register into W register
		movwf	pclath_temp       ; save off contents of PCLATH register


For it to differentiate between opcodes and labels it uses a file called Codes.csv but this can be overridden by a command line switch. Operation is pretty obvious except for the Auto button. Auto copies code from the clipboard, tidies it up and places it back on the clipboard.

Command line switches are,
/F"Filename.csv" = new opcode file
/T = use tabs
/S = use spaces
/A = auto
/L = make opcodes lower case
/U = make opcodes upper case
/N = make narrow - uses less horizontal space.

To use the switches, make a shortcut to the executable and add the switches to it. (ex "C:\Projects\CodeTidy.exe" /f"Z80.csv" /t)

The opcode file override is so you can have a version for other processors.

If the /a command line switch is used then you won't see anything. It will run, tidy any code on the clipboard and exit.

The zip file contains a setup program. If you installed the earlier version then it is best to uninstall it first via control panel before installing the new one.

Please check further down this thread as if there is a bug in this code I will not be able to edit this post due to the 15 minute edit timer.

Mike.

The other thread had gotten long and convoluted so I started this new one. If a mod wants to delete the old one it would prevent future confusion.
 
Last edited:
And here for Eric and anyone else that is interested are the source files. Be warned, as I wrote this for myself and don't intend to maintain it, there are no comments. However, it should be fairly easy to follow for anyone with reasonable VB experience.

Eric, the tab sizes are now constants at the top of the file. The nTab constants are the reduced width ones. If you make them values that are not multiples of 8 then the formatting is strange.

Mike.
 
Last edited:
Mike excellent work.I haven't see such a thing in any other forums.

For sure this must placed in the "sticky" on this microcontroller section.

Can we edit the copied code from your software using tabs? I mean when I use tabs it must move the tabs instead of moving to top option & command buttons.Oh no this is more than enough.

Wow great job.
 
Last edited:
Gayan,

If you want to put additional tabs into the tidied code you have to use Ctrl-Tab. One thing I should have done was to tidy up the tab order.

Mike.
 
Last edited:
And here for Eric and anyone else that is interested are the source files. Be warned, as I wrote this for myself and don't intend to maintain it, there are no comments. However, it should be fairly easy to follow for anyone with reasonable VB experience.

Eric, the tab sizes are now constants at the top of the file. The nTab constants are the reduced width ones. If you make them values that are not multiples of 8 then the formatting is strange.

Mike.
hi Mike,
Many thanks.
Pleased to see the 'dodgy digit' aka 'as the fickle finger of fate' hasn't slowed you down.!;)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top