21,500
社区成员
发帖
与我相关
我的任务
分享
data segment
bottom db '@'
info1 db 0dh,0ah,'it can only program about * or + $'
info2 db 0dh,0ah,'input your expresion ','and press q to exit $'
left db 0
right db 0
result dw 0
data ends
numstack segment stack
db 200 dup(0)
numstack ends
opstack segment
db 200 dup(0)
opstack ends
code segment
assume ds:data ,ss:numstack,cs:code
start:
mov ax,data
mov ds,ax
;将‘@’放到各个栈的栈底,不知道栈转换是这么用的么。
mov ax,numstack
mov ss,ax
push bottom
mov ax,opstack
mov ss,ax
push bottom
mov ax,'+'
push ax
mov ax,numstack
mov ss,ax
mov ax,3
push ax
mov ax,4
push ax
pop left
pop right
mov ax,opstack
mov ss,ax
pop bx
cmp bx,'+'
jne exit
mov ax,left
add ax,right
mov result,ax
exit:
mov ah,4ch
int 21h
code ends
end start