A simple loop.

Laszlo TataiLaszlo Tatai
1 min read

There's nothing to explain about the program; the comments are sufficient to understand its operation.

; Author tatai.laszlo@mail.com

TITLE Simple Loop            ;    program name
.386                        ; 80386 program code or higher.    
.model flat,stdcall

.stack 100H                    ; 256 byte Stack segment
.data
    szamlalo_max dw 10      ; The loop executes this many times. (word = 2 byte)

.code
start:
    mov ax, 0               ; The loop counter starts at 0. (ax register)
    mov cx, [szamlalo_max]     ; The loop counter (cx register) is set to the maximum value.

loop_while:
    cmp ax, cx              ; The counter is compared to the maximum.
    jge loop_end             ; If the counter is greater than or equal to the maximum, we exit the loop.

    inc ax                  ; Adding one to the counter.

    jmp loop_while            ; It jumps back to the beginning of the loop

loop_end :
    ret
end start

If you don't know how to compile the assembly file, then click on this link:
How to compile our console assembly file, using MASM32.

0
Subscribe to my newsletter

Read articles from Laszlo Tatai directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Laszlo Tatai
Laszlo Tatai

I am happy to help beginner programmers.