⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmov.asi

📁 一个微型操作系统源码
💻 ASI
字号:
;;;; CMOV.ASI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Agner Fog 2000 ;;;;
;;                                                                           ;;
;;          DEFINITION OF CONDITIONAL MOVE AND FCOMI INSTRUCTIONS            ;;
;;                                                                           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.XLIST                                                                       ;;
;;                                                                           ;;
;;  Instructions:                                                            ;;
;;  The Pentium Pro and Pentium II processors have conditional move and      ;;
;;  FCOMI instructions that are not supported by all assemblers.             ;;
;;  To use these instructions insert the following directive in your         ;;
;;  assembly file:                                                           ;;
;;  INCLUDE CMOV.ASI                                                         ;;
;;                                                                           ;;
;;  This file is written in MASM 5.10 syntax and works with TASM version 3.0 ;;
;;  or higher and MASM version 5.10 or higher.                               ;;
;;  The following assemblers may cause problems:                             ;;
;;  MASM v. 5.10 has a bug that gives wrong jump addresses in 32 bit mode.   ;;
;;  TASM32 v. 4.0, 5.0, 5.0o, 5.0r have various bugs that make them crash    ;;
;;  in DOS or Windows or both when executing these macros.                   ;;
;;  Microsoft ML version 6.11 doesn't work with these macros when output     ;;
;;  is in COFF format with certain linkers.                                  ;;
;;                                                                           ;;
;;  The macros work in both 16 bit mode and 32 bit mode, provided that no    ;;
;;  prefixes are needed. Make sure that all memory operands can be addressed ;;
;;  with the default segment register to avoid segment prefixes. Any         ;;
;;  prefixes needed must be hard-coded with the DB directive.                ;;
;;                                                                           ;;
;;  Microprocessor specified must be .386 or higher.                         ;;
;;                                                                           ;;
;;  Note that operands containing space must be enclosed in angle brackets   ;;
;;  in order to be interpreted as single operands by the macros, example:    ;;
;;  CMOV EAX, <DWORD PTR [ESI + 4]>                                          ;;
;;  or rewrite the operand to avoid the spaces:                              ;;
;;  CMOV EAX, [ESI+4]                                                        ;;
;;                                                                           ;;
;;  These macros accept two different ways of writing the floating point     ;;
;;  instructions: with and without the implicit operand ST. For example:     ;;
;;  FCOMI ST, ST(2)  or  FCOMI ST(2)                                         ;;
;;  The former for compatibility with Intel documents and assemblers that    ;;
;;  support these instructions, the latter for analogy with FCOM ST(2)       ;;
;;                                                                           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

IFDEF @version ; Microsoft assembler
  IF @version GE 612
    ; Assembler allready supports CMOV etc. Disable rest of file
    .686
    CMOVSUPPORTED EQU 1
  ELSE
    IF @version GE 600
      OPTION OLDMACROS  ; Make compatible with MASM 5.10 syntax
    ENDIF
  ENDIF
ENDIF
IFNDEF CMOVSUPPORTED

; meta-macro for defining CMOV instruction macro
CMOVDEF MACRO OPNAME, CCODE
  OPNAME MACRO DST, SRC
    LOCAL X, Y
    X:
    BSF DST, SRC
    Y:
    ORG X+1
    DB 40H + CCODE
    ORG Y
  ENDM
ENDM

; meta-macro for defining floating point instruction macro 
FPIDEF MACRO OPNAME, OPCODE, MODELINSTR
  OPNAME MACRO OP1, OP2
    LOCAL X, Y
    &IFNB <OP2>
      &IFIDNI <OP1>, <st>
      &ELSE
        &IFIDNI <OP1>, <st(0)>
        &ELSE
          &.ERR1
          &%OUT 'Error: First operand must be st'
        &ENDIF
      &ENDIF
      OPNAME <OP2>
    &ELSE
      X:
      MODELINSTR OP1
      Y:
      ORG X
      DB OPCODE
      ORG Y
    &ENDIF
  ENDM
ENDM


; define integer conditional move instructions
CMOVDEF CMOVO, 0
CMOVDEF CMOVNO, 1
CMOVDEF CMOVB, 2
CMOVDEF CMOVC, 2
CMOVDEF CMOVNB, 3
CMOVDEF CMOVNC, 3
CMOVDEF CMOVAE, 3
CMOVDEF CMOVZ, 4
CMOVDEF CMOVE, 4
CMOVDEF CMOVNZ, 5
CMOVDEF CMOVNE, 5
CMOVDEF CMOVBE, 6
CMOVDEF CMOVNA, 6
CMOVDEF CMOVA, 7
CMOVDEF CMOVS, 8
CMOVDEF CMOVNS, 9
CMOVDEF CMOVP, 10
CMOVDEF CMOVPE, 10
CMOVDEF CMOVNP, 11
CMOVDEF CMOVPO, 11
CMOVDEF CMOVL, 12
CMOVDEF CMOVNL, 13
CMOVDEF CMOVGE, 13
CMOVDEF CMOVLE, 14
CMOVDEF CMOVNG, 14
CMOVDEF CMOVG, 15

; define floating point conditional move instructions
FPIDEF FCMOVB, 0DAH, <FADD ST,>
FPIDEF FCMOVC, 0DAH, <FADD ST,>
FPIDEF FCMOVNB, 0DBH, <FADD ST,>
FPIDEF FCMOVNC, 0DBH, <FADD ST,>
FPIDEF FCMOVAE, 0DBH, <FADD ST,>
FPIDEF FCMOVE, 0DAH, <FMUL ST,>
FPIDEF FCMOVZ, 0DAH, <FMUL ST,>
FPIDEF FCMOVNE, 0DBH, <FMUL ST,>
FPIDEF FCMOVNZ, 0DBH, <FMUL ST,>
FPIDEF FCMOVBE, 0DAH, <FST>
FPIDEF FCMOVNA, 0DAH, <FST>
FPIDEF FCMOVNBE, 0DBH, <FST>
FPIDEF FCMOVA, 0DBH, <FST>
FPIDEF FCMOVU, 0DAH, <FSTP>
FPIDEF FCMOVNU, 0DBH, <FSTP>

; define floating point compare instructions setting integer flags
FPIDEF FCOMI, 0DBH, <FDIV ST,>
FPIDEF FCOMIP, 0DFH, <FDIV ST,>
FPIDEF FUCOMI, 0DBH, <FSUBR ST,>
FPIDEF FUCOMIP, 0DFH, <FSUBR ST,>

; purge meta-macros
PURGE CMOVDEF,FPIDEF

ENDIF

.LIST

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -