8086 汇编 移位减除
大家好,这是我第一次发帖,请对我好一点!我必须编写一个程序来进行移位和减法以最终除以两个数字。我已经编写了一个可以移位加法和乘法的程序......现在只需要除法。这是我到目前为止所拥有的。你必须制作一个带有菜单的程序,要求用户输入 2 个输入,然后进行加、减、乘、除。
product_a_b proc near
clc
push ax
push cx
push bx
push si
push dx
push di
push bp
mov si, 00h
mov ax, 00h
mov bx, 00h
mov dx, 00h
mov cx, 00
mov al, A[si]
mov ah, A[si+1]
mov dl, B[bx]
mov dh, B[bx+1]
mov bp, 10h
multiply: TEST DX, 01B
jz skip
add cx, ax
skip: rcr cx, 01
rcr dx, 01
dec bp ; dec number
jnz multiply
mov [di],dl
mov [di+1],dh
mov [di+2],cl
mov [di+3],ch
pop bp
pop di
pop dx
pop si
pop bx
pop cx
pop ax
ret
product_a_b endp
QUOTIENT_A_B proc near
clc
push ax
push cx
push bx
push si
push dx
push di
push bp
mov si, 00h
mov ax, 00h
mov bx, 00h
mov dx, 00h
mov cx, 00
mov dl, A[si] ;ax = m
mov dh, A[si+1]
mov al, B[bx] ; dx = q
mov ah, B[bx+1] ; cx = a
mov bp, 10h
divide: rcl cx, 01
rcl dx, 01
cmp cx, dx
jb div_add
dec bp ; dec number
jnz divide
div_add: add cx, dx
jmp divide
mov [di],dl
mov [di+1],dh
mov [di+2],cl
mov [di+3],ch
pop bp
pop di
pop dx
pop si
pop bx
pop cx
pop ax
ret
QUOTIENT_A_B endp
Hey guys this is my first time posting so be nice to me! I have to make a program that shifts and subtracts to eventually divide two numbers. I have already made a program that can shift add and multiply... Just need to divide now. This is what I have so far. You have to make a program with a menu, that asks the users for 2 inputs and then it adds, subtracts, multiplies and then divides.
product_a_b proc near
clc
push ax
push cx
push bx
push si
push dx
push di
push bp
mov si, 00h
mov ax, 00h
mov bx, 00h
mov dx, 00h
mov cx, 00
mov al, A[si]
mov ah, A[si+1]
mov dl, B[bx]
mov dh, B[bx+1]
mov bp, 10h
multiply: TEST DX, 01B
jz skip
add cx, ax
skip: rcr cx, 01
rcr dx, 01
dec bp ; dec number
jnz multiply
mov [di],dl
mov [di+1],dh
mov [di+2],cl
mov [di+3],ch
pop bp
pop di
pop dx
pop si
pop bx
pop cx
pop ax
ret
product_a_b endp
QUOTIENT_A_B proc near
clc
push ax
push cx
push bx
push si
push dx
push di
push bp
mov si, 00h
mov ax, 00h
mov bx, 00h
mov dx, 00h
mov cx, 00
mov dl, A[si] ;ax = m
mov dh, A[si+1]
mov al, B[bx] ; dx = q
mov ah, B[bx+1] ; cx = a
mov bp, 10h
divide: rcl cx, 01
rcl dx, 01
cmp cx, dx
jb div_add
dec bp ; dec number
jnz divide
div_add: add cx, dx
jmp divide
mov [di],dl
mov [di+1],dh
mov [di+2],cl
mov [di+3],ch
pop bp
pop di
pop dx
pop si
pop bx
pop cx
pop ax
ret
QUOTIENT_A_B endp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的事情可能会起作用:
Something like this may work: