Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"created_at_ms":1779385820882,"model":"nvidia/nemotron-3-super-120b-a12b:free","session_id":"session-1779385820883-0","type":"session_meta","updated_at_ms":1779385820882,"version":1,"workspace_root":"/home/pbk/school/P10-Master/compiler"}
{"text":"using the language trivilang (compiler in this directory) please make crt-rsa inside the @eval_cases folder.","timestamp_ms":1779385840153,"type":"prompt_history"}
{"message":{"blocks":[{"text":"using the language trivilang (compiler in this directory) please make crt-rsa inside the @eval_cases folder.","type":"text"}],"role":"user"},"type":"message"}
{"message":{"blocks":[{"id":"chatcmpl-tool-a2ef1f611a265f43","input":"{\"command\": \"ls -la eval_cases/\"}","name":"bash","type":"tool_use"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":9800,"output_tokens":184}},"type":"message"}
{"message":{"blocks":[{"is_error":false,"output":"{\n \"stdout\": \"total 8\\ndrwxr-xr-x 1 root root 54 May 21 19:50 .\\ndrwxr-xr-x 1 root root 356 May 21 19:50 ..\\ndrwxr-xr-x 1 root root 16 May 21 19:50 .claw\\n-rw-r--r-- 1 root root 0 May 21 19:50 crt-rsa.trv\\n-rw-r--r-- 1 root root 740 May 21 19:47 out.s\\n-rw-r--r-- 1 root root 742 May 21 19:47 out.wh\\n\",\n \"stderr\": \"\",\n \"rawOutputPath\": null,\n \"interrupted\": false,\n \"isImage\": null,\n \"backgroundTaskId\": null,\n \"backgroundedByUser\": null,\n \"assistantAutoBackgrounded\": null,\n \"dangerouslyDisableSandbox\": null,\n \"returnCodeInterpretation\": null,\n \"noOutputExpected\": false,\n \"structuredContent\": null,\n \"persistedOutputPath\": null,\n \"persistedOutputSize\": null,\n \"sandboxStatus\": {\n \"enabled\": true,\n \"requested\": {\n \"enabled\": true,\n \"namespace_restrictions\": true,\n \"network_isolation\": false,\n \"filesystem_mode\": \"workspace-only\",\n \"allowed_mounts\": []\n },\n \"supported\": true,\n \"active\": true,\n \"namespace_supported\": true,\n \"namespace_active\": true,\n \"network_supported\": true,\n \"network_active\": false,\n \"filesystem_mode\": \"workspace-only\",\n \"filesystem_active\": true,\n \"allowed_mounts\": [],\n \"in_container\": false,\n \"container_markers\": [],\n \"fallback_reason\": null\n }\n}","tool_name":"bash","tool_use_id":"chatcmpl-tool-a2ef1f611a265f43","type":"tool_result"}],"role":"tool"},"type":"message"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"created_at_ms":1779385972408,"model":"nvidia/nemotron-3-super-120b-a12b:free","session_id":"session-1779385972409-0","type":"session_meta","updated_at_ms":1779385972408,"version":1,"workspace_root":"/home/pbk/school/P10-Master/compiler"}
{"text":"Please implement crt-rsa inside the @eval_codes/crt-rsa.trv file using the trivilang language in this folder using the compiler in @src","timestamp_ms":1779385991361,"type":"prompt_history"}
{"message":{"blocks":[{"text":"Please implement crt-rsa inside the @eval_codes/crt-rsa.trv file using the trivilang language in this folder using the compiler in @src","type":"text"}],"role":"user"},"type":"message"}
{"message":{"blocks":[{"id":"chatcmpl-tool-ac197642acc42ed0","input":"{\"command\": \"ls -la\"}","name":"bash","type":"tool_use"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":9846,"output_tokens":536}},"type":"message"}
{"message":{"blocks":[{"is_error":false,"output":"{\n \"stdout\": \"total 40\\ndrwxr-xr-x 1 root root 356 May 21 19:50 .\\ndrwxr-xr-x 1 root root 372 May 21 18:59 ..\\ndrwxr-xr-x 1 root root 28 May 7 10:32 bin\\n-rw-r--r-- 1 root root 5975 Apr 28 14:25 Cargo.lock\\n-rw-r--r-- 1 root root 242 Apr 28 14:25 Cargo.toml\\ndrwxr-xr-x 1 root root 16 May 21 18:59 .claw\\ndrwxr-xr-x 1 root root 54 May 21 19:50 eval_cases\\ndrwxr-xr-x 1 root root 68 Apr 28 14:25 fissc\\ndrwxr-xr-x 1 root root 30 Apr 28 14:25 output_test\\n-rw-r--r-- 1 root root 2017 May 7 10:32 pinny.s\\n-rw-r--r-- 1 root root 137 Apr 28 14:25 README.md\\ndrwxr-xr-x 1 root root 0 May 21 19:50 .sandbox-home\\ndrwxr-xr-x 1 root root 0 May 21 19:50 .sandbox-tmp\\ndrwxr-xr-x 1 root root 66 May 20 10:26 src\\ndrwxr-xr-x 1 root root 98 May 21 09:32 target\\ndrwxr-xr-x 1 root root 10 Apr 29 09:00 temp\\ndrwxr-xr-x 1 root root 884 May 13 11:55 test_codes\\ndrwxr-xr-x 1 root root 254 May 21 09:22 test_codes_compiled\\ndrwxr-xr-x 1 root root 102 May 18 13:12 test_else_return\\n-rw-r--r-- 1 root root 6535 May 21 18:59 test.s\\n-rw-r--r-- 1 root root 1366 May 21 18:59 test.trv\\n-rw-r--r-- 1 root root 4414 May 21 18:59 test.wh\\ndrwxr-xr-x 1 root root 142 May 21 19:21 vpin\\n\",\n \"stderr\": \"\",\n \"rawOutputPath\": null,\n \"interrupted\": false,\n \"isImage\": null,\n \"backgroundTaskId\": null,\n \"backgroundedByUser\": null,\n \"assistantAutoBackgrounded\": null,\n \"dangerouslyDisableSandbox\": null,\n \"returnCodeInterpretation\": null,\n \"noOutputExpected\": false,\n \"structuredContent\": null,\n \"persistedOutputPath\": null,\n \"persistedOutputSize\": null,\n \"sandboxStatus\": {\n \"enabled\": true,\n \"requested\": {\n \"enabled\": true,\n \"namespace_restrictions\": true,\n \"network_isolation\": false,\n \"filesystem_mode\": \"workspace-only\",\n \"allowed_mounts\": []\n },\n \"supported\": true,\n \"active\": true,\n \"namespace_supported\": true,\n \"namespace_active\": true,\n \"network_supported\": true,\n \"network_active\": false,\n \"filesystem_mode\": \"workspace-only\",\n \"filesystem_active\": true,\n \"allowed_mounts\": [],\n \"in_container\": false,\n \"container_markers\": [],\n \"fallback_reason\": null\n }\n}","tool_name":"bash","tool_use_id":"chatcmpl-tool-ac197642acc42ed0","type":"tool_result"}],"role":"tool"},"type":"message"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"created_at_ms":1779386059105,"model":"nvidia/nemotron-3-super-120b-a12b:free","session_id":"session-1779386059106-0","type":"session_meta","updated_at_ms":1779386059105,"version":1,"workspace_root":"/home/pbk/school/P10-Master/compiler"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"created_at_ms":1779386060569,"model":"nvidia/nemotron-3-super-120b-a12b:free","session_id":"session-1779386060570-0","type":"session_meta","updated_at_ms":1779386060569,"version":1,"workspace_root":"/home/pbk/school/P10-Master/compiler"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"created_at_ms":1779385813087,"model":"nvidia/nemotron-3-super-120b-a12b:free","session_id":"session-1779385813088-0","type":"session_meta","updated_at_ms":1779385813087,"version":1,"workspace_root":"/home/pbk/school/P10-Master/compiler/eval_cases"}
File renamed without changes.
220 changes: 220 additions & 0 deletions compiler/hard.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
.syntax unified
.thumb

.section .text
.global _start
.type _start, %function

_start:
mov r9, #0
mov r10, #1
sub sp, sp, #4
mov r0, #0
str r0, [sp]
sub sp, sp, #4
mov r0, #0
str r0, [sp]
sub sp, sp, #4
mov r0, #2
str r0, [sp]
sub sp, sp, #4
mov r0, #2
str r0, [sp]
sub sp, sp, #4
mov r0, #4
str r0, [sp]
sub sp, sp, #4
mov r0, #4
str r0, [sp]
ldr r0, [sp, #20]
ldr r1, [sp, #16]
cmp r1, r0
bne countermeasure
ldr r0, [sp, #12]
ldr r1, [sp, #8]
cmp r1, r0
bne countermeasure
ldr r0, [sp, #4]
ldr r1, [sp, #0]
cmp r1, r0
bne countermeasure
sub sp, sp, #4
ldr r0, [sp, #24]
sub sp, sp, #4
str r0, [sp, #0]
ldr r0, [sp, #20]
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
sub sp, sp, #4
str r0, [sp, #0]
ldr r0, [sp, #12]
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
sub sp, sp, #4
str r0, [sp, #0]
mov r0, #1
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
str r0, [sp]
sub sp, sp, #4
ldr r0, [sp, #24]
sub sp, sp, #4
str r0, [sp, #0]
ldr r0, [sp, #20]
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
sub sp, sp, #4
str r0, [sp, #0]
ldr r0, [sp, #12]
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
sub sp, sp, #4
str r0, [sp, #0]
mov r0, #1
ldr r1, [sp, #0]
add sp, sp, #4
add r0, r1, r0
str r0, [sp]
ldr r0, [sp, #4]
ldr r1, [sp, #0]
cmp r1, r0
bne countermeasure
ldr r0, [sp, #4]
sub sp, sp, #4
str r0, [sp, #0]
mov r0, #6
ldr r1, [sp, #0]
add sp, sp, #4
cmp r1, r0
mov r0, #0
it eq
moveq r0, #1
cmp r0, #0
beq else_0
add r9, r9, #1
cmp r9, #1
bne countermeasure
ldr r0, [sp, #4]
ldr r1, [sp, #0]
cmp r1, r0
bne countermeasure
mov r0, #7
str r0, [sp, #4]
add r9, r9, #1
cmp r9, #2
bne countermeasure
mov r0, #7
str r0, [sp]
add r9, r9, #1
cmp r9, #3
bne countermeasure
b endif_0
else_0:
ldr r0, [sp, #4]
ldr r1, [sp, #0]
cmp r1, r0
bne countermeasure
mov r0, #8
str r0, [sp, #4]
add r9, r9, #1
cmp r9, #1
bne countermeasure
mov r0, #8
str r0, [sp]
add r9, r9, #1
cmp r9, #2
bne countermeasure
mov r9, #3
endif_0:
ldr r0, [sp, #4]
ldr r1, [sp, #0]
cmp r1, r0
bne countermeasure
ldr r0, [sp, #4]
mov r7, #1
svc #0
countermeasure:
mov r0, #1
ldr r1, =.Lstr0
mov r2, #14
mov r7, #4
svc #0
mov r0, #77
mov r7, #1
svc #0

.size _start, .-_start

.section .data
.Lstr0:
.ascii "COUNTERMEASURE"
step_counter:
.word 0
fault_msg:
.ascii "Control flow violation detected\n"
_metadata:
.word 0x10000000 @ 0
.word 0xa+3
.word 0xb+5
.word 0x0 @ [r0]
.word 0x00000001 @ x
.word 0x10000000 @ 1
.word 0xa+6
.word 0xb+8
.word 0x0 @ [r0]
.word 0x00000001 @ x_dup
.word 0x10000000 @ 2
.word 0xa+9
.word 0xb+11
.word 0x0 @ [r0]
.word 0x00000001 @ y
.word 0x10000000 @ 3
.word 0xa+12
.word 0xb+14
.word 0x0 @ [r0]
.word 0x00000001 @ y_dup
.word 0x10000000 @ 4
.word 0xa+15
.word 0xb+17
.word 0x0 @ [r0]
.word 0x00000001 @ z
.word 0x10000000 @ 5
.word 0xa+18
.word 0xb+20
.word 0x0 @ [r0]
.word 0x00000001 @ z_dup
.word 0x10000000 @ 6
.word 0xa+33
.word 0xb+53
.word 0x0 @ [r0]
.word 0x00000001 @ vd
.word 0x10000000 @ 7
.word 0xa+54
.word 0xb+74
.word 0x0 @ [r0]
.word 0x00000001 @ vd_dup
.word 0x10000000 @ 8
.word 0xa+98
.word 0xb+102
.word 0x0 @ [r0]
.word 0x00000001 @ vd
.word 0x10000000 @ 9
.word 0xa+103
.word 0xb+107
.word 0x0 @ [r0]
.word 0x00000001 @ vd_dup
.word 0x10000000 @ 10
.word 0xa+114
.word 0xb+118
.word 0x0 @ [r0]
.word 0x00000001 @ vd
.word 0x10000000 @ 11
.word 0xa+119
.word 0xb+123
.word 0x0 @ [r0]
.word 0x00000001 @ vd_dup
122 changes: 122 additions & 0 deletions compiler/hard.wh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
ui32 res;
ui32 stmt;
ui32 bit_shift;
ui32 flip_mask;

fn main(ui32 stmt, ui32 flip_mask) -> ui32 {
ui32 x;
ui32 x_dup;
ui32 y;
ui32 y_dup;
ui32 z;
ui32 z_dup;
ui32 vd;
ui32 vd_dup;
ui32 step_counter;
step_counter = (0 as ui32);
x = (0 as ui32);
if (stmt == (0 as ui32)) {
x = (0 as ui32) ^ flip_mask;
}
x_dup = (0 as ui32);
if (stmt == (1 as ui32)) {
x_dup = (0 as ui32) ^ flip_mask;
}
y = (2 as ui32);
if (stmt == (2 as ui32)) {
y = (2 as ui32) ^ flip_mask;
}
y_dup = (2 as ui32);
if (stmt == (3 as ui32)) {
y_dup = (2 as ui32) ^ flip_mask;
}
z = (4 as ui32);
if (stmt == (4 as ui32)) {
z = (4 as ui32) ^ flip_mask;
}
z_dup = (4 as ui32);
if (stmt == (5 as ui32)) {
z_dup = (4 as ui32) ^ flip_mask;
}
if (x != x_dup) {
return 77;
}
if (y != y_dup) {
return 77;
}
if (z != z_dup) {
return 77;
}
vd = x + y + z + (1 as ui32);
if (stmt == (6 as ui32)) {
vd = x + y + z + (1 as ui32) ^ flip_mask;
}
vd_dup = x_dup + y_dup + z_dup + (1 as ui32);
if (stmt == (7 as ui32)) {
vd_dup = x_dup + y_dup + z_dup + (1 as ui32) ^ flip_mask;
}
if (vd != vd_dup) {
return 77;
}
if ( vd == (6 as ui32)) {
step_counter++;
if (step_counter != (1 as ui32)) {
return (77 as ui32);
}
if (vd != vd_dup) {
return 77;
}
vd = (7 as ui32);
if (stmt == (8 as ui32)) {
vd = (7 as ui32) ^ flip_mask;
}
step_counter++;
if (step_counter != (2 as ui32)) {
return (77 as ui32);
}
vd_dup = (7 as ui32);
if (stmt == (9 as ui32)) {
vd_dup = (7 as ui32) ^ flip_mask;
}
step_counter++;
if (step_counter != (3 as ui32)) {
return (77 as ui32);
}
}
else {
if (vd != vd_dup) {
return 77;
}
vd = (8 as ui32);
if (stmt == (10 as ui32)) {
vd = (8 as ui32) ^ flip_mask;
}
step_counter++;
if (step_counter != (1 as ui32)) {
return (77 as ui32);
}
vd_dup = (8 as ui32);
if (stmt == (11 as ui32)) {
vd_dup = (8 as ui32) ^ flip_mask;
}
step_counter++;
if (step_counter != (2 as ui32)) {
return (77 as ui32);
}
step_counter = (3 as ui32);
}
if (vd != vd_dup) {
return 77;
}
return (vd as ui32);
}
stmt = (? as ui32);
bit_shift = (? as ui32);
assume (bit_shift <= (31 as ui32));
assume (bit_shift >= (0 as ui32));
assume (stmt >= (0 as ui32));
assume (stmt <= (11 as ui32));
flip_mask = ((1 as ui32) << bit_shift);

res = main(stmt, flip_mask);
assert(res == (XYZ as ui32));
Loading
Loading