Basic Compiler Debug Test Examples
Debug test examples published below were used for the compiler engine tests during the software development.
Most of the code tested is functionally meaningless, because the focus was on the inspection of the generated code for accuracy and precision.
Commented lines of code were probably used for the test of compiler error messages...
The newest test examples are on the top of the list.
A tip for advanced and/or curious users:
Be sure to turn on (set to 1 using the Registry Editor) the 'Print Debug Comment Lines in Compiler Listing' registry value for the software package you are using (located in 'HKEY_CURRENT_USER\Software\OshonSoft PIC18 Basic Compiler' registry key, for example), and then inspect the generated assembler listing for these examples, especially for complex expressions related ones at the bottom of the page...
string functions test #1
Dim s1 As String
Dim s2[5] As String
Dim s3 As String
Dim v1 As Byte
Dim v2 As Word
v1 = "9"
s2 = Chr(v1 - 2) + Chr(v1)
s1 = s2
v2 = Len(s2)
v2 = Asc(s1)
s1 = "abcde"
s2 = "abcde"
v1 = 1
If s1 = s2 Then v1 = 2
s1 = "abcdef"
v1 = 3
If s1 != s2 Then v1 = 4
s1 = LeftStr("01234567", 0)
s1 = LeftStr("01234567", 5)
s1 = LeftStr("01234567", 20)
s2 = LeftStr("01234567", 0)
s2 = LeftStr("01234567", 5)
s2 = LeftStr("a01234567", 20)
s1 = RightStr("01234567", 0)
s1 = RightStr("01234567", 5)
s1 = RightStr("01234567", 20)
s2 = RightStr("01234567", 0)
s2 = RightStr("01234567", 5)
s2 = RightStr("01234567", 20)
s1 = MidStr("01234567", 10, 3)
s1 = MidStr("01234567", 7, 3)
s2 = MidStr("01234567", 2, 10)
s1 = "01iuyt"
s3 = UCase(s1)
s2 = LCase(s3)
s2 = UCase("aBCdef")
s1 = "hghghghg"
s3 = ReplaceChr(s1, "h", "o")
s2 = ReplaceChr(s1, "g", "s")
s1 = "qwerty"
v2 = InStr(s1, "r")
v1 = InStr(s1, "0")
s2 = "56565"
v1 = InStrRev(s2, "5")
v1 = InStrRev(s2, "6")
v1 = CountChr(s2, "5")
s1 = FillStr("x", 10)
s2 = FillStr("y", 10)
s1 = RTrimChr("12345600", "0")
s2 = RTrimChr("01234567", "7")
s2 = RTrimChr("a1234444", "4")
s1 = LTrimChr("001234xx", "0")
s2 = LTrimChr("01234567", "0")
s2 = LTrimChr("01234567", "1")
s1 = ReverseStr("w234567")
s2 = ReverseStr(s1)
string functions test #2
Dim s1 As String
Dim s2[5] As String
s1 = LShiftStr("12345678", "x")
s1 = LShiftStr("1234", "x")
s1 = LShiftStr("1", "x")
s1 = LShiftStr("", "x")
s2 = LShiftStr("12345678", "x")
s2 = LShiftStr("123456", "x")
s2 = LShiftStr("12345", "x")
s2 = LShiftStr("1234", "x")
s2 = LShiftStr("1", "x")
s2 = LShiftStr("", "x")
s1 = RShiftStr("12345678", "x")
s1 = RShiftStr("1234", "x")
s1 = RShiftStr("1", "x")
s1 = RShiftStr("", "x")
s2 = RShiftStr("12345678", "x")
s2 = RShiftStr("123456", "x")
s2 = RShiftStr("12345", "x")
s2 = RShiftStr("1234", "x")
s2 = RShiftStr("1", "x")
s2 = RShiftStr("", "x")
s1 = LRotateStr("12345678")
s1 = LRotateStr("1234")
s1 = LRotateStr("1")
s1 = LRotateStr("")
s2 = LRotateStr("12345678")
s2 = LRotateStr("123456")
s2 = LRotateStr("12345")
s2 = LRotateStr("1234")
s2 = LRotateStr("1")
s2 = LRotateStr("")
s1 = RRotateStr("12345678")
s1 = RRotateStr("1234")
s1 = RRotateStr("1")
s1 = RRotateStr("")
s2 = RRotateStr("12345678")
s2 = RRotateStr("123456")
s2 = RRotateStr("12345")
s2 = RRotateStr("1234")
s2 = RRotateStr("1")
s2 = RRotateStr("")
string functions test #3
#define STRING_MAX_LENGTH = 10
Dim s1 As String
Dim s2[3] As String
Dim s3 As String
Dim sh1 As Short
Dim b1 As Byte
Dim w1 As Word
Dim l1 As Long
Dim g1 As Single
s1 = "208"
b1 = StrValB(s1)
s1 = ""
b1 = StrValB(s1)
s1 = "51397"
w1 = StrValW(s1)
s1 = "1234567123"
l1 = StrValL(s1)
s1 = "-6.7891230"
g1 = StrValS(s1)
s3 = "F"
w1 = DecFromHex(s3)
s3 = "FF"
w1 = DecFromHex(s3)
s3 = "FFF"
w1 = DecFromHex(s3)
s3 = "FFFF"
w1 = DecFromHex(s3)
s3 = "123456"
w1 = DecFromHex(s3) '1234h=4660
sh1 = -1
s1 = HexStr(sh1)
s2 = HexStr(sh1)
b1 = 0xaa
s1 = HexStr(b1)
s2 = HexStr(b1)
w1 = 0xfab
s1 = HexStr(w1)
s2 = HexStr(w1)
l1 = 0xfefe
s1 = HexStr(l1)
s2 = HexStr(l1)
string pointers
#define STRING_MAX_LENGTH = 16
Dim sx[1] As String
Dim px As StrPtr
'sx = "aa"
sx = "a"
SetStrPtr px = sx
'px = "aaaa"
px = "b"
Dim a1 As Byte
Dim s1[10] As String
Dim s2 As String
Dim p1 As StrPtr
Dim p2 As StrPtr
s1 = "abc"
s2 = "de"
SetStrPtr p1 = s1
p2 = p1
SetStrPtr p2 = p1
p2 = "1234"
SetStrPtr p2 = p2 + 2
p2 = "x"
SetStrPtr p2 = s2
p1 = "qwerty"
p2 = "zxcv"
s1 = p2
s1 = "aaa" + p2
a1 = 10
s1 = "abc" + "def"
s1 = sx + "7654" + "ggg"
s2 = sx + "01234" + "hh"
Call test1(s2, a1, s1)
End
Proc test1(ByRef arg1 As String, ByRef arg2 As Byte, ByRef arg3 As String)
arg1 = "555"
arg2 = 25
arg3 = "3434"
arg1 = arg1 + "876"
End Proc
dot operator test #1
Dim x0 As Bit
Dim xb As Byte
Dim xw(5) As Word
Dim xs As String
Dim xb1 As Byte
Dim xb2(5) As Byte
Dim xw1 As Word
Dim xw2(5) As Word
Dim xl1 As Long
Dim xl2(5) As Long
Dim xs1 As String
x0 = (xb + 1).xw
x0 = (xb + 1).3
xb = -xb1.LB / xw2(xb - 1).HB
xb = xw1.LB And xw1.HB
xs = #(xw.LB)
xs = #(!xw.LB)
xs = #(xw2(xb1 + 2).HB)
x0 = xl2(xb1 + 2).HW.LB.(xb + 1)
xl2(xb1 + 2).HW.LB.(xb + 1) = xb.(3 + 1)
xb = xw2(xb1 + 2).HB
xw.LB = xl2(xb1 + 2).HW.LB
xl2(xb1 + 2).HW.LB = xw.LB
dot operator test #2
Dim x0 As Bit
Dim xb As Byte
Dim xw(5) As Word
Dim xs As String
Dim xb1 As Byte
Dim xb2(5) As Byte
Dim xw1 As Word
Dim xw2(5) As Word
Dim xl1 As Long
Dim xl2(5) As Long
Dim xs1 As String
xb = xw(xb1).LB
xb = -xw.LB
xb = -xw(xb1).LB
xs = #(-xw(xb1).LB)
xw2(xb1).HB.xb = (xl2(xb1 + 2).HW).3
xs1 = #(-+xl2(xb1 + 2).HW.LB)
xw2(xw1 + 2).LB = -xl2(xb1 + 2).HW.LB
xw2(xb1 + 2).LB.3 = True
xw2(xb1).HB.3 = xl2(xb1 + 2).HW.15
xw(xb + 3) = xw(2).LB
xb + 5 = xw(2).LB
xw(3).LB = xw(2).LB
xb = xw.LB + xw.LB
xb = (xw(2) + xb.LB).LB
dot operator if test
Dim x0 As Bit
Dim xb As Byte
Dim xw(5) As Word
Dim xs As String
Dim xb1 As Byte
Dim xb2(5) As Byte
Dim xw1 As Word
Dim xw2(5) As Word
Dim xl1 As Long
Dim xl2(5) As Long
Dim xs1 As String
If xb1.3 = xw1.3 Then
Endif
If xw2(xb1).HB.xb = xl2(xb1 + 2).HW.3 Then
Endif
If xw2(xb1).HB.xb = xl2(xb1 + 2).HW.3 Then
Endif
If xw(xb1).LB.xb = xl2(2).HW.LB.3 Then
Endif
If -xw(xb1).LB = xl2(2).HW.LB Then
If -xw(xb1).LB = (xw(2) + xb.LB).LB Then
Endif
Endif
dot operator logical test
Dim x1 As Bit
Dim x2 As Bit
Dim xb As Byte
Dim xb2(3) As Byte
Dim xw As Word
Dim xw2(3) As Word
x1 = x2 And xb2(xb + 2).3
xb = xb && xb2(xb + 2).LB
x1 = xb And xb2(xb + 2).xw
x1 = x2 And xb2(xb + 2).xw2(xb)
x1 = x2 And xb2(xb + 2).xw2(xb + 1)
x1 = Not xb2(xb + 2).xw
x1 = !xb2(xb + 2).xw
cfor-cnext test
Dim i As Byte
Dim j As Byte
Dim k As Byte
k = 0
CFor (i = 1; i < 7; i++)
k++
CNext
k = 0
CFor (i = 5, j = 10; i + j < 20; i++, j++)
k++
CNext
for-next overflow test - long
Dim i As Long
Dim k As Byte
k = 0
For i = 4294967280 To 4294967295 Step 10
k = k + 1
Next i
For i = 12 To 0 Step -5
k = k + 1
Next i
for-next overflow test - word
Dim i As Word
Dim k As Byte
k = 0
For i = 65520 To 65535 Step 10
k = k + 1
Next i
For i = 12 To 0 Step -5
k = k + 1
Next i
for-next overflow test - byte
Dim i As Byte
Dim k As Byte
k = 0
For i = 240 To 255 Step 10
k = k + 1
Next i
For i = 12 To 0 Step -5
k = k + 1
Next i
expressions test #10
Dim x As Word
'Dim oshonsoft_temp15 As Word
Dim x1 As Word
Dim x2 As Word
Dim b1 As Bit
x = x1 && x2
x = x1 || x2
x = !x1
x = x1 % x2
x = --x1
x = ++x1
'b1 = ++x
b1 = x < x1 And x2 != 0
b1 = x < x1 || Not (x2 > 0)
b1 = x < x1 And ~(x2 > 0)
x = x1 << 6
x = x1 ShiftLeft x2
b1 = x < x1 Or x2 > x2 + (x1 >> 3)
'b1 = (x < 1) Mod (x < 0)
'b1 = (x < 1) % (x < 0)
b1 = (x < 1) And !(x < 0)
b1 = (x + 1) > (x + 1)
x1 = x--
x1 = x++
b1 = x < --x1 || Not (x2++ > 0)
expressions test #9 - for-next
Dim i As Byte
Dim j2 As Byte
Dim j As Word
Dim k As Word
Dim k2 As Word
Dim b1 As Bit
Dim s1 As String
j = 1
k = 5
k2 = 0
For i = j + 1 To k * 2 + 1 Step 2
k2 = k2 + 1
Next i
j2 = 0
For i = 1 To 10 Step 1 + j2
k2 = k2 + 1
Next i
expressions test #8 - while, csingle, clong
Dim w1 As Word
Dim l1 As Long
Dim s1 As Single
Dim i As Byte
Dim k As Byte
Dim j(5) As Byte
'While 2
'Wend
While 1
k = k + 1
Wend
'If 2 Then i = 1
If 1 Then i = 2
While i == j(w1)
k = k + 1
Wend
While s1 - 1 = w1 / 1000
k = k + 1
Wend
While l1 - 1 = w1 * 1000
k = k + 1
Wend
While s1 + 1 = CSingle w1 / 1000
k = k + 1
Wend
While l1 + 1 = CLong w1 * 1000
k = k + 1
Wend
expressions test #7
Dim w1 As Word
Dim l1 As Long
Dim s1 As Single
Dim i As Byte
Dim j(5) As Byte
5
i
j(5)
j(i)
#i
#j(i)
#i = w1 + 5
i + j = w1 + 5
i + j = w1 + 5 % 1
Sin(s1) = w1 + 5
s1 += w1 / 1000 + 3.14
s1 = w1 / 1000 + 3.14
l1 = w1 * 1000 + 500
If s1 = w1 / 1000 Then i = 0
If l1 = w1 * 1000 Then i = 0
If s1 = CSingle w1 / 1000 Then i = 0
If l1 = CLong w1 * 1000 Then i = 0
expressions test #6 - select case
Dim i As Byte
Dim j As Byte
Select Case i
Case 1
Case 5 + j
Case 2, 3, >= 10 + j
Case Else
EndSelect
expressions test #5 - lcdout
Dim i As Word
Dim a1 As Word
Dim a2 As Word
Dim s1 As String
AllDigital
Lcdinit
s1 = "ab"
a1 = 50
a2 = 50
For i = 0 To 10
Lcdcmdout LcdClear
Lcdout s1 + "c", 32, #i, 32, #(i + 1), 32, #-i
Lcdcmdout LcdLine2Home
Lcdout #func1(i * 2 + 1), 32, #a1++, 32, #--a2
Next i
a1 = func1(i * 2 + 1 + 2 + 3)
++a1
a2--
a1 == a2
'a1++ +
End
Function func1(arg1 As Word) As Word
func1 = arg1 + 100
End Function
expressions test #4 - logical
Dim b1 As Bit
Dim b2 As Bit
Dim a1 As Word
Dim a2 As Word
Dim x1 As Long
Dim x2 As Long
Dim i As Word
Dim j As Word
a1 += a2 Or x1 && x2
'b1 = !a1
'a1 = b1 ^ b2
'b1 = a1 & b2
'a1 = a1 & b2
b1 = Not b1 || !b1
a1 = a2 | a2 << 2
a1 = a2 ^ ShiftLeft(a2, 2)
b1 = b2 = True
a1 = b1 == b2
b1 = b1 == b2 And a1 <> a2 Or Not a1 != a2
b1 = (i > j * 10 + 5 And i + 10 < j * 20) Or x2 = i * 10000
'a1 = (i > j * 10 + 5 And i + 10 < j * 20) Or x2 = i * 10000
b1 = (i > j * 10 + 5 And i + 10 < j * 20) Or x2 = CLong i * 10000
expressions test #3
Dim a1 As Word
Dim a2 As Word
Dim x1 As Single
a1 += a2
a1 -= Sqr a2
a1 *= x1
a1 /= Log x1
expressions test #2
Dim a1 As Word
Dim a2 As Word
Dim a3 As Word
Dim abs As Single
Dim x1 As Single
a1 = -a2 + "a"
'a1 = -a2 + -100
x1 = -a2 + -100
x1 = -CSingle(a2) + -100
x1 = -abs + -100
abs = -abs
'Const pi = 3.14159265
Const pi = 3.14159
x1 = Sin(-pi - 0.1)
'a1 = a2 * + / a3
'a1 = a2 / a3 a1
new complex expressions evaluation engine test #1
Dim a1 As Word
Dim a2 As Word
Dim a3 As Word
Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim i1 As Byte
Dim i2 As Byte
Dim abs As Single
Dim peaks(10) As Single
a1 = Sqr(a2)
'a1 = #a2
s1 = #a2
s1 = "abcd" + s2
s1 = "abcd" + #a2
s1 = "abcd" + #a2 + s2 + s3
abs = peaks(i1 - 1) - peaks(i1 - 2)
a1 = --a2 / 2
a1 = Sqr ++a2
a1 = --a2 + ++a3
a1 = a2 + a3
a1 = -a2 + +a3
a1 = -a2 + +-a3
a1 = a2-- / 2
a1 = a2-- / 2 + 1 * 2
a1 = a2++
a1 = a2++ + --a2
a1 = a2++ + a2++
a1 = --a2 + a2--
a1 = --a2 + --a2
a1 = a2 = a3 + 1
peaks(i1 - 3) = abs = peaks(i1 - 1) - peaks(i1 - 2)
'a1 = #(a1 + a2 * a3)
s1 = #(a1 + a2 * a3)
a1 + a2 = a2 * a3
a3 = a1 + a2 = a2 * a3
array index check warnings
Dim v1(9) As Word
Dim v2 As Word
v1(-100) = 0
v1(10000) = 0
v1(9) = 10
v1(5) = v1(9) + 5
For v2 = 0 To 9
v1(v2) = 0
Next v2
For v2 = 9 To 2 Step -1
v1(v2) = 0
Next v2
array index check warnings (z80, 8085)
'Dim v1a(9) As Integer
'Dim v1b(40000) As Integer
Dim v1(9) As Integer
Dim v2 As Integer
For v2 = 1 To 10
v1(v2) = 0
Next v2
v1(-100) = 0
v1(10000) = 0
v1(9) = 10
v1(5) = v1(9) + 5
For v2 = 0 To 9
v1(v2) = 0
Next v2
For v2 = 9 To 2 Step -1
v1(v2) = 0
Next v2
single precision math calculations test
Dim s1 As Single
s1 = 1.2345 - 0.0666 '1.1679
s1 = 5.0045 * -3.333 '-16.6799985
s1 = 4.444 / 0.234567 '18.945546
s1 = Exp(0.55) '1.7332530
s1 = Sqrt(3.13) '1.7691806
s1 = Log(3.12) '1.1378330
s1 = Exp(3.03) '20.697232
s1 = Sin(2.93) '0.2100172
s1 = Cos(2.83) '-0.9518465
Dim l1 As Long
Dim b1 As Byte
s1 = Exp(3.03) '20.697232
l1 = s1
b1 = s1
While s1 > 15.003
s1 = s1 - 2
Wend
string test #2
#define STRING_MAX_LENGTH = 18
#define SINGLE_DECIMAL_PLACES = 6
Dim BigNumber1 As String
Dim BigNumber2 As String
Dim result As Single
Dim l_val1 As Long
Dim s_val1 As Single
Dim l_val2 As Long
Dim size As Byte
Dim decpnt As Byte
Const pi = "3.1415938"
BigNumber1 = "4294967295.1234567"
BigNumber2 = "-1.349876"
size = Len(BigNumber1)
decpnt = InStr(BigNumber1, ".")
l_val1 = StrValL(LeftStr(BigNumber1, decpnt - 1))
l_val2 = StrValL(RightStr(BigNumber1, size - decpnt))
result = StrValS(pi)
s_val1 = StrValS(BigNumber2)
Serout PORTB.6, 9600, BigNumber1, " ", #size, " ", #decpnt, 10
Serout PORTB.6, 9600, #l_val1, " ", #l_val2, " ", #s_val1, " ", pi
string test #1
#define SINGLE_DECIMAL_PLACES = 4
Dim str1 As String
Dim str2 As String
Dim lenth As Byte
Dim xyz As Single
Dim array(10) As Byte
str1 = "1234.56789012345"
str2 = "-378.9875"
lenth = Len(str1)
xyz = StrValS(str2)
array(5) = 65
Serout PORTB.6, 9600, str1, 10
Serout PORTB.6, 9600, #lenth, 10
Serout PORTB.6, 9600, #array(4), " ", #array(5), 10
str1(7) = "#"
Serout PORTB.6, 9600, #array(5), " ", #str1(7), Cr
Serout PORTB.6, 9600, str1, Cr
Serout PORTB.6, 9600, #xyz
while type test
Dim s1 As String
Dim s2 As String
Dim b1 As Byte
Dim w1 As Word
Dim l1 As Long
Dim ss1 As Single
b1 = 100
s1 = "aaa"
s2 = "bbb"
s1 = s2 + #b1
While b1 - 10 < 1000
Wend
While b1 - "a" < 100
Wend
While LeftStr(s1, 5) = "aaaaa"
Wend
While b1 = 3
Wend
While b1 + 1 + 1 = b1 * 100
Wend
While "aaa" = "aa"
Wend
While w1 * 10000 < l1 + 10
Wend
While w1 / 1024 > 10.56
Wend
While w1 / 1024 > ss1
Wend
error messages test
Dim b1 As Byte
Dim b2(10) As Byte
Dim i As Byte
Dim s1 As String
i = 10 + s1(10 + i)
'i = 10 + b1(10 + i)
i = 10 + b2(10 + i)
'b1(10 + i) = 10
b2(10 + i) = 10 + b1
s1(10 + i) = f1(10 + b2(1) + b2)
'f1(10 + i) = f1(10 + b2(1) + b2)
End
Function f1(arg1 As Byte) As Byte
f1 = arg1
End Function
complex array index test #2
Dim arr(10) As Byte
Dim arr2(10) As Word
Dim w1 As Word
Dim b1 As Byte
w1 = myfunc1()
w1 = arr(b1)
w1 = arr(b1 + 1)
w1 = arr(b1 + 3) * arr(Sqr(w1 + 1)) + myfunc1 + myfunc2(1)
arr2(b1 + 3) = arr(b1)
'arr2(b1 + Sqr()) = arr(b1 + 1)
arr2(b1 + Sqr(w1 + 1)) = arr(b1 + 1)
arr2(b1 + 3) = arr(b1 + 3) * arr(Sqr(w1 + 1)) + myfunc1 + myfunc2(1)
End
Function myfunc1() As Byte
myfunc1 = 1
End Function
Function myfunc2(arg1 As Byte) As Byte
myfunc2 = 1 + arg1
End Function
complex array index test #1
Dim arr(10) As Byte
Dim w1 As Word
Dim b1 As Byte
'w1 = arr()
w1 = arr(b1)
w1 = arr(b1 + 1)
'w1 = 1 + arr()
'w1 = arr() + 1
'w1 = 1 +
w1 = arr(b1 + 3) * arr(Sqr(w1 + 1))
'w1 = b1 + Sqr()
'w1 = Sqr() + b1
w1 = myfunc1 + myfunc1()
w1 = myfunc1() + myfunc1
'w1 = myfunc2 + myfunc2()
'w1 = myfunc2() + myfunc2
w1 = arr(b1 + 3) * arr(Sqr(w1 + 1)) + myfunc1 + myfunc1()
'w1 = arr(b1 + 3) * arr(Sqr(w1 + 1)) + myfunc1 + myfunc2()
w1 = arr(b1 + 3) * arr(Sqr(w1 + 1)) + myfunc1 + myfunc2(1)
End
Function myfunc1() As Byte
myfunc1 = 1
End Function
Function myfunc2(arg1 As Byte) As Byte
myfunc2 = 1 + arg1
End Function
string as byte array test
Dim y1 As String
Dim i As Byte
y1(5) = "c"
y1(i - 5) = "c"
i = y1(3)
i = y1(i + 1)
y1(i + 2) = y1(i + 3)
complex expressions test
Dim b1 As Byte
Dim b2 As Byte
Dim w1 As Word
Dim w2 As Word
Dim s1 As String
Dim s2 As String
b1 = InStr(s1, b1)
b1 = InStr(s1, Asc(s2))
b1 = InStr(s1, " ")
b2 = InStr(s1, b1 + 3)
b1 = InStr(s1, b1 + 3)
b2 = InStr(s1, w1 + 3)
s1 = InStr(s1, b1)
w2 = InStr(s1, "a") + InStr(s1, "b")
b1 = ((1 + (b1 + 2)) + ((b1 + 3) + 4))
b1 = ((1 + (b2 + 2)) + ((b2 + 3) + 4))
b1 = ((1 + (b1 + 2)) + ((b1 + 300) + 4))
b1 = 100 + (1000000 + b1)
s1 = LeftStr(s2, " ")
s1 = LeftStr(s1, " ")
b1 = 3 + "a"
b1 = b1 * 10
b1 = b1 * 1000
's2 = 3 + "aa"
s1 = #b1 + #b2
s1 = #b1 + "a"
'b1 = LeftStr("aaa", 2)
s1 = "aa" + "bb"
s1 = s1 + "aa"
s1 = "aa" + s1
s1 = s2 + "aa"
s1 = "aa" + s2
s1 = "ABC" + LeftStr(s1, 2)
s1 = LeftStr(s1, 2) + "ABC"
s2 = "ABC" + LeftStr(s1, 2)
s2 = LeftStr(s1, 2) + "ABC"
s1 = LeftStr("aaa" + s1, 5)
s1 = LeftStr(s1 + "aaa", 5)
s1 = LeftStr("aaa" + s2, 5)
s1 = LeftStr(s2 + "aaa", 5)
b1 = Asc("ABC")
b1 = Asc("ABC" + s2)
Lcdinit
Lcdout "aaa", s2, "ABC" + LeftStr(s1, 2), #b1, Asc("ABC")
UART_Init 9600
UART_Write "aaa", s2, "ABC" + LeftStr(s1, 2), #b1, Asc("ABC")
procedure and function arguments test #3
Dim a1 As String
Dim a2 As String
a1 = "abcdefgh"
a2 = f1(f1("a", "c"), f1("b", "d"))
a2 = LeftStr(a1, 4) + f2(f2("k"))
End
Function f2(a1 As String) As String
f2 = a1 + a1
End Function
Function f1(a1 As String, a2 As String) As String
f1 = a1 + a2
End Function
procedure and function arguments test #2
Dim t As Byte
f1 = 100
t = f1
't = Sqr
t = f1 + 1
't = 1 + f1()
t = f1(1)
t = 1 + f1(1)
t = 1 + f1(f1(2))
t = 1 + f1(f1(2) + 1)
t = 1 + f1(1 + f1(2))
t = 1 + f1(f1(f1(5)))
't = f1(1) + f1(1, 1)
t = f1(4) + f1(5)
't = f2(f2(5, 5), f2(10))
t = f2(f2(5, 5), f2(10, 10))
t = f2(f2(6, 6) + 1, f2(11, 11))
t = f2(f2(7, 7), f2(12, 12) + 1)
t = f2(f2(8, 8) + 1, f2(13, 13) + 1)
End
Function f1(a1 As Byte) As Byte
'f1 = 1 + f1(1)
f1 = a1 + 1
f1 = f1 + f1
End Function
Function f2(a1 As Byte, a2 As Byte) As Byte
f2 = a1 + a2
End Function
procedure and function arguments test #1
Gosub sub1
Call p1(f1(10))
Call p1(f1(10) + 1)
Dim x1(5) As Byte
x1(4) = 20
Call p1(x1(4))
Call p1(x1(4) + 1)
Dim t1 As Word
Dim t As Byte
t1 = 10 * 2 + 10 + 100 * 10 + 10 * 2
t = 10 + 20
t = 10 * 2 + 10 + 100 * 10 + 10 * 2
t = 10 * 2 + 10 + 100 * 10 + 10 * 2000
t = 1 + (2 + (3 + (4 + f1(5))))
t = 1 + f1(1)
t = 1 + f1(f1(1))
t = 1 + f1(f1(f1(1)))
t = 1 + f1(t)
t = 1 + f1(x1(4))
t = 1 + f1(x1(4) + 1)
End
sub1:
Return
Proc p1(a1 As Byte)
End Proc
Function f1(a1 As Byte) As Byte
f1 = a1 + 1
End Function
user function calls test #2
Dim y1 As String
Dim y2 As String
y1 = "abcd"
y2 = f2("bcde")
y2 = f2(y1)
y2 = f2("c" + y1)
y2 = f2("c" + f2(y1))
y2 = f2("c" + f2(f2(y1)))
Dim i As Byte
i = 1
y2 = LeftStr(y1, i * 2 + 1)
y2 = LeftStr(y2, i * 2 + 1)
End
Function f2(a2 As String) As String
f2 = LeftStr(a2, 1)
End Function
user function calls test #1
Dim t As Byte
Dim x1 As Byte
Dim x2(5) As Byte
t = f1(1)
t = f1(x1)
t = f1(x2(2))
End
Function f1(a1 As Byte) As Byte
f1 = a1 + 1
End Function