Example of concatenating strings:
Code: Select all
decl func Title():str;
const C = "SharpBASIC is here!";
dim s:str;
main do
s = "Hello " + "world" + ", " + Title();
print(s);
end;
func Title():str
do
Title = C;
end;
generated asm output of the above code:
Code: Select all
_start:
call _sb_create_strdesc
mov [_I85], eax
mov ebx, _C5
call _sb_creassign_constr
mov esi, eax
mov ebx, _C6
call _sb_concat_constr
mov esi, eax
mov ebx, _C7
call _sb_concat_constr
mov esi, eax
call _I83
call _sb_dstref
call _sb_concat_str
mov esi, eax
mov edi, dword [_I85]
call _sb_assign_str
mov [_I85], eax
mov eax, dword [_I85]
call _sb_load_strdesc
call _sb_printl
mov eax, dword [_I85]
call _sb_testd_strefdd
_end:
mov ebx, 0
mov eax, 1
int 80h
_I83:
push ebp
mov ebp, esp
sub esp, 4
call _sb_create_strdesc
mov dword [ebp - 4], eax
mov ebx, _C4
mov eax, dword [ebp - 4]
call _sb_assign_constr
mov [ebp - 4], eax
._L0:
mov eax, dword [ebp - 4]
mov esp, ebp
pop ebp
ret