Home | History | Annotate | Download | only in x86-atom
      1    /* Copyright (C) 2008 The Android Open Source Project
      2     *
      3     * Licensed under the Apache License, Version 2.0 (the "License");
      4     * you may not use this file except in compliance with the License.
      5     * You may obtain a copy of the License at
      6     *
      7     * http://www.apache.org/licenses/LICENSE-2.0
      8     *
      9     * Unless required by applicable law or agreed to in writing, software
     10     * distributed under the License is distributed on an "AS IS" BASIS,
     11     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12     * See the License for the specific language governing permissions and
     13     * limitations under the License.
     14     */
     15 
     16    /*
     17     * File: binopDivRemLong2Addr.S
     18     *
     19     * Code: 64-bit "/2addr" long divide operation. Variable
     20     *       "func" defines the function called to do the operation.
     21     *
     22     * For: div-long/2addr, rem-long/2addr
     23     *
     24     * Description: Perform a binary operation on two sources registers
     25     *              and store the result in the first source register.
     26     *
     27     * Format: B|A|op (12x)
     28     *
     29     * Syntax: op vA, vB
     30     */
     31 
     32 %default {"func":"__divdi3"}
     33 
     34     movl        rINST, %edx             # %edx<- BA
     35     shr         $$4, %edx               # %edx<- B
     36     and         $$15, rINST             # rINST<- A
     37     movl        (rFP, %edx, 4), %eax    # %eax<- vB
     38     movl        %eax, -12(%esp)         # push arg vB
     39     movl        4(rFP, %edx, 4), %ecx   # %ecx<- vB+1
     40     or          %ecx, %eax              # check for divide by zero
     41     je          common_errDivideByZero  # handle divide by zero
     42     movl        %ecx, -8(%esp)          # push arg vB+1
     43     movq        (rFP, rINST, 4), %xmm0  # %xmm0<- vA,vA+1
     44     jmp         .L${opcode}_break
     45 %break
     46 .L${opcode}_break:
     47     movq        %xmm0, -20(%esp)        # push arg vA, vA+1
     48     lea         -20(%esp), %esp
     49     call        $func                   # call func
     50     lea         20(%esp), %esp
     51     movl        %eax, (rFP, rINST, 4)   # vA<- return low
     52     movl        %edx, 4(rFP, rINST, 4)  # vA<- return high
     53     FFETCH_ADV  1, %ecx                 # %ecx<- next instruction hi; fetch, advance
     54     FGETOP_JMP 1, %ecx                  # jump to next instruction; getop, jmp