[BITS 64]
;extern basic_call
;extern basic_fcall
[segment .text]
extern ExitProcess
extern basic_inf
extern basic_mod
extern basic_inf
extern basic_regfun
extern basic_ccall
extern basic_ncall
extern basic_create_array
extern basic_create_var
extern basic_array
extern basic_addr
extern basic_vstart
extern basic_astart
;extern basic_array2
extern basic_ret
extern basic_inc
extern basic_apop
extern basic_begin
extern basic_print
;extern basic_print2
extern basic_input
extern basic_nop
extern basic_add
extern basic_jmp
extern basic_jz
extern basic_je
extern basic_sub
extern basic_mul
extern basic_div
extern basic_lt
extern basic_gt
extern basic_lteq
extern basic_gteq
extern basic_neq
extern basic_eq
extern basic_and
extern basic_or
extern basic_xor
extern basic_not
extern basic_push
extern basic_ipush
extern basic_apush
extern basic_spush
;extern basic_push2
extern basic_pop
extern basic_concat
extern basic_uminus
extern basic_init
extern basic_fin
extern basic_import
extern basic_use
extern basic_l_val
extern basic_r_val

%macro pushaq 0
        push rdi
        push rsi
        push rbx
        push rdx
        push rax
        push rcx
        push r8
        push r9
        push r10
        push r11
        push r12
        push r13
        push r14
        push r15
%endmacro

%macro popaq 0
        push r15
        push r14
        push r13
        push r12
        push r11
        push r10
        push r9
        push r8
        push rcx
        push rax
        push rdx
        push rbx
        push rsi
        push rdi
%endmacro

%macro BASIC_ADDR 1
	mov rcx,%1
	call basic_addr
%endmacro

%macro BASIC_VSTART 2
	mov rdx,%2
	mov rcx,%1
	call basic_vstart
	
%endmacro

%macro BASIC_L_VAL 2
	mov rdx,%2
	mov rcx,%1
	call basic_l_val
%endmacro

%macro BASIC_R_VAL 2
	mov rdx,%2
	mov rcx,%1
	call basic_r_val
%endmacro

%macro BASIC_INIT 1
	mov rcx,%1
	call basic_init
%endmacro

%macro BASIC_START 0
	sub rsp,28h
%endmacro

%macro BASIC_IMPORT 1
	mov rcx,%1
	call basic_import
%endmacro

%macro BASIC_USE 2 
	mov rcx,%1
	call basic_use
%endmacro

%macro BASIC_APUSH 3
	mov r8,%3
	mov rdx,%2
	mov rcx,%1
	call basic_apush 
%endmacro 

%macro BASIC_SPUSH 1
	mov rcx,%1
	call basic_spush 
%endmacro 

%macro BASIC_IPUSH 1
	mov rcx,%1
	call basic_ipush 
%endmacro 

%macro BASIC_PUSH 1
	mov rcx,%1
	call basic_push 
%endmacro 

%macro BASIC_POP 1
        mov rcx,%1
	call basic_pop
%endmacro 

%macro BASIC_PRINT 1
	mov rcx,%1
	mov rax,0
	call basic_print
%endmacro

%macro BASIC_FIN 0
	call basic_fin
%endmacro

%macro BASIC_FCALL 1
	call basic_pop
	call %1
%endmacro

%macro BASIC_CALL 2
	mov rax,0
	call %2
%endmacro

%macro BASIC_REGFUN 2
	mov rdx,%2
	mov rcx,%1
	call basic_regfun
%endmacro

%macro BASIC_NCALL 2
	mov rdx,%2
	mov rcx,%1
	call basic_ncall
%endmacro

%macro BASIC_CCALL 1
	mov rcx,%1
	call basic_ccall
%endmacro

%macro BASIC_ASTART 2
	mov rdx,%2
	mov rcx,%1
	call basic_astart
%endmacro

%macro BASIC_CREATE_ARRAY 3
	mov r8,%3
	mov rdx,%2
	mov rcx,%1
	call basic_create_array
%endmacro

%macro BASIC_CREATE_VAR 3
	mov r8,%3
	mov rdx,%2
	mov rcx,%1
	call basic_create_var
%endmacro

%macro BASIC_ARRAY 2
	mov rdx,%2
	mov rcx,%1
	call basic_array
%endmacro

%macro BASIC_ARRAY2 0
	call basic_array2
%endmacro

%macro BASIC_EXIT 1
	mov rcx,%1
	call ExitProcess
%endmacro

%macro BASIC_RET2 1
	mov eax,%1
	leave
	ret
%endmacro

%macro BASIC_RET 0
	leave
	ret
%endmacro

%macro BASIC_PRINT2 0
	call basic_print2
%endmacro

%macro BASIC_INPUT 1
	mov rcx,%1
	call basic_input
%endmacro

%macro BASIC_NOP 0
	call basic_nop
%endmacro

%macro BASIC_ADD 0
	call basic_add
%endmacro

%macro BASIC_MOD 0
	call basic_mod
%endmacro

%macro BASIC_INF 0
	call basic_inf
%endmacro

%macro BASIC_JMP 1
	jmp %1
%endmacro

%macro BASIC_JZ 1
	call basic_jz
	cmp eax,1
	jz %1
%endmacro

%macro BASIC_JE 1
	call basic_je
	cmp eax,1
	je %1
%endmacro

%macro BASIC_SUB 0
	call basic_sub
%endmacro

%macro BASIC_MUL 0
	call basic_mul
%endmacro

%macro BASIC_DIV 0
	call basic_div
%endmacro

%macro BASIC_LT 0
	call basic_lt
%endmacro

%macro BASIC_GT 0
	call basic_gt
%endmacro

%macro BASIC_LTEQ 0
	call basic_lteq
%endmacro

%macro BASIC_GTEQ 0
	call basic_gteq
%endmacro

%macro BASIC_NEQ 0
	call basic_neq
%endmacro

%macro BASIC_EQ 0
	call basic_eq
%endmacro

%macro BASIC_AND 0
	call basic_and
%endmacro

%macro BASIC_OR 0
	call basic_or
%endmacro

%macro BASIC_XOR 0
	call basic_xor
%endmacro

%macro BASIC_NOT 0
	call basic_not
%endmacro

%macro BASIC_PUSH2 1
	mov rcx,%1
	call basic_push2
%endmacro

%macro BASIC_CONCAT 0
	call basic_concat
%endmacro

%macro BASIC_UMINUS 0
	call basic_uminus
%endmacro

%macro BASIC_APOP 3
	mov r8,%3
	mov rdx,%2
	mov rcx,%1
	call basic_apop
%endmacro

%macro BASIC_INC 3
	mov r8,%3
	mov rdx,%2
	mov rcx,%1
	call basic_inc
%endmacro

%macro BASIC_BEGIN 0
	push rbp
	mov rbp,rsp
	sub rsp,40
	call basic_begin
%endmacro

%macro BASIC_END 0
	leave
	ret
%endmacro
