bincmp.S revision 00b53b7f3f9ce5996b767b52c28dd846f47a723c
1    /*
2     * Generic two-operand compare-and-branch operation.  Provide a "condition"
3     * fragment that specifies the comparison to perform, e.g. for
4     * "if-le" you would use "le".
5     *
6     * For: if-eq, if-ne, if-lt, if-ge, if-gt, if-le
7     */
8    /* if-cmp vA, vB, +CCCC */
9    lh      a4, 2(rPC)                  # a4 <- sign-extended CCCC
10    ext     a2, rINST, 8, 4             # a2 <- A
11    ext     a3, rINST, 12, 4            # a3 <- B
12    GET_VREG a0, a2                     # a0 <- vA
13    GET_VREG a1, a3                     # a1 <- vB
14
15    b${condition}c a0, a1, 1f
16    li      a4, 2                       # offset if branch not taken
171:
18
19    dlsa    rPC, a4, rPC, 1             # rPC <- rPC + CCCC * 2
20    FETCH_INST                          # load rINST
21
22#if MTERP_SUSPEND
23    bgez    a4, 2f                      # CCCC * 2 >= 0 => no suspend check
24    REFRESH_IBASE
252:
26#else
27    lw      ra, THREAD_FLAGS_OFFSET(rSELF)  # Preload flags for MterpCheckSuspendAndContinue
28    bltz    a4, MterpCheckSuspendAndContinue
29#endif
30
31    GET_INST_OPCODE v0                  # extract opcode from rINST
32    GOTO_OPCODE v0                      # jump to next instruction
33