非常新鲜的问题,我如何用4个以上的数值来表达算术方程?
(14×3) + 16/4-3
ORG 0
MOV AL, E
MOV BL, 3
MUL AL, BL
;
MOV CL, 10
MOV DL, 4
DIV CL, DL
;
ADD AL, CL
MOV ??, 03 <--- what to put, DL is the last register
SUB AL, ?? <--- what to do
END
发布于 2015-10-21 20:59:27
首先,MUL和DIV只进行了一次论证。搜索“intel mul”和“intel div”以查看详细说明:
8双边投资条约:
使用8位寄存器r8
作为参数(其中r8
是16位8位寄存器之一),
MUL r8
将r8
与al
相乘,并将结果存储在ax
中。这是因为,例如,将127乘以127大于8位(但不超过16位)。div r8
将ax
除以r8
,将结果放在al
中,其余的在ah
中。对于16位参数:
MUL r16
将r16
( 16位寄存器)与ax
相乘,并将结果存储在dx:ax
中,即dx
中的高字,ax
中的低字。DIV r16
将把dx:ax
除以r16
,将结果放在ax
中,其余的在dx
中。你的计算
计算14×3 + 16/4 - 3
的步骤如下:
; First term: 14x3
mov al, 14
mov bl, 3
mul bl ; ax = 42 (or, al=42 and ah=0)
; next we're going to DIV, which uses `AX`, so we better copy our result out of ax:
mov cx, ax ; or: mov cl, al
; Second term, 16/4 (16/3 would be more interesting!)
mov ax, 16 ; we could mov al, 16 since ah is already 0
mov dl, 4
div dl ; now al=4 and ah=0 (With 16/3, al=5 and ah=1!)
; Add to our result:
add cl, al
; adc ch, 0 ; take care of overflow if we want a 16 bit result
; calculate the 3rd term
mov al, 3 ; that was easy :-)
; and add the 3rd term to our result:
sub cl, al ; we could have done sub cl, 3
我希望你知道这个主意!
https://stackoverflow.com/questions/33268699
复制相似问题