Bug with string literals

Beta Testing discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
stevech
Posts: 38
Joined: 20 Aug 2007 16:47

Bug with string literals

#1 Post by stevech » 11 Dec 2008 05:40

This is a bug.
The compiler is generating load immediate over and over instead of putting a const string in RAM or more preferably in Flash.

Code: Select all

       UART1_Write_Text("AVR-Started") ' If AVR present report
0x0092        0x01FE            MOVW       R30, R28
0x0094        0xE4B1            LDI        R27, 65
0x0096        0x93B1            ST         Z+, R27
0x0098        0xE5B6            LDI        R27, 86
0x009A        0x93B1            ST         Z+, R27
0x009C        0xE5B2            LDI        R27, 82
0x009E        0x93B1            ST         Z+, R27
0x00A0        0xE2BD            LDI        R27, 45
0x00A2        0x93B1            ST         Z+, R27
0x00A4        0xE5B3            LDI        R27, 83
0x00A6        0x93B1            ST         Z+, R27
0x00A8        0xE7B4            LDI        R27, 116
0x00AA        0x93B1            ST         Z+, R27
0x00AC        0xE6B1            LDI        R27, 97
0x00AE        0x93B1            ST         Z+, R27
0x00B0        0xE7B2            LDI        R27, 114
0x00B2        0x93B1            ST         Z+, R27
0x00B4        0xE7B4            LDI        R27, 116
0x00B6        0x93B1            ST         Z+, R27
0x00B8        0xE6B5            LDI        R27, 101
0x00BA        0x93B1            ST         Z+, R27
0x00BC        0xE6B4            LDI        R27, 100
0x00BE        0x93B1            ST         Z+, R27
0x00C0        0xE0B0            LDI        R27, 0
0x00C2        0x93B1            ST         Z+, R27
0x00C4        0x018E            MOVW       R16, R28
0x00C6        0x931F            PUSH       R17
0x00C8        0x930F            PUSH       R16
0x00CA        0xD559            RCALL      _UART1_Write_Text+0
0x00CC        0xB7AD            IN         R26, SPL
0x00CE        0xB7BE            IN         R27, SPH
0x00D0        0x9612            ADIW       R26, 2
0x00D2        0xBFAD            OUT        SPL, R26
0x00D4        0xBFBE            OUT        SPH, R27
as well

Code: Select all

Lcd.mbas,51 ::                 txt1 = "mikroElektronika"
0x0286        0xE6EB            LDI        R30, _txt1+0
0x0288        0xE0F0            LDI        R31, hi_addr(_txt1+0)
0x028A        0xE6BD            LDI        R27, 109
0x028C        0x93B1            ST         Z+, R27
0x028E        0xE6B9            LDI        R27, 105
0x0290        0x93B1            ST         Z+, R27
0x0292        0xE6BB            LDI        R27, 107
0x0294        0x93B1            ST         Z+, R27
0x0296        0xE7B2            LDI        R27, 114
0x0298        0x93B1            ST         Z+, R27
0x029A        0xE6BF            LDI        R27, 111
0x029C        0x93B1            ST         Z+, R27
0x029E        0xE4B5            LDI        R27, 69
0x02A0        0x93B1            ST         Z+, R27
0x02A2        0xE6BC            LDI        R27, 108
0x02A4        0x93B1            ST         Z+, R27
0x02A6        0xE6B5            LDI        R27, 101
0x02A8        0x93B1            ST         Z+, R27
0x02AA        0xE6BB            LDI        R27, 107
0x02AC        0x93B1            ST         Z+, R27
0x02AE        0xE7B4            LDI        R27, 116
0x02B0        0x93B1            ST         Z+, R27
0x02B2        0xE7B2            LDI        R27, 114
0x02B4        0x93B1            ST         Z+, R27
0x02B6        0xE6BF            LDI        R27, 111
0x02B8        0x93B1            ST         Z+, R27
0x02BA        0xE6BE            LDI        R27, 110
0x02BC        0x93B1            ST         Z+, R27
0x02BE        0xE6B9            LDI        R27, 105
0x02C0        0x93B1            ST         Z+, R27
0x02C2        0xE6BB            LDI        R27, 107
0x02C4        0x93B1            ST         Z+, R27
0x02C6        0xE6B1            LDI        R27, 97
0x02C8        0x93B1            ST         Z+, R27
0x02CA        0xE0B0            LDI        R27, 0
0x02CC        0x93B1            ST         Z+, R27

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: Bug with string literals

#2 Post by Thomas.Pahl@t-online.de » 11 Dec 2008 18:52

mentioned code works!! ==> no bug!!
Perhaps it is not elegant. (ST Z+,r27 puts literal into ram)
You do not need to use it. Use constants instead. Load them into variable before you print them or else.
Thopas

stevech
Posts: 38
Joined: 20 Aug 2007 16:47

#3 Post by stevech » 11 Dec 2008 21:26

Please show example of const string.
Library routines such as UART Write Text don't accept string constants.

Post Reply

Return to “mikroBasic PRO for AVR Beta Testing”