计算ffff:0~ffff:b数据的和,结果存在dx中

October 4, 2013
masm

代码:

assume cs:sad
sad segment
start:
    mov ax, 0ffffh
    mov ds, ax
    mov dx, 0
    ; add ds:0bh~ds:1h
    mov cx, 0bh
s:
    mov ah, 0
    mov bx, cx
    mov al, ds:[bx]
    add dx, ax
    loop s

    ; add ds:0h
    mov bh, 0
    mov bl, ds:[0]
    add dx, bx

    mov ax, 4c00h
    int 21h
sad ends
end

自己写的==

下面是看了书上的之后,写的:

assume cs:sad
sad segment
start:
    mov ax, 0ffffh
    mov ds, ax
    mov dx, 0
    mov bx, 0
    ; c = b + 1
    mov cx, 0ch
s:
    mov ah, 0
    mov al, [bx]
    inc bx
    add dx, ax
    loop s

    mov ax, 4c00h
    int 21h

sad ends
end

主要是加上了inc bx的用法==

comments powered by Disqus