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: binopDivRemLong.S
     18     *
     19     * Code: 64-bit long divide operation. Variable
     20     *       "func" defines the function called to do the operation.
     21     *
     22     * For: div-long, rem-long
     23     *
     24     * Description: Perform a binary operation on two source registers
     25     *              and store the result in a destination register.
     26     *
     27     * Format: AA|op CC|BB (23x)
     28     *
     29     * Syntax: op vAA, vBB, vCC
     30     */
     31 
     32 %default {"func":"__divdi3"}
     33 
     34     FETCH_CC    1, %edx                 # %edx<- CC
     35     movl        (rFP, %edx, 4), %eax    # %eax<- vCC
     36     movl        4(rFP, %edx, 4), %ecx   # %ecx<- vCC+1
     37     movl        %eax, -8(%esp)          # push arg vCC
     38     or          %ecx, %eax              # check for divide by zero
     39     je          common_errDivideByZero  # handle divide by zero
     40     FETCH_BB    1, %edx                 # %edx<- BB
     41     movl        %ecx, -4(%esp)          # push arg vCC+1
     42     movq        (rFP, %edx, 4), %xmm0   # %xmm0<- vBB,vBB+1
     43     jmp         .L${opcode}_finish
     44 %break
     45 .L${opcode}_finish:
     46     movq        %xmm0, -16(%esp)        # push arg vBB,vBB+1
     47     lea         -16(%esp), %esp
     48     call        $func                   # call func
     49     lea         16(%esp), %esp
     50     movl        %eax, (rFP, rINST, 4)   # vAA<- return low
     51     movl        %edx, 4(rFP, rINST, 4)  # vAA+1<- return high
     52     FINISH      2                       # jump to next instruction
     53