• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%verify "executed"
2%verify "basic lt, gt, eq */
3%verify "left arg NaN"
4%verify "right arg NaN"
5    /*
6     * Compare two floating-point values.  Puts 0, 1, or -1 into the
7     * destination register based on the results of the comparison.
8     *
9     * int compare(x, y) {
10     *     if (x == y) {
11     *         return 0;
12     *     } else if (x < y) {
13     *         return -1;
14     *     } else if (x > y) {
15     *         return 1;
16     *     } else {
17     *         return 1;
18     *     }
19     * }
20     */
21    /* op vAA, vBB, vCC */
22    FETCH(r0, 1)                        @ r0<- CCBB
23    mov     r9, rINST, lsr #8           @ r9<- AA
24    and     r2, r0, #255                @ r2<- BB
25    mov     r3, r0, lsr #8              @ r3<- CC
26    VREG_INDEX_TO_ADDR(r2, r2)          @ r2<- &vBB
27    VREG_INDEX_TO_ADDR(r3, r3)          @ r3<- &vCC
28    flds    s0, [r2]                    @ s0<- vBB
29    flds    s1, [r3]                    @ s1<- vCC
30    fcmpes  s0, s1                      @ compare (vBB, vCC)
31    FETCH_ADVANCE_INST(2)               @ advance rPC, load rINST
32    mov     r0, #1                      @ r0<- 1 (default)
33    GET_INST_OPCODE(ip)                 @ extract opcode from rINST
34    fmstat                              @ export status flags
35    mvnmi   r0, #0                      @ (less than) r1<- -1
36    moveq   r0, #0                      @ (equal) r1<- 0
37    b       .L${opcode}_finish          @ argh
38
39%break
40.L${opcode}_finish:
41    SET_VREG(r0, r9)                    @ vAA<- r0
42    GOTO_OPCODE(ip)                     @ jump to next instruction
43