端口读写 in out
assume cs:code
code segment
start:
mov al,2
out 70h,al
;//out 70h,2 ;//must be acuumulator register
in al,71h
mov al,0
out 71h,al
mov al,0eeh
in al,71h
mov ax,4c00h
int 21h
code ends
end start
使用加法和移位指令计算(ax)=(ax)*10
(ax)*10=(ax)*8+(ax)*2,需要考虑进位,把进位部分保存在dx。
mov cl,3;shl bx,cl可以左移3位,即乘以8,
但是一次性左移3位可能出现多次进位的情况,此时cf=1,无法判断进位了几次,
所以每次移动一位。
assume cs:code,ss:stack
stack segment
db 8 dup(0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
push cx
mov sp,0
mov dx,0
mov cx,3
mov ax,3eeeh ;61166*2=9554cH
loop1:
;sub ax,0 ;//设置cf=0,这里不需要设置
shl dx,1
shl ax,1
jnc s1
inc dx
s1:
cmp cx,3
jnz s2 ;//==jne s2
push dx
push ax
s2:
loop loop1
pop cx
add ax,cx
jnc s3
inc dx
s3:
pop cx
add dx,cx
pop cx
mov ax,4c00h
int 21h
code ends
end start