Code Blocks

Thread Starter

joeyd999

Joined Jun 6, 2011
5,285
Am I doing something wrong? Why are tabs in code blocks now being converted to spaces? The result is no better than if I didn't use code blocks at all. For instance, code I just posted on another thread:

Code:
txdata    lfsr    0,array            ;point to array of data

    movlw    low (-bytecount)    ;load number of bytes to send
    movwf    bytectr
    movlw    high (-bytecount)
    movwf    bytectr+1

dobyte    movlw    4        ;send 4 doublets per byte 
    movwf    dblctr

dublet    rlncf    indf0,f        ;simultaneously shift bytes,
    rlncf    indf0,f        ;   and multiply least 2 by 4 for jump

    movf    indf0,w        ;bits 2 & 3 are important
    andlw    b'1100'        ;mask them
    addwf    pcl,f        ;and use as index into jump table

c00    movlw    b'00001000'    ;code for doublet '00'
    bra    load

c01    movlw    b'00001111'    ;code for doublet '01'
    bra    load

c10    movlw    b'11101000'    ;code for doublet '10'
    bra    load

c11    movlw    b'11101111'    ;code for doublet '11'
    bra    load

load    btfss    pir1,txif    ;txreg empty?
    bra    load        ;  no, wait

    movwf    txreg        ;yes, send new code

    decfsz    dblctr,f    ;all doublets done?
    bra    dublet        ;no, do more

    movf    postinc0,f    ;point to next byte

    incfsz    bytectr,f    ;do for all bytes
    bra    dobyte
    incfsz    bytectr+1,f
    bra    dobyte

    return            ;done.
There were tabs, now they're spaces!
 

Thread Starter

joeyd999

Joined Jun 6, 2011
5,285
I'm gonna try something different here:

Code:
txdata	lfsr	0,array			;point to array of data

	movlw	low (-bytecount)	;load number of bytes to send
	movwf	bytectr
	movlw	high (-bytecount)
	movwf	bytectr+1

dobyte	movlw	4		;send 4 doublets per byte 
	movwf	dblctr

dublet	rlncf	indf0,f		;simultaneously shift bytes,
	rlncf	indf0,f		;   and multiply least 2 by 4 for jump

	movf	indf0,w		;bits 2 & 3 are important
	andlw	b'1100'		;mask them
	addwf	pcl,f		;and use as index into jump table

c00	movlw	b'00001000'	;code for doublet '00'
	bra	load

c01	movlw	b'00001111'	;code for doublet '01'
	bra	load

c10	movlw	b'11101000'	;code for doublet '10'
	bra	load

c11	movlw	b'11101111'	;code for doublet '11'
	bra	load

load	btfss	pir1,txif	;txreg empty?
	bra	load		;  no, wait

	movwf	txreg		;yes, send new code

	decfsz	dblctr,f	;all doublets done?
	bra	dublet		;no, do more

	movf	postinc0,f	;point to next byte

	incfsz	bytectr,f	;do for all bytes
	bra	dobyte
	incfsz	bytectr+1,f
	bra	dobyte

	return			;done.
 

Thread Starter

joeyd999

Joined Jun 6, 2011
5,285
Aha!

If you use the BB Code Editor, it keeps the tabs, *but* only if you don't click the More Options... button to preview your work.

This is a major bug, I think. Please fix it.
 

Wendy

Joined Mar 24, 2008
23,429
Good to know. Thanks for passing it on.

I suspect this is a fundamental bug, one the authors of the site software has to fix.
 

jpanhalt

Joined Jan 18, 2008
11,087
Posting code does appear to be a little messed up. Years ago, Pommie posted a little application called CodeTidy on ETO and AAC and perhaps some other sites as well. It gives the choice of inserting spaces or tabs. I usually uses "spaces" both with CideTidy and MPLab. Anyway, it has worked for me. I tried it this morning and here is what it did in testing:
upload_2015-1-3_6-17-5.png

I can assure you that I double checked where my code tags were, and the close tag was after the "done", but yet those five lines of code were not included in the preview. I didn't try posting to see what would happen.

On a second and related item, I searched for CodeTidy and variations of that by Pommie and found no posts here. Here is a link to his application on ETO: http://www.electro-tech-online.com/threads/pic-code-tidier-mkii.39820/#post-317307 My version was first downloaded/installed on 5/22/08, so it may be that MarkII version; although, "MkII" does not appear in its name.

Maybe if Pommie sees this, he will re-post it on AAC.

Regards, John
 

WBahn

Joined Mar 31, 2012
30,072
I've also found that the editor is very poor in several regards. With the VB code I could copy something from a text file and paste it between CODE tags and the result was pretty predictable and satisfactory. Not even close here. I, too, have found that previewing something can mess things up and so I end up having to post it and then edit it and that is both inefficient and also exposes posts to being viewed by others before I am ready to have them seen.
 
Top