variable = expressionFUNCTION = expressionpb_cg_emit_store_numeric_expr (pb_codegen.c:2251), pb_cg_emit_stmt (pb_codegen.c:~6630)The assignment operator (=) stores the result of an expression into a variable. The compiler handles different variable types (LOCAL, STATIC, GLOBAL, BYREF parameters, TYPE fields, and array elements) and automatically generates the correct addressing mode for each. For functions, FUNCTION = expression sets the return value, which is loaded into RAX (integer), XMM0 (float), or RAX:RDX (string) during the function epilogue.
| Parameter | Description |
|---|---|
variable | The target variable name. Can be a LOCAL, STATIC, GLOBAL, BYREF parameter, TYPE field, or array element. |
expression | Any numeric, string, or pointer expression whose result is stored into the variable. |
FUNCTION = value | Sets the return value of a FUNCTION. The value is stored in a dedicated return slot in the stack frame and loaded during the epilogue. |
FUNCTION PBMAIN() AS LONG
LOCAL x AS LONG
LOCAL y AS LONG
LOCAL name AS STRING
' Simple assignment
x = 10
y = x * 2 + 5
' String assignment
name = "Hello"
' Function return via FUNCTION =
FUNCTION = x + y
END FUNCTION
variable = expressionpb_cg_emit_store_numeric_expr (pb_codegen.c:2251); Evaluate expression -> RAX mov [rbp - offset], rax ; store to stack frame
mov r11, [rbp - offset] ; load pointer from param slot mov [r11], rax ; store through pointer
mov [label], rax ; direct static storage
mov [rbp - written_offset], r11 ; save field address mov r11, [rbp - written_offset] mov [r11], rax ; store value at field address
; pb_cg_emit_array_address -> r11 = element address mov [rbp - written_offset], r11 mov r11, [rbp - written_offset] mov [r11], rax ; a(i) = expr
FUNCTION = expressionpb_cg_emit_stmt (pb_codegen.c:~6630); Evaluate expression -> RAX mov [rbp - return_offset], rax ; store to return slot ; On function exit: mov rax, [rbp - return_offset] ; load return value add rsp, frame_size pop rbp ret
movsd [rbp - return_offset], xmm0 ; store float to return slot ; On function exit: movsd xmm0, [rbp - return_offset] ; load to XMM0 (Win64 FP return) add rsp, frame_size pop rbp ret
lea r11, [rbp - return_offset] ; descriptor address ; pb_cg_emit_string_expr_to_descriptor (complex string copy) ; On exit: mov rax, [rbp - return_offset] ; string data pointer mov rdx, [rbp - return_length_offset] ; string length add rsp, frame_size pop rbp ret
mov rcx, [rbp - return_offset] ; exit code call [__imp_ExitProcess] xor rax, rax ; unreachable add rsp, frame_size pop rbp ret