TASM SIMPLE LOOP implemention

I just want too write simple .asm code for TASM that work as for in C++

int t=2;
for(int i=0;i<2;i++)

How can I implement it with TASM?


This will loop from 1 to 100 in 8086 TASM:


    .STACK 100h

    Finished DB 10, 13, 'Loop x 100 finished.  Congratulations! $', 10, 13



            MOV AX, @data            ; Required at the start of every program (inside your main procedure, from what I've seen)
            MOV DS, AX

            MOV CX, 100              ; Set CX to 100
            MOV BX, 0                ; Counter (for double-verification, I guess...lol)

    StrtLoop:                        ; When a loop starts, it does CX-- (subtracts 1 from CX)   

            INC BX                    ; This does BX++, which increments BX by 1

    LOOP StrtLoop                     ; Go back to StrtLoop label

            CMP BX, 100              ; Compare BX to 100...
            JE DispMsg               ; Jump-if-Equal...CMP BX, 100 sets flags, and if they are set,
                                     ;  JE will Jump you to DispMsg (to get "congratulations" message).

            JMP SkipMsg              ; Jump to the SkipMsg label (so you don't see the "congratulations" message).

    DispMsg:                         ; If BX = 100, you JE here.
            MOV AH, 09H              ; Displays the message stored in the defined byte "Finished"
            MOV DX, OFFSET Finished
            INT 21H
    SkipMsg:                         ; If BX != 100, you JMP here.
            MOV AL, 0h               ; Op code to exit to DOS from the assembler.
            MOV AH, 4CH
            INT 21H


I hope it helps. I did the basic loop, so you can do the other bits of your code (and I don't know C++, lol). Good luck! It's hard, but kind of fun at the same time (at least for me).

Need Your Help

Laravel 4.1, Both Observer and EventHandler Wont Work on Eloquent Model

php laravel event-handling laravel-4 observers

Summary: I have a model that I want to observe or Listen, but even after seeing response; nothing happens related to observers / event handles. (Db is ok too)

Is solving the halting problem easier than people think?

language-agnostic types inference computability

Although the general case is undecidable, many people still do solve problems that are equivilent well enough for day to day use.