Skip to content

Commit

Permalink
div set flags test
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Jun 14, 2024
1 parent 30d6ed2 commit e671111
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions programs/div/div_set_eq_flag.zasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.text
.file "div_set_eq_flag.zasm"
.globl __entry
__entry:
.func_begin0:
; EQ is set if the quotient is not zero
add 25, r0, r1
add 6, r0, r2
div! r1, r2, r3, r4
sstore r0, r3
ret
.func_end0:

.note.GNU-stack
.rodata
15 changes: 15 additions & 0 deletions programs/div/div_set_gt_flag.zasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.text
.file "div_set_gt_flag.zasm"
.globl __entry
__entry:
.func_begin0:
; GT is set if the reminder is not zero.
add 25, r0, r1
add 6, r0, r2
div! r1, r2, r3, r4
sstore r0, r3
ret
.func_end0:

.note.GNU-stack
.rodata
17 changes: 17 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@ fn test_div_zero_asm() {
run_program(&bin_path);
}

#[test]
fn test_div_set_eq_flag() {
let bin_path = make_bin_path_asm("div_set_eq_flag");
let (_, vm) = run_program(&bin_path);

assert!(vm.flag_eq);
}

#[test]
fn test_div_set_gt_flag() {
let bin_path = make_bin_path_asm("div_set_gt_flag");
run_program(&bin_path);
let (_, vm) = run_program(&bin_path);

assert!(vm.flag_gt);
}

#[test]
fn test_more_complex_program_with_conditionals() {
let bin_path = make_bin_path_asm("add_and_sub_with_conditionals");
Expand Down

0 comments on commit e671111

Please sign in to comment.