the _pointer is a 16-bit variable, and stm8 is big endian. you might need

 ld y, _pointer
addw y, #1
ld _pointer, y

to replace inc _pointer

r...@remi.lu编写:

> 
>
>hello 
>
>with this code i get printed : "t3333333...." 
>
>you think the X register gets polluted by the delay fonction ? 
>
>Regards 
>
>Le 26.09.2014 04:11, Ben Shi a écrit : 
>
>> I am not sure how your function _lcdwritechar works, but I guess you might 
>> need such kind of code, 
>> 
>> .area DATA 
>> 
>> _varOne: 
>> 
>> .ds 1 
>> 
>> _lcdchar: 
>> 
>> .ds 1 
>> 
>> _pointer: 
>> 
>> .ds 1 
>> 
>> ..... 
>> 
>> ldw x, #_string_0 
>> 
>> ldw _pointer, x 
>> 
>> main_loop: 
>> 
>> LDW X, #0d50 
>> 
>> CALL delay_m 
>> 
>> CALL ledon 
>> 
>> LDW X, #0d50 
>> 
>> CALL delay_m 
>> 
>> CALL ledoff 
>> 
>> ldw x, [_pointer.w] 
>> 
>> ldw _lcdchar, x 
>> 
>> call _lcdwritechar 
>> 
>> inc _pointer 
>> 
>> JP main_loop 
>> 
>> .... 
>> 
>> .area CODE 
>> 
>> _string_0: 
>> 
>> .ascii "toto" 
>> 
>> .db 0x00 
>> 
>> First, the variable _pointer is initialized to point to _string_0; second, 
>> in each iteration of the main loop, the content pointed by _pointer is moved 
>> to _lcdchar; third, _pointer increases each time. 
>> 
>> 在2014年09月25 23时32分,"remi"<r...@remi.lu>写道: 
>> 
>>> Hello 
>>> 
>>> I have spent a few years with MChip, I switched to stm8 recently. 
>>> 
>>> One of the reasons is pointer handeling (pic16 and 18) very limited ... 
>>> 
>>> and now, I am almost learning two things in the same time, STM8 and sdasm . 
>>> 
>>> Can some one direct me a little on how pointers are beeing 
>>> 
>>> used in sdasstm8 ? 
>>> 
>>> in this snipet, i am trying to go trhu a string and print it ... 
>>> 
>>> no luck so far, only the "t" is printed . 
>>> 
>>> I have already went thru sdccman.pdf ... but it mostly talk about its C and 
>>> inline assembly , 
>>> 
>>> and stm8 axemples elsewhere are for other assemblers ... :) 
>>> 
>>> my goal , is to write 100% assembly code . 
>>> 
>>> Best regards 
>>> 
>>> .area DATA
>>> _varOne:
>>> .ds 1
>>> _lcdchar:
>>> .ds 1 
>>> 
>>> ..... 
>>> 
>>> main_loop: 
>>> 
>>> LDW X, #0d50
>>> CALL delay_m
>>> CALL ledon 
>>> 
>>> LDW X, #0d50
>>> CALL delay_m
>>> CALL ledoff 
>>> 
>>> mov _lcdchar,string_0
>>> call _lcdwritechar
>>> inc [string_0] 
>>> 
>>> JP main_loop 
>>> 
>>> .... 
>>> 
>>> .area CODE
>>> string_0:
>>> .ascii "toto"
>>> .db 0x00 
>>> 
>>> .area INITIALIZER
>>> .area CABS (ABS)
>> 
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk 
>> [1]
>> 
>> _______________________________________________
>> Sdcc-user mailing list
>> Sdcc-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/sdcc-user [2]
>
> 
>
>Links:
>------
>[1]
>http://pubads.g.doubleclick.net/gampad/clk?id=154622311&amp;iu=/4140/ostg.clktrk
>[2] https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
>------------------------------------------------------------------------------
>Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
>_______________________________________________
>Sdcc-user mailing list
>Sdcc-user@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/sdcc-user
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to