Hello

I will try to code it in C today ,

In the mean while, someone answered this:

https://my.st.com/public/STe2ecommunities/mcu/Lists/stm81/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fstm81%2fpointer%20problem%20%28sdcc%20assembler%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580001E3853D9DB932A46A3FE4CD15CAB46FB&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fstm81%2FAllItems%2Easpx&currentviews=38

and I had changed my code to this:


       00813C 72 CE 00 03      [ 5]  214        ldw     X,[_charptr]
       008140 CF 00 02         [ 2]  215        ldw     _lcdchar,X
       008143 CD 81 D5         [ 4]  216        call    _lcdwritechar
       008146 CE 00 03         [ 2]  217        ldw     X, _charptr
       008149 5C               [ 2]  218        incw    X
       00814A CF 00 03         [ 2]  219        ldw     _charptr, X
                                     220
       00814D CC 81 2A         [ 2]  221        JP      main_loop


regards

Le 2014-09-29 01:44, Bin Shi a écrit :
> Does your c code work? If so, what are the differences between the
> generated asm and your own asm ?
> 
> r...@remi.lu编写:
> 
>> hi,
>> 
>> I tried following a c/asm generated code by sdcc , but now it only
>> prints the T , like the INCrementing doesnt do it:
>> 
>> 
>> any help ?, and as I said , when I use thing.w , the "thing"
>> register/variable is not recognised, it takes is as a new reference 
>> ...
>> the .w to make show as a word, is not handeled i think
>> 
>> ....
>> ;--------------------------------------------------------
>>      .area INITIALIZED
>> 
>> _charptr::
>>      .ds     2
>> ;--------------------------------------------------------
>> ; Stack segment in internal ram
>> ;--------------------------------------------------------
>> .....
>> ;--------------------------------------------------------
>>      .area INITIALIZED
>> 
>> _charptr::
>>      .ds     2
>> ;--------------------------------------------------------
>> ; Stack segment in internal ram
>> 
>>      mov     _varOne, #'a'
>> 
>>      ldw     X,__xinit__charptr   ;#__string_0
>>      ldw     _charptr, X
>> 
>> 
>> main_loop:
>> 
>> 
>>      LDW     X, #0d50
>>      CALL    delay_m
>>      CALL    ledon
>> 
>> 
>>      LDW     X, #0d50
>>      CALL    delay_m
>>      CALL    ledoff
>> 
>> 
>>      ld      a,[__xinit__charptr]            ; <---- not returning what is 
>> at that 
>> address
>>      ld      _lcdchar,a
>>      call    _lcdwritechar
>>      inc     __xinit__charptr
>> 
>>      JP      main_loop
>> 
>> ....
>> 
>> 
>>      .area CODE
>> __string_0:
>>         .ascii "toto"
>>         .db 0x00
>> 
>>      .area INITIALIZER
>> __xinit__charptr:
>>      .dw     __string_0
>> 
>>      .area CABS (ABS)
>> 
>> ....
>> 
>> 
>> 
>> 
>> 
>> 
>> Le 26.09.2014 13:33, r...@remi.lu a écrit :
>>> Hello
>>> 
>>> I tested your suggestion, then replaced the ADDW with INCW ... still
>>> not
>>> working
>>> 
>>> this time, the carracter it self is incremented
>>> as if the syntax
>>> 
>>>     ldw     X,[_charptr] doesnt return a pointer ...
>>> 
>>> 
>>> If you guys think this is not a bug, I can try forum@st and try to 
>>> port
>>> their answers
>>> i am aware this mailing list is not dedicated to the STM8 assembly...
>>> 
>>> 
>>> 
>>> 
>>>     ldw     X,#string_0
>>>     ldw     _charptr, X
>>> 
>>> main_loop:
>>> 
>>>     LDW     X, #0d50
>>>     CALL    delay_m
>>>     CALL    ledon
>>> 
>>>     LDW     X, #0d50
>>>     CALL    delay_m
>>>     CALL    ledoff
>>> 
>>>     ldw     Y,[_charptr]
>>>     ldw     _lcdchar, Y
>>>     call    _lcdwritechar
>>>     ldw     Y, _charptr
>>>     incw    Y
>>>     ldw     _charptr, Y
>>> 
>>>     JP      main_loop
>>> 
>>> 
>>> 
>>> 
>>> Le 26.09.2014 11:39, Bin Shi a écrit :
>>>> 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
>>> 
>>> ------------------------------------------------------------------------------
>>> 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
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&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