<<< The Assembly Process     Index     MASM Command Line Interface >>>

3. Small Assembly Sample


     
     ; add_16_bytes.asm
     ;
     .586P
     ; Flat memory model, standard calling convention:
     .MODEL FLAT, STDCALL 
     ;
     ; Data segment
     _DATA SEGMENT
         values db 16 DUP( 5 ) ; 16 bytes of values "5"
     _DATA ENDS
 
     ; Code segment
     _TEXT SEGMENT
     START:
         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
     _TEXT ENDS
 
     END START
     
 
<<< The Assembly Process     Index     MASM Command Line Interface >>>