Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 5th June 2008, 03:29 AM   (permalink)
Default Pic Code Tidier MkII

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 by Pommie; 6th July 2008 at 04:12 PM.
Pommie is offline   Reply With Quote
Old 5th June 2008, 03:34 AM   (permalink)
Default

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 by Pommie; 6th July 2008 at 03:27 PM.
Pommie is offline   Reply With Quote
Old 5th June 2008, 04:00 AM   (permalink)
Default

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.
__________________
Gayan

My Website
http://gsmicro.blogspot.com/

Last edited by Gayan Soyza; 5th June 2008 at 04:12 AM.
Gayan Soyza is offline   Reply With Quote
Old 5th June 2008, 04:39 AM   (permalink)
Default

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 by Pommie; 5th June 2008 at 04:40 AM.
Pommie is offline   Reply With Quote
Old 5th June 2008, 04:42 AM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
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.
Oh ya thats what I need thanks for that
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline   Reply With Quote
Old 5th June 2008, 06:54 AM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
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.!
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Pic code tidier. Pommie Micro Controllers 14 28th May 2008 07:09 AM
Need assembly code or other source code of a "Miniature digital pin number lock"... chunei Micro Controllers 1 13th August 2007 05:45 PM
code help emaney Micro Controllers 6 26th June 2007 12:56 AM
help with a code jijita Micro Controllers 1 16th August 2004 08:17 AM
some testing code.... of code of 89C51 for LCD kumar_3k Electronic Projects Design/Ideas/Reviews 0 5th November 2003 05:23 PM



All times are GMT. The time now is 09:48 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.