+
+
+unsigned
+CParser::output_codes(ZMemblock *zmem_code)
+{
+ unsigned code_size = 0;
+ map<string, Function>::iterator function_iter = m_functions.begin();
+ unsigned address = 0;
+
+ unsigned calls_index = 0;
+ for (int i = 0; i < get_number_of_instructions(); ++i)
+ {
+ ////if ( parser.)
+ //if (function_iter != m_functions.end())
+ //{
+ // if (function_iter->second.index == i)
+ // {
+ // /// write few bytes for alignment purposes
+ // for (int j = 0; j < function_iter->second.address - address; ++j)
+ // zmem_putbyte(zmem_code, 0);
+ // }
+ //}
+
+ // write actual addresses to calls
+ if (g_codes[i]->contents[0] == Opcode_ICALL1)
+ {
+ //vector<unsigned>::iterator iter = find(m_function_addresses.begin(), m_function_addresses.end(), address);
+ unsigned target_addr = m_functions.find(m_calls[calls_index])->second.address >> 2;
+ g_codes[i]->contents[1] = (target_addr >> 8) & 255;
+ g_codes[i]->contents[2] = target_addr & 255;
+ ++calls_index;
+ }
+
+
+ for (int j = 0; j < g_codes[i]->used_size; ++j)
+ {
+ zmem_putbyte(zmem_code, g_codes[i]->contents[j]);
+ ++code_size;
+ }
+ }
+
+ return code_size;
+}
\ No newline at end of file