汇编语言输出计算后的结果
datasegmentxdb?ydw?mess1db"inputx:","$"mess2db"y=2x+3=","$"dataendscodesegmentassumec...
data segment
x db ?
y dw ?
mess1 db "input x:","$"
mess2 db "y = 2x + 3 =","$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset mess1
mov ah,9
int 21h
mov ah,1
int 21h
mov dl,0ah
mov ah,2
int 21h
mov bl,al
sal bl,1
add bl,3
int 21h
mov dx,offset mess2
mov ah,9
int 21h
mov dx,bx
mov ah,9
mov ah,4ch
int 21h
code ends
end start
运行之后就是不输出运算的结果呢,高手帮个忙看一下哈~
还有,要求是用十进制数输出,是不是需要什么雨具做转换呢? 展开
x db ?
y dw ?
mess1 db "input x:","$"
mess2 db "y = 2x + 3 =","$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset mess1
mov ah,9
int 21h
mov ah,1
int 21h
mov dl,0ah
mov ah,2
int 21h
mov bl,al
sal bl,1
add bl,3
int 21h
mov dx,offset mess2
mov ah,9
int 21h
mov dx,bx
mov ah,9
mov ah,4ch
int 21h
code ends
end start
运行之后就是不输出运算的结果呢,高手帮个忙看一下哈~
还有,要求是用十进制数输出,是不是需要什么雨具做转换呢? 展开
1个回答
展开全部
data segment
x db ?
y dw ?
mess1 db 10, 13, "input x : ", "$"
mess2 db 10, 13, "y = 2x + 3 = ", 10, 13, "$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset mess1
mov ah,9
int 21h
mov ah,1
int 21h
SUB AL, 30H
ADD AL, AL
ADD AL, 3
MOV AH, 0
MOV BL, 10
DIV BL
ADD AL, 30H
MOV mess2[15], AL
ADD AH, 30H
MOV mess2[16], AH
mov dx,offset mess2
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
执行结果:
c:\masm510>JI_UU
input x : 7
y = 2x + 3 = 17
c:\masm510>
输入的如果不是10进制数,计算结果将会出错。
x db ?
y dw ?
mess1 db 10, 13, "input x : ", "$"
mess2 db 10, 13, "y = 2x + 3 = ", 10, 13, "$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset mess1
mov ah,9
int 21h
mov ah,1
int 21h
SUB AL, 30H
ADD AL, AL
ADD AL, 3
MOV AH, 0
MOV BL, 10
DIV BL
ADD AL, 30H
MOV mess2[15], AL
ADD AH, 30H
MOV mess2[16], AH
mov dx,offset mess2
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
执行结果:
c:\masm510>JI_UU
input x : 7
y = 2x + 3 = 17
c:\masm510>
输入的如果不是10进制数,计算结果将会出错。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询