I
f a string is declared as a literal it should reside in rom. the compiler should pass by reference into rom. Current compiler does not do that. it makes a bulky copy routine to store the string in ram (it seeds an index , performs a MOV of the hardcoded character and then increments r0.
This eats rom space... either do this with a loop or, since you hardcode the characters you can hardcode the target addresses as well and avoid the increment. This would already double the speed and halve ROM space.
Passing a pointer to handling function is most efficient. the function implements a loop searching for the null character on the string.
I have played with the compilers for a couple of days and studied the output. It looks like you use the same core compiler no matter what cpu. You don't take advantage of cpu features in the libraries. the libraries are slow and bulky because they need to be able to run on any cpu.
Code: Select all
Lcd.mbas,40 :: q = "hello world"
MOV R0, #_q+0
MOV @R0, #104
INC R0
MOV @R0, #101
INC R0
MOV @R0, #108
INC R0
MOV @R0, #108
INC R0
MOV @R0, #111
INC R0
MOV @R0, #32
INC R0
MOV @R0, #119
INC R0
MOV @R0, #111
INC R0
MOV @R0, #114
INC R0
MOV @R0, #108
INC R0
MOV @R0, #100
INC R0
MOV @R0, #0
this wuld halve size and double speed :
Code: Select all
Lcd.mbas,40 :: q = "hello world"
MOV q+0, #104
MOV q+1, #101
MOV q+2, #108
MOV q+3, #108
MOV q+4, #111
MOV q+5, #32
MOV q+6, #119
MOV q+7, #111
MOV q+8, #114
MOV q+9, #108
MOV q+10, #100
MOV q+11, #0
the above should be stored as a db chain. and a pointer should be passed.
q = some rom location
org q
db "hello world",0
call 'somefunction'
function gets pointer to Q ( rom address)
s=q^
while s <>0
p1 = s
incr(q)
s=q^
wend
there is endless data shuffling that is totally unnecessary.
Other food for thought : Why is there no 8 bit lcd library ? Also the feature of having every bit in the data path on the 4 bit assignable eats cpu cycles.