Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 1 | %default {"result":"","special":""} |
| 2 | /* |
| 3 | * 32-bit binary div/rem operation. Handles special case of op0=minint and |
| 4 | * op1=-1. |
| 5 | */ |
| 6 | /* div/rem/lit16 vA, vB, #+CCCC */ |
| 7 | /* Need A in rINST, ssssCCCC in ecx, vB in eax */ |
| 8 | movzbl rINSTbl, %eax # eax <- 000000BA |
| 9 | sarl $$4, %eax # eax <- B |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame^] | 10 | GET_VREG %eax, %eax # eax <- vB |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 11 | movswl 2(rPC), %ecx # ecx <- ssssCCCC |
| 12 | andb $$0xf, rINSTbl # rINST <- A |
| 13 | testl %ecx, %ecx |
| 14 | je common_errDivideByZero |
| 15 | cmpl $$-1, %ecx |
| 16 | jne .L${opcode}_continue_div |
| 17 | cmpl $$0x80000000, %eax |
| 18 | jne .L${opcode}_continue_div |
| 19 | movl $special, %eax |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame^] | 20 | SET_VREG %eax, rINST |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 21 | ADVANCE_PC_FETCH_AND_GOTO_NEXT 2 |
| 22 | |
| 23 | .L${opcode}_continue_div: |
| 24 | mov rIBASE, LOCAL0(%esp) |
| 25 | cltd |
| 26 | idivl %ecx |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame^] | 27 | SET_VREG $result, rINST |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 28 | mov LOCAL0(%esp), rIBASE |
| 29 | ADVANCE_PC_FETCH_AND_GOTO_NEXT 2 |