PDA

View Full Version : Wrapping code



Christopher4187
- 19th February 2014, 20:07
If I have a line of code that's 150 characters long, is there a way to continue that code onto the next line so all of the code can be viewed on my screen without scrolling to the right?

ruijc
- 19th February 2014, 20:25
Hi there,

yes there is...

just use the _ to break the line.

Check this example:


Lookup y, [$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$10,$08,$00,$00,$00,$00,$80,$80,$90,$00,$2 0,$1C,$2C,$30,_
$18,$18,$1C,$1C,$3E,$2E,$2A,$08,$2C,$10,$18,$18,$0 8,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$F0,_
$F0,$02,$02,$04,$04,$04,$04,$00,$00,$00,$00,$00,$0 1,$00,$00,$00,_
$00,$00,$00,$00,$00,$80,$80,$80,$80,$40,$40,$40,$2 0,$20,$10,$10,_
$10,$08,$88,$88,$4C,$44,$C4,$A4,$02,$00,$00,$00,$F C,$8C,$C4,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$20,$68,$68,$38,$00,$00,$0 0,$00,$00,$E0,_
$20,$10,$B0,$68,$C8,$00,$00,$80,$30,$C8,$08,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$FE,$01,$11,$C1,$A8,$88,$88,$5 4,$D4,$00,$00,_
$00,$00,$00,$00,$00,$00,$02,$14,$01,$0D,$0A,$6A,$1 0,$00,$00,$00,_
$F7,$39,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$4E,_
$00,$00,$00,$03,$EE,$01,$01,$03,$01,$F3,$45,$C3,$6 0,$D7,$BE,$46,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$3F,$00,$14,$2 C,$8A,$4A,$56,_
$19,$06,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$0 2,$0C,$02,$00,_
$00,$80,$00,$00,$02,$01,$03,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$80,$00,_
$80,$80,$00,$31,$00,$00,$00,$00,$FF,$00,$00,$00,$0 0,$DE,$39,$38,_
$08,$6B,$FC,$32,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$02,$01,$00,$00,$00,$00,$00,$00,$80,$80,$40,$4 0,$40,$20,$20,_
$20,$10,$10,$18,$08,$04,$05,$01,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$02,$05,$06,$03,$00,$00,$08,$10,$10,$20,$2 0,$20,$24,$56,_
$5C,$80,$80,$81,$83,$89,$00,$00,$00,$00,$80,$C0,$5 0,$48,$28,$2C,_
$12,$12,$10,$08,$08,$08,$04,$04,$02,$02,$03,$01,$0 1,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00] ,LcdReg

regards
Rui

Normnet
- 20th February 2014, 05:09
Hi there,

yes there is...

just use the _ to break the line.

Check this example:


Lookup y, [$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$10,$08,$00,$00,$00,$00,$80,$80,$90,$00,$2 0,$1C,$2C,$30,_
$18,$18,$1C,$1C,$3E,$2E,$2A,$08,$2C,$10,$18,$18,$0 8,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$F0,_
$F0,$02,$02,$04,$04,$04,$04,$00,$00,$00,$00,$00,$0 1,$00,$00,$00,_
$00,$00,$00,$00,$00,$80,$80,$80,$80,$40,$40,$40,$2 0,$20,$10,$10,_
$10,$08,$88,$88,$4C,$44,$C4,$A4,$02,$00,$00,$00,$F C,$8C,$C4,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$20,$68,$68,$38,$00,$00,$0 0,$00,$00,$E0,_
$20,$10,$B0,$68,$C8,$00,$00,$80,$30,$C8,$08,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$FE,$01,$11,$C1,$A8,$88,$88,$5 4,$D4,$00,$00,_
$00,$00,$00,$00,$00,$00,$02,$14,$01,$0D,$0A,$6A,$1 0,$00,$00,$00,_
$F7,$39,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$4E,_
$00,$00,$00,$03,$EE,$01,$01,$03,$01,$F3,$45,$C3,$6 0,$D7,$BE,$46,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$3F,$00,$14,$2 C,$8A,$4A,$56,_
$19,$06,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$0 2,$0C,$02,$00,_
$00,$80,$00,$00,$02,$01,$03,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$80,$00,_
$80,$80,$00,$31,$00,$00,$00,$00,$FF,$00,$00,$00,$0 0,$DE,$39,$38,_
$08,$6B,$FC,$32,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$02,$01,$00,$00,$00,$00,$00,$00,$80,$80,$40,$4 0,$40,$20,$20,_
$20,$10,$10,$18,$08,$04,$05,$01,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$02,$05,$06,$03,$00,$00,$08,$10,$10,$20,$2 0,$20,$24,$56,_
$5C,$80,$80,$81,$83,$89,$00,$00,$00,$00,$80,$C0,$5 0,$48,$28,$2C,_
$12,$12,$10,$08,$08,$08,$04,$04,$02,$02,$03,$01,$0 1,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0 0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00] ,LcdReg

