2010-03-22 07:49:57 +08:00
|
|
|
/*
|
2021-03-08 18:19:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2010-03-22 07:49:57 +08:00
|
|
|
*
|
2018-10-14 19:28:18 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-03-22 07:49:57 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2010-03-22 Bernard first version
|
|
|
|
*/
|
2009-07-03 06:48:23 +08:00
|
|
|
#include "finsh_ops.h"
|
|
|
|
#include "finsh_vm.h"
|
|
|
|
|
|
|
|
#define OP_BIN_BYTE(x) do {\
|
|
|
|
(finsh_sp - 2)->char_value = (finsh_sp - 2)->char_value x (finsh_sp - 1)->char_value; \
|
|
|
|
finsh_sp--; \
|
|
|
|
}while (0)
|
|
|
|
|
|
|
|
#define OP_BIN_WORD(x) do {\
|
|
|
|
(finsh_sp - 2)->short_value = (finsh_sp - 2)->short_value x (finsh_sp - 1)->short_value; \
|
|
|
|
finsh_sp--; \
|
|
|
|
}while (0)
|
|
|
|
|
|
|
|
#define OP_BIN_DWORD(x) do {\
|
|
|
|
(finsh_sp - 2)->long_value = (finsh_sp - 2)->long_value x (finsh_sp - 1)->long_value; \
|
|
|
|
finsh_sp--; \
|
|
|
|
}while (0)
|
|
|
|
|
|
|
|
/* --- noop --- */
|
|
|
|
void OP_no_op()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
/* none */
|
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- add --- */
|
|
|
|
void OP_add_byte()
|
|
|
|
{
|
|
|
|
OP_BIN_BYTE(+);
|
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_add_word()
|
|
|
|
{
|
|
|
|
OP_BIN_WORD(+);
|
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_add_dword()
|
|
|
|
{
|
|
|
|
OP_BIN_DWORD(+);
|
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- sub --- */
|
|
|
|
void OP_sub_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(-);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_sub_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(-);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_sub_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(-);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- div --- */
|
|
|
|
void OP_div_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(/);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_div_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(/);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_div_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(/);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- mod --- */
|
|
|
|
void OP_mod_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(%);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_mod_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(%);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_mod_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(%);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- mul --- */
|
|
|
|
void OP_mul_byte()
|
|
|
|
{
|
|
|
|
OP_BIN_BYTE(*);
|
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_mul_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(*);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_mul_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(*);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- and --- */
|
|
|
|
void OP_and_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(&);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_and_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(&);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_and_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(&);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- or --- */
|
|
|
|
void OP_or_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(|);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_or_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(|);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_or_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(|);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- xor --- */
|
|
|
|
void OP_xor_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(^);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_xor_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(^);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_xor_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(^);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- bw --- */
|
|
|
|
void OP_bw_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
(finsh_sp - 1)->char_value = ~ ((finsh_sp - 1)->char_value);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_bw_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
(finsh_sp - 1)->short_value = ~ ((finsh_sp - 1)->short_value);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_bw_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
(finsh_sp - 1)->long_value = ~ ((finsh_sp - 1)->long_value);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- shl --- */
|
|
|
|
void OP_shl_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(<<);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_shl_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(<<);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_shl_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(<<);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- shr --- */
|
|
|
|
void OP_shr_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_BYTE(>>);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_shr_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_WORD(>>);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_shr_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
OP_BIN_DWORD(>>);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- ld --- */
|
|
|
|
void OP_ld_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->char_value = *finsh_pc;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp++;
|
|
|
|
finsh_pc++;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->short_value = FINSH_GET16(finsh_pc);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp ++;
|
|
|
|
finsh_pc += 2;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->long_value = FINSH_GET32(finsh_pc);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp ++;
|
|
|
|
finsh_pc += 4;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
char* c;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
c = (char*) (FINSH_GET32(finsh_pc));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->char_value = *c;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp ++;
|
|
|
|
finsh_pc += 4;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_byte_stack()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
char* c;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
c = (char *)(finsh_sp - 1)->long_value;
|
|
|
|
(finsh_sp - 1)->char_value = *c;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
short* s;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
s = (short*) (FINSH_GET32(finsh_pc));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->short_value = *s;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp ++;
|
|
|
|
finsh_pc += 4;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_word_stack()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
short* s;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
s = (short *)(finsh_sp - 1)->long_value;
|
|
|
|
(finsh_sp - 1)->short_value = *s;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
long* l;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
l = (long*) (FINSH_GET32(finsh_pc));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp->long_value = *l;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp ++;
|
|
|
|
finsh_pc += 4;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OP_ld_value_dword_stack()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
long* l;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
l = (long *)(finsh_sp - 1)->long_value;
|
|
|
|
(finsh_sp - 1)->long_value = *l;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- st --- */
|
|
|
|
/*
|
|
|
|
* 2006-4-16 bernard
|
|
|
|
* fixed the sp move bug
|
|
|
|
*/
|
|
|
|
void OP_st_byte()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
*(char*)((finsh_sp - 2)->long_value) = (finsh_sp - 1)->char_value;
|
|
|
|
finsh_sp --;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2006-4-16 bernard
|
|
|
|
* fixed the sp move bug
|
|
|
|
*/
|
|
|
|
void OP_st_word()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
*(short*)((finsh_sp - 2)->long_value) = (finsh_sp - 1)->short_value;
|
|
|
|
finsh_sp --;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2006-4-16 bernard
|
|
|
|
* fixed the sp move bug
|
|
|
|
*/
|
|
|
|
void OP_st_dword()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
*(long*)((finsh_sp - 2)->long_value) = (finsh_sp - 1)->long_value;
|
|
|
|
finsh_sp --;
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-03-01 21:01:20 +08:00
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- pop --- */
|
|
|
|
void OP_pop()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
finsh_sp --;
|
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --- call --- */
|
|
|
|
void OP_call()
|
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
/* the max number of arg*/
|
|
|
|
unsigned long parameterv[16];
|
|
|
|
unsigned int parameters, i;
|
|
|
|
|
|
|
|
typedef unsigned long var_t;
|
|
|
|
typedef var_t (*op_func)();
|
|
|
|
op_func f;
|
|
|
|
var_t r;
|
|
|
|
|
|
|
|
parameters = *finsh_pc ++;
|
|
|
|
|
|
|
|
i = 0; finsh_sp --;
|
|
|
|
while (i < parameters)
|
|
|
|
{
|
|
|
|
parameterv[parameters - 1 - i] = finsh_sp->long_value;
|
|
|
|
finsh_sp --;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = (op_func)(finsh_sp->long_value);
|
|
|
|
switch (parameters)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
r = f(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
r = f(parameterv[0]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
r = f(parameterv[0], parameterv[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10], parameterv[11]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10], parameterv[11],
|
|
|
|
parameterv[12]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10], parameterv[11],
|
|
|
|
parameterv[12], parameterv[13]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10], parameterv[11],
|
|
|
|
parameterv[12], parameterv[13], parameterv[14]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
r = f(parameterv[0], parameterv[1], parameterv[2], parameterv[3],
|
|
|
|
parameterv[4], parameterv[5], parameterv[6], parameterv[7],
|
|
|
|
parameterv[8], parameterv[9], parameterv[10], parameterv[11],
|
|
|
|
parameterv[12], parameterv[13], parameterv[14], parameterv[15]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
r = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
finsh_sp->long_value = r;
|
|
|
|
finsh_sp ++;
|
|
|
|
|
|
|
|
return ;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
2010-03-26 17:34:26 +08:00
|
|
|
const op_func op_table[] =
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2018-03-01 21:01:20 +08:00
|
|
|
/* 00 */ OP_no_op,
|
|
|
|
/* 01 */ OP_add_byte,
|
|
|
|
/* 02 */ OP_add_word,
|
|
|
|
/* 03 */ OP_add_dword,
|
|
|
|
/* 04 */ OP_sub_byte,
|
|
|
|
/* 05 */ OP_sub_word,
|
|
|
|
/* 06 */ OP_sub_dword,
|
|
|
|
/* 07 */ OP_div_byte,
|
|
|
|
/* 08 */ OP_div_word,
|
|
|
|
/* 09 */ OP_div_dword,
|
|
|
|
/* 10 */ OP_mod_byte,
|
|
|
|
/* 11 */ OP_mod_word,
|
|
|
|
/* 12 */ OP_mod_dword,
|
|
|
|
/* 13 */ OP_mul_byte,
|
|
|
|
/* 14 */ OP_mul_word,
|
|
|
|
/* 15 */ OP_mul_dword,
|
|
|
|
/* 16 */ OP_and_byte,
|
|
|
|
/* 17 */ OP_and_word,
|
|
|
|
/* 18 */ OP_and_dword,
|
|
|
|
/* 19 */ OP_or_byte,
|
|
|
|
/* 20 */ OP_or_word,
|
|
|
|
/* 21 */ OP_or_dword,
|
|
|
|
/* 22 */ OP_xor_byte,
|
|
|
|
/* 23 */ OP_xor_word,
|
|
|
|
/* 24 */ OP_xor_dword,
|
|
|
|
/* 25 */ OP_bw_byte,
|
|
|
|
/* 26 */ OP_bw_word,
|
|
|
|
/* 27 */ OP_bw_dword,
|
|
|
|
/* 28 */ OP_shl_byte,
|
|
|
|
/* 29 */ OP_shl_word,
|
|
|
|
/* 30 */ OP_shl_dword,
|
|
|
|
/* 31 */ OP_shr_byte,
|
|
|
|
/* 32 */ OP_shr_word,
|
|
|
|
/* 33 */ OP_shr_dword,
|
|
|
|
/* 34 */ OP_ld_byte,
|
|
|
|
/* 35 */ OP_ld_word,
|
|
|
|
/* 36 */ OP_ld_dword,
|
|
|
|
/* 37 */ OP_ld_value_byte,
|
|
|
|
/* 38 */ OP_ld_value_word,
|
|
|
|
/* 39 */ OP_ld_value_dword,
|
|
|
|
/* 40 */ OP_st_byte,
|
|
|
|
/* 41 */ OP_st_word,
|
|
|
|
/* 42 */ OP_st_dword,
|
|
|
|
/* 43 */ OP_pop,
|
|
|
|
/* 44 */ OP_call,
|
|
|
|
/* 45 */ OP_ld_value_byte_stack,
|
|
|
|
/* 46 */ OP_ld_value_word_stack,
|
|
|
|
/* 47 */ OP_ld_value_dword_stack,
|
|
|
|
NULL
|
2009-07-03 06:48:23 +08:00
|
|
|
};
|