EMU8086 简单汇编程序&实现5个BYTES的数据相加

一个简单的汇编程序:

        .MODEL SMALL          
        .STACK 64
        .DATA
DATA1   DB      52H
DATA2   DB      29H
SUM     DB      0
        .CODE  
MAIN    PROC    FAR
        MOV     AX, @DATA
        MOV     DS, AX
        ;MOV     DS, @DATA  ; No segment register can be loaded directly
        MOV     AL, DATA1
        MOV     BL, DATA2
        ADD     AL, BL
        MOV     SUM, AL
        MOV     AH, 4CH  ; With line 16 & 17, there will be "PROGRAM HAS RETURNED CONTROL TO THE OPERATING SYSTEM"
        INT     21H  ; Else there will be "the emulator is halted."
MAIN    ENDP 
        ENDP    MAIN
实现5个BYTES相加:

PAGE        60, 132
TITLE       TEST002 (COM)       PURPOSE: ADDS 5 BYTES OF DATA
            .MODEL SMALL
            .STACK 64
;-----------
            .DATA
DATA_IN     DB      25H, 12H, 15H, 1FH, 2BH
SUM         DB      0
;-----------
            .CODE
MAIN        PROC    FAR
            MOV     AX, @DATA
            MOV     DS, AX
            MOV     CX, 05
            MOV     BX, OFFSET DATA_IN
            MOV     AL, 0
AGAIN:      ADD     AL, [BX]
            INC     BX
            DEC     CX
            JNZ     AGAIN
            MOV     SUM, AL
            MOV     AH, 4CH
            INT     21H
MAIN        ENDP
            END     MAIN
结果:

EMU8086 简单汇编程序&实现5个BYTES的数据相加_第1张图片

EMU8086 简单汇编程序&实现5个BYTES的数据相加_第2张图片

你可能感兴趣的:(汇编)