From 754f2f1af268d8b2ca003aeb2d025f5e19f458b3 Mon Sep 17 00:00:00 2001 From: Vladimir Lebedev Date: Tue, 23 Jan 2024 21:53:29 +0700 Subject: [PATCH] Work on divs --- cp0.json | 1005 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 944 insertions(+), 61 deletions(-) diff --git a/cp0.json b/cp0.json index 79918fd..6e71cb9 100644 --- a/cp0.json +++ b/cp0.json @@ -4195,6 +4195,88 @@ } } }, + { + "mnemonic": "MODR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "MODR" + }, + "bytecode": { + "doc_opcode": "A909", + "tlb": "#A909", + "prefix": "A909", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - r", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "MODC", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "MODC" + }, + "bytecode": { + "doc_opcode": "A90A", + "tlb": "#A90A", + "prefix": "A90A", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - r", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, { "mnemonic": "DIVMOD", "doc": { @@ -4334,21 +4416,21 @@ } }, { - "mnemonic": "RSHIFTR_VAR", + "mnemonic": "ADDRSHIFTMOD", "doc": { "category": "arithm_div", "description": "", "gas": "26", - "fift": "RSHIFTR" + "fift": "ADDRSHIFTMOD" }, "bytecode": { - "doc_opcode": "A925", - "tlb": "#A925", - "prefix": "A925", + "doc_opcode": "A920", + "tlb": "#A920", + "prefix": "A920", "operands": [] }, "value_flow": { - "doc_stack": "x y - round(x/2^y)", + "doc_stack": "x w z - q=floor((x+w)/2^z) r=(x+w)-q*2^z", "inputs": { "stack": [ { @@ -4358,7 +4440,12 @@ }, { "type": "simple", - "name": "y", + "name": "w", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "z", "value_types": ["Integer"] } ] @@ -4367,7 +4454,12 @@ "stack": [ { "type": "simple", - "name": "result", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", "value_types": ["Integer"] } ] @@ -4375,21 +4467,21 @@ } }, { - "mnemonic": "RSHIFTC_VAR", + "mnemonic": "ADDRSHIFTMODR", "doc": { "category": "arithm_div", "description": "", - "gas": "34", - "fift": "RSHIFTC" + "gas": "26", + "fift": "ADDRSHIFTMODR" }, "bytecode": { - "doc_opcode": "A926", - "tlb": "#A926", - "prefix": "A926", + "doc_opcode": "A921", + "tlb": "#A921", + "prefix": "A921", "operands": [] }, "value_flow": { - "doc_stack": "x y - ceil(x/2^y)", + "doc_stack": "x w z - q=round((x+w)/2^z) r=(x+w)-q*2^z", "inputs": { "stack": [ { @@ -4399,7 +4491,12 @@ }, { "type": "simple", - "name": "y", + "name": "w", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "z", "value_types": ["Integer"] } ] @@ -4408,7 +4505,12 @@ "stack": [ { "type": "simple", - "name": "result", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", "value_types": ["Integer"] } ] @@ -4416,29 +4518,72 @@ } }, { - "mnemonic": "RSHIFTR", + "mnemonic": "ADDRSHIFTMODC", "doc": { "category": "arithm_div", "description": "", - "gas": "34", - "fift": "[tt+1] RSHIFTR#" + "gas": "26", + "fift": "ADDRSHIFTMODC" }, "bytecode": { - "doc_opcode": "A935tt", - "tlb": "#A935 tt:uint8", - "prefix": "A935", - "operands": [ - { - "name": "t", - "loader": "uint", - "loader_args": { - "size": 8 + "doc_opcode": "A922", + "tlb": "#A922", + "prefix": "A922", + "operands": [] + }, + "value_flow": { + "doc_stack": "x w z - q=ceil((x+w)/2^z) r=(x+w)-q*2^z", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "w", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "z", + "value_types": ["Integer"] } - } - ] + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTR_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "RSHIFTR" + }, + "bytecode": { + "doc_opcode": "A925", + "tlb": "#A925", + "prefix": "A925", + "operands": [] }, "value_flow": { - "doc_stack": "x y - round(x/2^(tt+1))", + "doc_stack": "x y - round(x/2^y)", "inputs": { "stack": [ { @@ -4465,29 +4610,21 @@ } }, { - "mnemonic": "RSHIFTC", + "mnemonic": "RSHIFTC_VAR", "doc": { "category": "arithm_div", "description": "", "gas": "34", - "fift": "[tt+1] RSHIFTC#" + "fift": "RSHIFTC" }, "bytecode": { - "doc_opcode": "A936tt", - "tlb": "#A936 tt:uint8", - "prefix": "A936", - "operands": [ - { - "name": "t", - "loader": "uint", - "loader_args": { - "size": 8 - } - } - ] + "doc_opcode": "A926", + "tlb": "#A926", + "prefix": "A926", + "operands": [] }, "value_flow": { - "doc_stack": "x y - ceil(x/2^(tt+1))", + "doc_stack": "x y - ceil(x/2^y)", "inputs": { "stack": [ { @@ -4514,35 +4651,73 @@ } }, { - "mnemonic": "MODPOW2", + "mnemonic": "MODPOW2_VAR", "doc": { "category": "arithm_div", "description": "", "gas": "26", - "fift": "[tt+1] MODPOW2#" + "fift": "MODPOW2" }, "bytecode": { - "doc_opcode": "A938tt", - "tlb": "#A938 tt:uint8", - "prefix": "A938", - "operands": [ - { - "name": "t", - "loader": "uint", - "loader_args": { - "size": 8 + "doc_opcode": "A928", + "tlb": "#A928", + "prefix": "A928", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - x mod 2^y", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] } - } - ] + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "MODPOW2R_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "MODPOW2R" + }, + "bytecode": { + "doc_opcode": "A929", + "tlb": "#A929", + "prefix": "A929", + "operands": [] }, "value_flow": { - "doc_stack": "x - x mod 2^(tt+1)", + "doc_stack": "x y - x mod 2^y", "inputs": { "stack": [ { "type": "simple", "name": "x", "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] } ] }, @@ -4557,6 +4732,714 @@ } } }, + { + "mnemonic": "MODPOW2C_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "MODPOW2C" + }, + "bytecode": { + "doc_opcode": "A92A", + "tlb": "#A92A", + "prefix": "A92A", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - x mod 2^y", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMOD_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "RSHIFTMOD" + }, + "bytecode": { + "doc_opcode": "A92C", + "tlb": "#A92C", + "prefix": "A92C", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - q=floor(x/2^y) r=x-q*2^y", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMODR_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "RSHIFTMODR" + }, + "bytecode": { + "doc_opcode": "A92D", + "tlb": "#A92D", + "prefix": "A92D", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - q=round(x/2^y) r=x-q*2^y", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMODC_VAR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "26", + "fift": "RSHIFTMODC" + }, + "bytecode": { + "doc_opcode": "A92E", + "tlb": "#A92E", + "prefix": "A92E", + "operands": [] + }, + "value_flow": { + "doc_stack": "x y - q=ceil(x/2^y) r=x-q*2^y", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "y", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "ADDRSHIFTMOD", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] ADDRSHIFT#MOD" + }, + "bytecode": { + "doc_opcode": "A930tt", + "tlb": "#A930 tt:uint8", + "prefix": "A930", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x w - q=floor((x+w)/2^(tt+1)) r=(x+w)-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "w", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "ADDRSHIFTRMOD", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] ADDRSHIFTR#MOD" + }, + "bytecode": { + "doc_opcode": "A931tt", + "tlb": "#A931 tt:uint8", + "prefix": "A931", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x w - q=round((x+w)/2^(tt+1)) r=(x+w)-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "w", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "ADDRSHIFTCMOD", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] ADDRSHIFTC#MOD" + }, + "bytecode": { + "doc_opcode": "A932tt", + "tlb": "#A932 tt:uint8", + "prefix": "A932", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x w - q=round((x+w)/2^(tt+1)) r=(x+w)-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "w", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] RSHIFTR#" + }, + "bytecode": { + "doc_opcode": "A935tt", + "tlb": "#A935 tt:uint8", + "prefix": "A935", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - round(x/2^(tt+1))", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTC", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] RSHIFTC#" + }, + "bytecode": { + "doc_opcode": "A936tt", + "tlb": "#A936 tt:uint8", + "prefix": "A936", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - ceil(x/2^(tt+1))", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "MODPOW2", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] MODPOW2#" + }, + "bytecode": { + "doc_opcode": "A938tt", + "tlb": "#A938 tt:uint8", + "prefix": "A938", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - x mod 2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "MODPOW2R", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] MODPOW2R#" + }, + "bytecode": { + "doc_opcode": "A939tt", + "tlb": "#A939 tt:uint8", + "prefix": "A939", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - x mod 2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "MODPOW2C", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] MODPOW2C#" + }, + "bytecode": { + "doc_opcode": "A93Att", + "tlb": "#A93A tt:uint8", + "prefix": "A93A", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - x mod 2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "result", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMOD", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] RSHIFTMOD#" + }, + "bytecode": { + "doc_opcode": "A93Ctt", + "tlb": "#A93C tt:uint8", + "prefix": "A93C", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - q=floor(x/2^(tt+1)) r=x-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMODR", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] RSHIFTMODR#" + }, + "bytecode": { + "doc_opcode": "A93Dtt", + "tlb": "#A93D tt:uint8", + "prefix": "A93D", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - q=round(x/2^(tt+1)) r=x-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, + { + "mnemonic": "RSHIFTMODC", + "doc": { + "category": "arithm_div", + "description": "", + "gas": "34", + "fift": "[tt+1] RSHIFTMODC#" + }, + "bytecode": { + "doc_opcode": "A93Ett", + "tlb": "#A93E tt:uint8", + "prefix": "A93E", + "operands": [ + { + "name": "t", + "loader": "uint", + "loader_args": { + "size": 8 + } + } + ] + }, + "value_flow": { + "doc_stack": "x - q=ceil(x/2^(tt+1)) r=x-q*2^(tt+1)", + "inputs": { + "stack": [ + { + "type": "simple", + "name": "x", + "value_types": ["Integer"] + } + ] + }, + "outputs": { + "stack": [ + { + "type": "simple", + "name": "q", + "value_types": ["Integer"] + }, + { + "type": "simple", + "name": "r", + "value_types": ["Integer"] + } + ] + } + } + }, { "mnemonic": "MULADDDIVMOD", "doc": {