PDA

View Full Version : Help me save some spacecode...



ngeronikolos
- 10th August 2005, 11:59
This is my code.It is used 1697 words of my 2K space code.
Please help me to increase it.I do not want to change my Pic to bigger.

I attach my code.It is too big to post it.

Thanks
Regards
Nikos Geronikolos

Melanie
- 10th August 2005, 12:06
http://www.picbasic.co.uk/forum/showthread.php?t=545

It's all here somewhere if you did a SEARCH...

ngeronikolos
- 10th August 2005, 12:13
Dear Melanie,

I have aleady check this link.I tried to add after my variable Bank0 without any sucsses.My codespace is still the same.

Ioannis
- 10th August 2005, 12:45
Here is your smaller size code.

Read it to see why.

Ioannis

ngeronikolos
- 10th August 2005, 13:00
Thanks my friend john,

I see your changings.My code is much more smaller,now!
I will program my pic and I will inform you!!!
If you find anything else please tell me...

I am from Athens as you may see.
I have finished my studies in TEI of Thessaloniki.I love your town.
Any news from PAOK.

Best regards
Nikos

NavMicroSystems
- 10th August 2005, 13:10
nikos,

with some changes to your code you can still save sereral hundred words of codespace.
(Less than 1200 words should be possible)

Store the "static" strings in EEPROM

Do a search for "STRINGS EEPROM" and you'll find many examples.

Reduce the number of I2CWRITE statements by writing a subroutine "I2COUT"
Stet the required parameters and call that sub.

ngeronikolos
- 10th August 2005, 15:11
Raiph,

Thanks.I make a subroutine which save my some more code.But I have a problem.
Have a look:



DISPLAYADDRESSBYTE = $05
;GR Γ = RAM15 MAX6953
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE1, DISPLAYADDRESSBYTE, [$CB,%01111111,%00000001,%00000001,%00000001,%00000 001]
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE2, DISPLAYADDRESSBYTE, [$CB,%01111111,%00000001,%00000001,%00000001,%00000 001]
;GR Δ = RAM16
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE1, DISPLAYADDRESSBYTE, [$D0,%01111100,%01000010,%01000001,%01000010,%01111 100]
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE2, DISPLAYADDRESSBYTE, [$D0,%01111100,%01000010,%01000001,%01000010,%01111 100]
;GR Θ = RAM17
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE1, DISPLAYADDRESSBYTE, [$D5,%00111110,%01001001,%01001001,%01001001,%00111 110]
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE2, DISPLAYADDRESSBYTE, [$D5,%00111110,%01001001,%01001001,%01001001,%00111 110]


I would like to make a subroutine like that:


DISPLAYADDRESSBYTE = $05
X = $CB,%01111111,%00000001,%00000001,%00000001,%00000 001
GOSUB I2COUT
X = $D0,%01111100,%01000010,%01000001,%01000010,%01111 100
GOSUB I2COUT
X = $D5,%00111110,%01001001,%01001001,%01001001,%00111 110
GOSUB I2COUT
....
I2COUT:
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE1, DISPLAYADDRESSBYTE, [X]
I2CWRITE SDA0, SCL0, DISPLAYCONTROLBYTE2, DISPLAYADDRESSBYTE, [X]
RETURN
....

Now what variable is X?Word?
That is my problem.

Regards
Nikos

NavMicroSystems
- 10th August 2005, 23:50
nikos,

the attached example is based on your inital code with IOANNIS's modifications.

All I have done was some "cut & paste" and some modding.

It is supposed to work, but not tested.
(compiles to 1246 words)

There is still plenty of room for improvement,
the example is just ment to give you an idea.