aboutsummaryrefslogtreecommitdiff
path: root/tests/stack_machine_mul/instructions.s.tcl
blob: fae5ec64cd67a93e3bc4e4654fbfe347826b20af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env tclsh

source tclasm.tcl

### store 4 values to memory; load 2 of them back, multiply them and store the
### result; load another 2, multiply them and store the result;
### this is similar to addition and substraction tests

set_sp 0

## store first 2 factors
const 483091365
store h1EEE0
const 74683203
store h1EEE4

## store other 2 factors
const 8436
store h1EEEC
const -14020
store h1EEF0

## perform the first multiplication
load h1EEE0
load h1EEE4
# multiplying 483091365 by 74683203 should yield 36078810479842095
# if we take lowest 32 bits of 36078810479842095 we get 2861683503
mul
store h1EEE8

## perform the second multiplication
load h1EEEC
load h1EEF0
# multiplying 8436 by -14020 should yield -118272720 (which fits in 32 bits)
mul
store h1EEF4

halt