1    /*
2     * Compare two floating-point values.  Puts 0, 1, or -1 into the
3     * destination register based on the results of the comparison.
4     *
5     * int compare(x, y) {
6     *     if (x == y) {
7     *         return 0;
8     *     } else if (x > y) {
9     *         return 1;
10     *     } else if (x < y) {
11     *         return -1;
12     *     } else {
13     *         return -1;
14     *     }
15     * }
16     */
17    /* op vAA, vBB, vCC */
18    FETCH r0, 1                         @ r0<- CCBB
19    mov     r9, rINST, lsr #8           @ r9<- AA
20    and     r2, r0, #255                @ r2<- BB
21    mov     r3, r0, lsr #8              @ r3<- CC
22    VREG_INDEX_TO_ADDR r2, r2           @ r2<- &vBB
23    VREG_INDEX_TO_ADDR r3, r3           @ r3<- &vCC
24    fldd    d0, [r2]                    @ d0<- vBB
25    fldd    d1, [r3]                    @ d1<- vCC
26    vcmpe.f64 d0, d1                    @ compare (vBB, vCC)
27    FETCH_ADVANCE_INST 2                @ advance rPC, load rINST
28    mvn     r0, #0                      @ r0<- -1 (default)
29    GET_INST_OPCODE ip                  @ extract opcode from rINST
30    fmstat                              @ export status flags
31    movgt   r0, #1                      @ (greater than) r1<- 1
32    moveq   r0, #0                      @ (equal) r1<- 0
33    SET_VREG r0, r9                     @ vAA<- r0
34    GOTO_OPCODE ip                      @ jump to next instruction
35