Skip to content

Commit

Permalink
MOD test assembler asm files
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyuanyang-uu committed Dec 1, 2023
1 parent e0f266c commit 78d031e
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 82 deletions.
22 changes: 11 additions & 11 deletions assembler/src/test_data_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ mod tests {
);
}

#[test]
fn generate_sccall_test() {
generate_from_file(
"sccall/caller.json".to_string(),
"sccall/caller.json".to_string(),
);
generate_from_file(
"sccall/callee.json".to_string(),
"sccall/callee.json".to_string(),
);
}
// #[test]
// fn generate_sccall_test() {
// generate_from_file(
// "sccall/caller.json".to_string(),
// "sccall/caller.json".to_string(),
// );
// generate_from_file(
// "sccall/callee.json".to_string(),
// "sccall/callee.json".to_string(),
// );
// }

#[test]
fn generate_store_u32() {
Expand Down
85 changes: 85 additions & 0 deletions assembler/test_data/asm/ptr_call.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"program": "chain_id:\n.LBL8_0:\n add r9 r9 2\n mov r0 7\n mstore [r9,-1] r0\n mload r0 [r9,-1]\n add r1 r9 -2\n mov r2 0\n tload r1 r2 r0\n mload r0 [r9,-2]\n add r9 r9 -2\n ret\nexe_address:\n.LBL9_0:\n add r9 r9 6\n mov r0 8\n mstore [r9,-1] r0\n mload r1 [r9,-1]\n.PROPHET9_0:\n mov r0 psp\n mload r0 [r0]\n mstore [r9,-6] r0\n mload r0 [r9,-6]\n mload r1 [r9,-1]\n mov r2 1\n tload r0 r2 r1\n mload r0 [r9,-6]\n mload r0 [r0]\n mstore [r9,-5] r0\n mload r0 [r9,-6]\n mload r0 [r0,+1]\n mstore [r9,-4] r0\n mload r0 [r9,-6]\n mload r0 [r0,+2]\n mstore [r9,-3] r0\n mload r0 [r9,-6]\n mload r0 [r0,+3]\n mstore [r9,-2] r0\n mload r0 [r9,-6]\n add r9 r9 -6\n ret\nbar:\n.LBL10_0:\n add r9 r9 1\n mov r0 r1\n mstore [r9,-1] r0\n mload r0 [r9,-1]\n mov r1 3\n mstore [r0,+0] r1\n mov r0 5\n add r9 r9 -1\n ret\nsum1:\n.LBL11_0:\n add r9 r9 6\n mstore [r9,-2] r9\n mov r0 11\n mstore [r9,-3] r0\n add r1 r9 -3\n call bar\n mstore [r9,-4] r0\n mload r0 [r9,-3]\n add r9 r9 -6\n ret\nmain:\n.LBL12_0:\n add r9 r9 10\n mstore [r9,-2] r9\n mov r0 14\n mstore [r9,-3] r0\n mov r0 1\n mstore [r9,-8] r0\n mload r0 [r9,-3]\n mstore [r9,-5] r0\n mload r1 [r9,-5]\n.PROPHET12_0:\n mov r0 psp\n mload r0 [r0]\n mstore [r9,-6] r0\n mload r0 [r9,-6]\n mload r1 [r9,-5]\n mov r3 0\n not r1 r1\n add r1 r1 1\n add r1 r3 r1\n add r0 r0 r1\n mstore [r9,-7] r0\n mload r0 [r9,-7]\n mload r1 [r9,-5]\n mov r3 1\n tload r0 r3 r1\n mload r0 [r9,-7]\n mload r0 [r0]\n mstore [r9,-5] r0\n mload r0 [r9,-7]\n add r0 r0 1\n mstore [r9,-7] r0\n mload r0 [r9,-7]\n mload r0 [r0]\n mstore [r9,-4] r0\n mload r0 [r9,-5]\n mload r1 [r9,-3]\n add r2 r0 r1\n mstore [r9,-5] r2\n mload r1 [r9,-5]\n.PROPHET12_1:\n mov r0 psp\n mload r0 [r0]\n mstore [r9,-6] r0\n mload r0 [r9,-6]\n mload r1 [r9,-5]\n mov r2 0\n not r1 r1\n add r1 r1 1\n add r1 r2 r1\n add r0 r0 r1\n mstore [r9,-7] r0\n mload r0 [r9,-7]\n mload r1 [r9,-5]\n mov r2 1\n tload r0 r2 r1\n mload r0 [r9,-4]\n eq r1 r0 2657046596\n cjmp r1 .LBL12_1\n jmp .LBL12_2\n.LBL12_1:\n call sum1\n mov r2 r0\n mov r1 2\n.PROPHET12_2:\n mov r0 psp\n mload r0 [r0]\n mov r1 1\n mstore [r0,-1] r1\n mstore [r0,-2] r2\n add r0 r0 -2\n tstore r0 2\n jmp .LBL12_3\n.LBL12_2:\n jmp .LBL12_3\n.LBL12_3:\n mov r0 0\n add r9 r9 -10\n end\n",
"prophets": [
{
"label": ".PROPHET9_0",
"code": "%{\n entry() {\n cid.addr = malloc(cid.len);\n }\n%}",
"inputs": [
{
"name": "cid.len",
"length": 1,
"is_ref": false,
"is_input_output": false
}
],
"outputs": [
{
"name": "cid.addr",
"length": 1,
"is_ref": false,
"is_input_output": false
}
]
},
{
"label": ".PROPHET12_0",
"code": "%{\n entry() {\n cid.addr = malloc(cid.len);\n }\n%}",
"inputs": [
{
"name": "cid.len",
"length": 1,
"is_ref": false,
"is_input_output": false
}
],
"outputs": [
{
"name": "cid.addr",
"length": 1,
"is_ref": false,
"is_input_output": false
}
]
},
{
"label": ".PROPHET12_1",
"code": "%{\n entry() {\n cid.addr = malloc(cid.len);\n }\n%}",
"inputs": [
{
"name": "cid.len",
"length": 1,
"is_ref": false,
"is_input_output": false
}
],
"outputs": [
{
"name": "cid.addr",
"length": 1,
"is_ref": false,
"is_input_output": false
}
]
},
{
"label": ".PROPHET12_2",
"code": "%{\n entry() {\n cid.addr = malloc(cid.len);\n }\n%}",
"inputs": [
{
"name": "cid.len",
"length": 1,
"is_ref": false,
"is_input_output": false
}
],
"outputs": [
{
"name": "cid.addr",
"length": 1,
"is_ref": false,
"is_input_output": false
}
]
}
]
}
71 changes: 0 additions & 71 deletions assembler/test_data/asm/sqrt.json

This file was deleted.

0 comments on commit 78d031e

Please sign in to comment.