I'm trying to implement the following pseudocode in assembly:

My solution tries to implement the while loop using a LOOP instruction, but this gives me an infinite loop. (I know this is b/c of the garbage values in the ECX, but I don't understand how to overcom this problem and correctly implement the WHILE loop). Here's my code:
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
A WORD 9
B WORD 8
X WORD 15
sum WORD 0
.code
main PROC
L1:
    cmp X, 3     
    jne ELSEE   ;jump to ELSEE if X!=3 (short circuits the AND condition)
    mov ax, A+3
    cmp X, ax
    jle TRUE  ;jump to TRUE if X<=A+3
    mov bx, B-3
    cmp X, bx
    jl TRUE ;jump to TRUE if X<B-3
    cmp X,0
    jge WHYLE
    TRUE:
        sub X,2
        inc sum
    ELSEE:
        dec X
WHYLE:
    loop L1
    invoke ExitProcess, 0
main ENDP
END main
 
     
    