zoukankan      html  css  js  c++  java
  • 汇编:实现C语言的 ||与&&运算

    ;C程序转汇编(或运算链接)
    DATAS SEGMENT
    a Dw 5
    b dw 6
    cc dw 7
    d dw 8
    m dw 2
    n dw 2
    string db 6 dup(?)
    DATAS ends
    CODES SEGMENT
        ASSUME CS:CODES, DS:DATAS
        START:
            mov AX,DATAS
            mov DS,AX   ;把需要比较的两个数字放入两个寄存器中
            
            mov ax,a
            mov bx,b
            cmp ax,bx
            jb Rm       ;当a<B时跳转到rm
            mov m,0     ;当a>b时为假所以m赋值为0
                        ;上述内容给等价于m=a<>>b
            mov ax,cc
            mov bx,d
            cmp ax,cc
            ja  Rn
            mov n,0
                         ;上述内容给等价于n=c>d
            jmp exit
    
        Rm:
            mov m,1
            jmp exit
        Rn:
            mov n,1
            jmp exit
        exit:
            mov si,offset string
            mov AX,m
            and AL,0FH
            add al,30H
            mov [si],al
                        ;把m转化为ASCII码并存入string中
            xor cx,cx
            mov cl,3
                        ;上述两句设置循环次数
        lp:
            inc si
            mov byte ptr [si],20H    ;20H代表空格
            loop lp
                        ;利用循环添加3个空格 代替	
            inc si
            mov AX,n
            and AL,0FH
            add al,30H
            mov [si],al
                        ;把n转化为ASCII码并存入string中
            mov byte ptr [si+1],'$'
                        ;为字符串string加上结束符
            lea dx,string
            mov ah,09h
            int 21H
            mov ah,4ch
            int 21H
    CODES ends
        end START

    <hr>

     1 ;C程序转汇编(与运算链接)
     2 DATAS SEGMENT
     3 a Dw 5
     4 b dw 6
     5 cc dw 7
     6 d dw 8
     7 m dw 2
     8 n dw 2
     9 string db 6 dup(?)
    10 DATAS ends
    11 CODES SEGMENT
    12     ASSUME CS:CODES, DS:DATAS
    13     START:
    14         mov AX,DATAS
    15         mov DS,AX   ;把需要比较的两个数字放入两个寄存器中
    16         
    17         mov ax,a
    18         mov bx,b
    19         cmp ax,bx
    20         jbe Rm     ;当a<=B时跳转到rm
    21         mov m,1     ;当a>b时为真所以m赋值为1
    22                     ;上述内容给等价于m=a>b
    23         mov ax,cc
    24         mov bx,d
    25         cmp ax,cc
    26         jbe Rn
    27         mov n,1
    28                      ;上述内容给等价于n=c>d
    29         jmp exit
    30 
    31     Rm:
    32         mov m,0
    33         jmp exit
    34     Rn:
    35         mov n,0
    36         jmp exit
    37     exit:
    38         mov si,offset string
    39         mov AX,m
    40         and AL,0FH
    41         add al,30H
    42         mov [si],al
    43                     ;把m转化为ASCII码并存入string中
    44         xor cx,cx
    45         mov cl,3
    46                     ;上述两句设置循环次数
    47     lp:
    48         inc si
    49         mov byte ptr [si],20H    ;20H代表空格
    50         loop lp
    51                     ;利用循环添加3个空格 代替	
    52         inc si
    53         mov AX,n
    54         and AL,0FH
    55         add al,30H
    56         mov [si],al
    57                     ;把n转化为ASCII码并存入string中
    58         mov byte ptr [si+1],'$'
    59                     ;为字符串string加上结束符
    60         lea dx,string
    61         mov ah,09h
    62         int 21H
    63         mov ah,4ch
    64         int 21H
    65 CODES ends
    66     end START
  • 相关阅读:
    静态化之优化
    SEO小技巧
    apache 工具和简单优化
    apache rewrite机制
    nginx php win平台配置
    mvc 简单模型
    php无限分类三种方式
    【转】sqlserver查询数据库中有多少个表
    【转】sqlserver数据库之间的表的复制
    SET ANSI_NULLS (TransactSQL)
  • 原文地址:https://www.cnblogs.com/roseAT/p/10246072.html
Copyright © 2011-2022 走看看