regards
Rui
I'm not sure that works on anything other than the example.

Norm

Darrel Taylor
- 20th February 2014, 06:05
I'm not sure that works on anything other than the example.

Norm

Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?

HenrikOlsson
- 20th February 2014, 06:20
I thought the maximum allowed number of constants for LOOKUP was 255, it looks to be way more than that it the list - has that changed?
Never the less, it does show the "line continuation".

/Henrik.

HenrikOlsson
- 20th February 2014, 10:02
OK, I'll do my best to clarify that myself.....
Previously the limit was 255 or 256 but in version 2.5C the limit for PIC18 parts was increased to 1024 entities. The PBP3 manual (which of course is the correct place to look when in doubt) says 1024 for PIC18 parts while the online help in MCSP 5.0.0.3 doesn't mention that, it says 256 for 18C parts though.

/Henrik.

Charlie
- 20th February 2014, 13:37
Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?

While the manual doesn't say a lot about how to use the line extension character, from experience you need to extend from an operator and not just anywhere in the line.
For example:
myvariable31 = myvariable1 + myvariable2 + myvariable3 +_
myvariable4 + myvariable5
should work.

However;
myvariable31 = myvariable1 + myvariable2 + myvar_
iable3 + myvariable4 + myvariable5
will not.

It's called a line extension, but it's really statement extension to include terms and operators on the following line. You can't just jam it anywhere in the line of text and have the next line pick up exactly where the first left off.

Normnet
- 21st February 2014, 03:29
Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?
My bad. Pleased to see it works OK.

Norm

Christopher4187
- 4th June 2014, 23:00
Maybe you could phrase that the other way around, and suggest a scenario where it doesn't work?I have one.

I can't code wrap when the characters extend past column 255 even though we're given 1024.

Darrel Taylor
- 4th June 2014, 23:20
Could you explain what you mean by that.
This code which goes out to column 333 compiles just fine with PBP3.


I VAR WORD
value VAR WORD

LOOKUP I, [$45,$35,$67,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$4 5,$35,$67,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$45, $35,$67,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$45,$3 5,$67,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$45,$35, $67,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$45,$35,$6 7,$7E,$45,$35,$67,$7E,$45,$35,$67,$7E,$45,$35,$67, $7E,$45,$35,$67,$7E,_
$8F,$00,$0F,$C0,_
$EF,$55,$01,$00], value

It wraps in the forums code box, but you should get the idea.

Christopher4187
- 4th June 2014, 23:42
What happens when you try to compile this code?


HSEROUT ["iVBORw0KGgoAAAANSUhEUgAAACEAAAAkCAYAAAAHKVPcAAAAAX NSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQA AA7EAZUrDhsAAArtSURBVFhHVVhpb1XXFfVfaACPb579bGYwHv BsP9vPfp6NzGDjCcJghkClpKSIUmVom1aKKqVRUtqilhZwmANU plUSNUOhqIRIQYKUqimhUMKPWF1rn3fd5MN9w7nn7",_
"nHttfe5BQFfCXylhSgrWYIyfgf1n79DZYV2+UsWI+Avht9XjJL ixQj5eb+siFehffvzv/Ws31dke7Wu/wFeYe3ht3TovtbtHuXpW3sL7AEK9Ba8Db5SGsKNft2jUd8U4hk dpkFSYJcMpqxSGi0Dy/i81oNU7CvV+hJTrHvOGN6XgVwrcMp58cay8ti3LBzMtlJA3hgK ichT/tcV5jNBKvxpf9Z+",_
"B3hfUXMRXIKgKXGetjfWIhQopTOLbe3F2RkXzXxUCmThkf07Ee YmGRMOliHIkAZpYUCecnOYys/um8KpTAPme1pweO1yRIsW4RdVK/GnjhacymUQ4f+/",_
"PjeO8z2NmG9bjxNtDWaY5CmFumSAIqNIRLgeDpaafEaCG2lAeS yE8kTYLD5MS20tGbHNIVp8elMvHk0P4el4H25PDuBMWx2ut9fj K659NDOKBPFyqa0WD2cG8HhzD66PdOP1nZNmRJqyo6EyRlnKS1 FBueXxsMmW4wWyyuW7GCEuet4LYHYpBQzjq001+HQgi/sbe3FxpBMJGn+hdT1uTg/",_
"XibVX6mVPtMoHvzotJcMCrfzp2Bbp97K+POKB7WvEOxPa9oc9//AEEBNtPX0IZcAAAAAElFTkSuQmCC",34,"/>"]

Darrel Taylor
- 5th June 2014, 02:32
Compiling that code ... generates a "FATAL ERROR: Internal: Locate could not find nCmd = 32174784"

But it has nothing to do with "Line Continuation" and the "_" underscore.
There are simply too many characters in the HSEROUT command.

If you break that into 2 HSEROUT statements, it compiles fine ...

HSEROUT ["iVBORw0KGgoAAAANSUhEUgAAACEAAAAkCAYAAAAHKVPcAAAAAX NSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQA AA7EAZUrDhsAAArtSURBVFhHVVhpb1XXFfVfaACPb579bGYwHv BsP9vPfp6NzGDjCcJghkClpKSIUmVom1aKKqVRUtqilhZwmANU plUSNUOhqIRIQYKUqimhUMKPWF1rn3fd5MN9w7nn7",_
"nHttfe5BQFfCXylhSgrWYIyfgf1n79DZYV2+UsWI+Avht9XjJL ixQj5eb+siFehffvzv/Ws31dke7Wu/wFeYe3ht3TovtbtHuXpW3sL7AEK9Ba8Db5SGsKNft2jUd8U4hk dpkFSYJcMpqxSGi0Dy/i81oNU7CvV+hJTrHvOGN6XgVwrcMp58cay8ti3LBzMtlJA3hgK ichT/tcV5jNBKvxpf9Z+",_
"B3hfUXMRXIKgKXGetjfWIhQopTOLbe3F2RkXzXxUCmThkf07Ee Ym"]

HSEROUT ["GRMOliHIkAZpYUCecnOYys/um8KpTAPme1pweO1yRIsW4RdVK/GnjhacymUQ4f+/",_
"PjeO8z2NmG9bjxNtDWaY5CmFumSAIqNIRLgeDpaafEaCG2lAeS yE8kTYLD5MS20tGbHNIVp8elMvHk0P4el4H25PDuBMWx2ut9fj K659NDOKBPFyqa0WD2cG8HhzD66PdOP1nZNmRJqyo6EyRlnKS1 FBueXxsMmW4wWyyuW7GCEuet4LYHYpBQzjq001+HQgi/sbe3FxpBMJGn+hdT1uTg/",_
"XibVX6mVPtMoHvzotJcMCrfzp2Bbp97K+POKB7WvEOxPa9oc9//AEEBNtPX0IZcAAAAAElFTkSuQmCC",34,"/>"]


If you add a single character to the first HSEROUT ... it will fail.
Because there are already 512 characters. Apparently, the maximum it can handle.

Christopher4187
- 5th June 2014, 02:52
If you break that into 2 HSEROUT statements, it compiles fine ...I know. That's what I've been doing but now it's becoming a problem because there are so many HSEROUT statements. A 2kB image takes up 17kB of code space. Is there a better way to send an image that doesn't take up so much code space with HSEROUT statements?

Darrel Taylor
- 5th June 2014, 04:13
I know.
Really!


... it's becoming a problem because there are so many HSEROUT statements.
You could have an HSEROUT statement for every character, and it wouldn't use a single word more than putting everything in a single HSEROUT.
That's just the way HSEROUT works.
It calls a macro for each character, it doesn't matter which HSEROUT statement calls the macro.


A 2kB image takes up 17kB of code space. Is there a better way to send an image that doesn't take up so much code space with HSEROUT statements?
Store it in FLASH ... a 2kB image will use 2kB (on 18Fs).
Read it back with READCODE.