<<< Getting Started     Index     Beep API Call >>>

; CIS-77
; add_16_bytes.asm
;
.586P
.MODEL FLAT         ; Flat memory model
option casemap:none ; Treat labels as case-sensitive

.CONST          ; Constant data segment

.STACK 100h     ; (default is 1-kilobyte stack)

.DATA           ; Begin initialized data segment
    values db 16 DUP( 5 ) ; 16 bytes of values "5"

; Code segment
.CODE           ; Begin code segment
_main PROC      ; Beginning of code

    mov eax, 0      ; clear result 
    mov bl, 16      ; init loop counter 
    lea esi, values ; init data pointer
addup:
    add al, [esi]   ; add byte to sum
    inc esi         ; increment data pointer 
    dec bl          ; decrement loop counter 
    jnz addup       ; if BL not zero, continue
    mov [esi], al   ; save sum 
    ret             ; Exit
    
_main ENDP
END _main       ; Marks the end of the module and sets the program entry point label

<<< Getting Started     Index     Beep API Call >>>