Lhogho  0.0.028
 All Data Structures Files Functions Variables Typedefs Macros Pages
asm.h
Go to the documentation of this file.
1 //
2 // Project: Lhogho
3 // File: asm.h
4 //
5 // Copyright (C) 2007 P.Boytchev
6 //
7 // Revision history:
8 // 2007-06-19 - File created
9 // 2011-10-14 - Support for RUNMACRO
10 // 2012-01-02 - Command-line options are translatable
11 //
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 //
27 
28 
29 #ifndef LHOGHO_ASM_H
30 #define LHOGHO_ASM_H
31 
32 
33 
34 #ifdef ADVANCED
35 
36 // terminal coloring and disassembly are
37 // available only in ADVANCED mode
38 
39 //#define TERM_INSTR outter(TEXT("\033[0m\033[1m"),-1) ///< instructions
40 //#define TERM_INFO outter(TEXT("\033[0m\033[2;32m"),-1) ///< infos
41 //#define TERM_REMARK outter(TEXT("\033[2;30m"),-1) ///< remarks
42 #define TERM_INSTR
43 #define TERM_INFO
44 #define TERM_REMARK
45 
46 #ifdef UNICODE_CHARS
47  #define INSTR(format,...) disasm(ctx,1,L##format,##__VA_ARGS__)
48  #define INFO(format,...) disasm(ctx,2,L##format,##__VA_ARGS__)
49  #define REM(format,...) disasm(ctx,3,L##format,##__VA_ARGS__)
50  #define LABEL(format,...) disasm(ctx,4,L##format,##__VA_ARGS__)
51 #else
52  #define INSTR(format,...) disasm(ctx,1,format,##__VA_ARGS__)
53  #define INFO(format,...) disasm(ctx,2,format,##__VA_ARGS__)
54  #define REM(format,...) disasm(ctx,3,format,##__VA_ARGS__)
55  #define LABEL(format,...) disasm(ctx,4,format,##__VA_ARGS__)
56 #endif
57 
58 extern void disasm( context_t* ctx, int mode, chars_t format, ... );
59 #endif //ADVANCED
60 
61 
62 #ifndef ADVANCED
63  #define INSTR(format,...)
64  #define INFO(format,...)
65  #define REM(format,...)
66  #define LABEL(format,...)
67 #endif //if ADVANCED is undefined
68 
69 #define ASM (OPTION_ASSEMBLER && ctx->generate)
70 
71 extern void asm_label( context_t* ctx, chars_t name );
72 extern void asm_prologue( context_t* ctx, atom_t func, int check );
73 extern void asm_epilogue( context_t* ctx, atom_t func, int is_macro );
74 extern void asm_preepilogue( context_t* ctx );
75 extern void asm_external_function( context_t* ctx, atom_t func );
76 extern void asm_internal_function( context_t* ctx, int static_link, atom_t func );
77 extern void asm_push_atom( context_t* ctx, atom_t atom );
78 extern void asm_call_atom( context_t* ctx, atom_t atom, int params );
79 extern void asm_pop_atom( context_t* ctx );
80 extern void asm_pop_result( context_t* ctx );
81 extern void asm_result_func( context_t* ctx, atom_t source );
82 extern void asm_result_unknown( context_t* ctx, atom_t source );
83 extern void asm_result_proc( context_t* ctx, atom_t source );
84 extern void asm_push_result( context_t* ctx );
85 extern void asm_pop_dummy( context_t* ctx );
86 extern void asm_make_direct( context_t* ctx, atom_t var, atom_t source );
87 extern void asm_reference( context_t* ctx, atom_t var, atom_t source, int check );
88 extern void asm_push_value_addr( context_t* ctx, atom_t var );
89 extern void asm_empty_body( context_t* ctx );
90 extern void asm_output( context_t* ctx, atom_t source, int true_output );
91 extern void asm_stop( context_t* ctx, atom_t source );
92 extern void asm_boolean( context_t* ctx, atom_t source );
93 extern int asm_if_prologue( context_t* ctx );
94 extern int asm_if_epilogue( context_t* ctx );
95 extern void asm_fix( context_t* ctx, int addr );
96 extern void asm_dump_source( context_t* ctx, atom_t source );
97 
98 extern int asm_repeat_prologue_const( context_t* ctx, int cnt );
99 extern int asm_repeat_prologue_expr( context_t* ctx, atom_t source, int* branch2 );
100 extern void asm_repeat_epilogue( context_t* ctx, int branch, int branch2 );
101 
102 extern int asm_for_prologue( context_t* ctx, atom_t step_var, atom_t source, int* branch2 );
103 extern void asm_for_epilogue( context_t* ctx, int branch, int branch2 );
104 
105 extern int asm_forever_prologue( context_t* ctx );
106 extern void asm_forever_epilogue( context_t* ctx, int branch );
107 
108 extern int asm_while_prologue( context_t* ctx, int is_while, int is_do );
109 extern int asm_while_inlogue( context_t* ctx, atom_t source, int is_while );
110 extern void asm_while_epilogue( context_t* ctx, int loop_branch, int skip_branch, int is_while );
111 
112 extern int asm_catch_prologue( context_t* ctx );
113 extern void asm_catch_epilogue( context_t* ctx );
114 
115 extern void asm_push_mode( context_t* ctx, int mode );
116 
117 extern void asm_push_frame( context_t* ctx );
118 extern void asm_pop_frame( context_t* ctx );
119 
120 extern void asm_runtime_reference( context_t* ctx );
121 extern void asm_adjust_result( context_t* ctx );
122 
123 extern void asm_goto( context_t* ctx, atom_t tag );
124 extern void asm_goto_prologue( context_t* ctx, atom_t source );
125 extern void asm_goto_epilogue( context_t* ctx, atom_t source );
126 extern int asm_test_prologue( context_t* ctx, int criteria );
127 
128 extern void asm_run_epilogue( context_t* ctx );
129 extern void asm_runresult_epilogue( context_t* ctx );
130 
131 extern void asm_int_3( context_t* ctx );
132 extern void asm_set_output_status( context_t* ctx, int n );
133 extern void asm_nop( context_t* ctx );
134 
135 //extern void asm_enter_if_output( context_t* ctx );
136 //extern void asm_exit_if_output( context_t* ctx );
137 
138 #endif //LHOGHO_ASM_H

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Wed Jul 10 2013