| 1 | // vtest build: !msvc && !tinyc |
| 2 | // The tests here have constraints, that are not implemented yet in tcc, and msvc does not support inline assembly at all |
| 3 | fn test_constraints() { |
| 4 | x := u64(100) |
| 5 | y := u64(200) |
| 6 | mut hi := u64(0) |
| 7 | mut lo := u64(0) |
| 8 | asm amd64 { |
| 9 | mov rax, x |
| 10 | mulq y |
| 11 | mov lo, rax |
| 12 | mov hi, rdx |
| 13 | ; =*m (lo) |
| 14 | =&r (hi) |
| 15 | ; rm (x) |
| 16 | r (y) |
| 17 | ; rax |
| 18 | rdx |
| 19 | cc |
| 20 | } |
| 21 | assert hi == 0 |
| 22 | assert lo == 20000 |
| 23 | } |
| 24 | |
| 25 | fn test_flag_output() { |
| 26 | a, b := 4, 9 |
| 27 | mut out := false |
| 28 | asm amd64 { |
| 29 | cmp a, b |
| 30 | ; =@ccl (out) |
| 31 | ; r (a) |
| 32 | r (b) |
| 33 | } |
| 34 | assert out |
| 35 | asm amd64 { |
| 36 | cmp b, a |
| 37 | ; =@ccl (out) |
| 38 | ; r (a) |
| 39 | r (b) |
| 40 | } |
| 41 | assert !out |
| 42 | |
| 43 | zero := 0 |
| 44 | asm amd64 { |
| 45 | cmp zero, zero |
| 46 | ; =@ccz (out) |
| 47 | ; r (zero) |
| 48 | } |
| 49 | assert out |
| 50 | |
| 51 | mut maybe_four := 4 |
| 52 | mut four := 4 |
| 53 | asm amd64 { |
| 54 | subl four, maybe_four |
| 55 | testl four, maybe_four |
| 56 | movl maybe_four, 9 |
| 57 | ; +m (maybe_four) |
| 58 | +r (four) |
| 59 | =@ccz (out) |
| 60 | } |
| 61 | assert out |
| 62 | assert maybe_four == 9 |
| 63 | } |
| 64 |