嘿伙计这是我第一次发帖,所以对我很好!我必须制作一个移位和减法的程序,最终将两个数字分开。我已经制作了一个可以增加和增加的程序......现在需要分开。这就是我到目前为止所拥有的。你必须用一个菜单制作一个程序,它要求用户输入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
答案 0 :(得分:0)
这样的事情可能有用:
; divide cx by dx, leaving the quotient in cx and the remainder in ax.
mov ax, 0
mov bp, 10h
divide: sal cx, 1
rcl ax, 1
cmp ax, dx
jb smaller
sub ax, dx
inc cx
smaller: dec bp
jnz divide