Machine code: Difference between revisions
Content added Content deleted
(Added PicoLisp) |
m (added pure ilASM example) |
||
Line 290: | Line 290: | ||
integer res |
integer res |
||
#ilASM{ mov eax,[mem] |
#ilASM{ mov eax,[mem] |
||
call :%pLoadMint -- (in case mem>#3FFFFFFF |
call :%pLoadMint -- eax:=(int32)eax, in case mem>#3FFFFFFF |
||
push 12 |
push 12 |
||
push 7 |
push 7 |
||
Line 298: | Line 298: | ||
?res |
?res |
||
free(mem)</lang> |
free(mem)</lang> |
||
Better yet, albeit deviating somewhat from the task (and this runs on both 32 and 64 bit): |
|||
<lang Phix>integer res |
|||
#ilASM{ jmp @f |
|||
::add |
|||
[32] |
|||
mov eax,[esp+4] |
|||
add eax,[esp+8] |
|||
[64] |
|||
mov rax,[rsp+8] |
|||
add rax,[rsp+16] |
|||
[] |
|||
ret |
|||
@@: |
|||
push 12 |
|||
push 7 |
|||
call :add |
|||
[32] |
|||
add esp,8 |
|||
mov [res],eax |
|||
[64] |
|||
add rsp,16 |
|||
mov [res],rax |
|||
[] |
|||
} |
|||
?res</lang> |
|||
All three cases output 19 |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |