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.

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. For it to decide what are valid opcodes 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.

The command line switches are,
/f"Filename.csv" = new opcode file
/t = use tabs
/s = use spaces
/a = auto

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 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, do it's job and exit.

The zip file contains a setup program. If anyone just wants the exe then just ask.

Have fun.

Mike.
It won't let me post an attachment at the moment so I'll try again later.
 
Where did the edit button go?

Anyway, I put the file here. Unzip it into a folder and run setup.

Mike.
Edit, I have an edit button on this post but not the first!!
 
Last edited:
Where did the edit button go?

Anyway, I put the file here. Unzip it into a folder and run setup.

Mike.
Edit, I have an edit button on this post but not the first!!

Hi Mike,
You cannot EDIT after 15 minutes since posting.!

I'll try the formatter, I have a program listing that got trashed yesterday.

Downloaded, took nearly 5 minutes!, its modem speeds.
 
Last edited:
hi Mike,

It reformated that PIC source file a treat...:)
Didn't need to play with the switches.

Many thanks.

Regards
 
Here's the source. Be warned, as I wrote it 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.

Just noticed the zip size. Only Microsoft could take 2.9k of source and turn it into 1.3M of code. :rolleyes:

Have fun.

Mike.
 
Last edited:
I like the graphics, especially the auto button. A smaller version of the auto button would make a nice icon for it.

The way I use it, I never actually see the form. I have it as a button on my office toolbar that's set to auto (/a). I copy code from this board, hit the tidy button and paste straight to PFE. The other thing I use it for is to tidy the Microchip template files, whoever thought that 5 was a good tab size wants shooting.

Mike.
 
I was thinking about that like making it a toolbar and have it optional to make large or small buttons... I might also make a miniture version called Tiny Tidy... The trick here is all you have to do is drag and drop and it tidys and saves auto.
 
Here's a newer version with the ability to set the case of the opcodes.

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

It is best to uninstall the old verion first via control panel before installing the new one. Alternatively, just download the exe and replace it in program files/codetidy.

AtomSoft, I stole your Auto graphic to use as an Icon. Hope you don't mind.

Mike.
 
Last edited:
G'day Mike,
Hope you feeling a little better.:)

I have found a little bug in the latest tidier.
Its setting the label names for the EQU's to lower case in the declarations
but not in the body of the program.
So I am getting case sensitive errors during assembly.

Regards

Code:
;frag from declerations
		r4l	EQU 0x28
		r4h	EQU 0x29
		r5l	EQU 0x2A
		r5h	EQU 0x2B
		w_temp	EQU 0x7F
		status_temp EQU 0x7E

;frag from prog
		swapf	STATUS_TEMP,W
		movwf	STATUS
		swapf	W_TEMP,F
		swapf	W_TEMP,W
		retfie

		movlw	0x14
		movwf	R4L
		call	X001
 
Hi Eric,

I made the assumption that anything that was not at position 1 was an opcode. I forgot things like cblock can have labels in the opcode position. Silly assumption, I'll go fix it.

Mike.
Edit, done in the 15 min window.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top