Author Topic: #show  (Read 575 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
#show
« on: August 30, 2020, 03:37:09 AM »
#show reveals the inner workings of the o2 compiler: expanding macros, creating intermediate code then expanding to assembler.

You can see exactly what your code produces.

It can be used on a single line of code:
Code: [Select]
int a,b,c
#show a=b+c

or several lines:
Code: [Select]
#show {
function f(int a,b,c) as int
  return a+b*c
end function
}

The output can be saved to a file instead of a messagebox:
Code: [Select]
macro iif int(a,b,c,d)
if b
  a=c
else
  a=d
endif
end macro

#show "t.txt" {
int a,b,c,d
a=iif(a==b,c,d)
}
Resulting text:
Code: [Select]
{
'_13
int a,b,c,d
'_14
a=iif(a==b,c,d)
'_15
}

>>>>

if a==b
  1=c
else
  1=d
endif
_code2


>>>>

'_13
|va a as int == [ebx+4096]
|va b as int == [ebx+4100]
|va c as int == [ebx+4104]
|va d as int == [ebx+4108]
'_14
|va 1 as int == [ebx+4112]
|op 1 4 [ebx+4096]
|op 85 4 eax,[ebx+4100]
 fwd _end_cnd1
|op 1 4 [ebx+4104]
|op 2 4 [ebx+4112]
jmp fwd _end_if1
._end_cnd1
|op 1 4 [ebx+4108]
|op 2 4 [ebx+4112]
._end_cnd1
._end_if1
|op 1 4 [ebx+4112]
|op 2 4 [ebx+4096]
'_15

>>>>

'_13
'_14
mov eax,[ebx+4096]
cmp eax,[ebx+4100]
jnz  fwd _end_cnd1
mov eax,[ebx+4104]
mov [ebx+4112],eax
jmp fwd _end_if1
._end_cnd1
mov eax,[ebx+4108]
mov [ebx+4112],eax
._end_cnd1
._end_if1
mov eax,[ebx+4112]
mov [ebx+4096],eax
'_15

Alex_Longard

  • Guest
Re: #show
« Reply #1 on: August 30, 2020, 05:23:20 AM »
Thanks Charles!