;实现a+b-2*(a and b)
;作者:任嫱
;2007/10/21
;功能:汇编程序实现以上的公式计算
data segment
string1 db ' iuput the number a: $'
string2 db ' iuput the number b: $'
string3 db ' s=(a+b)-2*(a and b)= $'
a db ?
b db ?
s db ?
data ends
code segment
assume cs:code ,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset string1
mov ah,09h
int 21h
mov ah,01h
int 21h
mov a,al
mov dl,0dh
mov ah,02h
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov dx,offset string2
mov ah,09h
int 21h
mov ah,01h
int 21h
mov b,al
mov dl,0dh
mov ah,02h
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov dx,offset string3
mov ah,09h
int 21h
mov dl,a ;计算开始a+b
add dl,b
mov bl,a ;计算开始a and b
and bl,b
mov al,2 ;计算开始2*(a and b)
mul bl
sub dl,al
mov s,dl
add dl,30h
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start