Using TASM I'm trying to allocate some memory which should serve as a buffer.
To do this I first deallocate all the memory which has been given to the executable using:
    MOV     BX, SS 
    MOV     AX, ES  
    SUB     BX, AX  
    MOV     AX, SP 
    ADD     AX, 0fh
    SHR     AX, 4
    ADD     BX, AX
    MOV     AH, 4ah
    INT     21h
Afterwards I'm trying to allocate 64000 bytes using:
    MOV     AH, 48h
    MOV     BX, 64000/16 
    INT     21h
    MOV     buffer, AX
which seems to work flawlessly as the CARRY flag ain't set after executing instruction 21h.
Later on I'm ultimately trying to fill the just allocated memory like:
    MOV     BX, OFFSET BUFFER
    MOV     ES, BX
    XOR     DI,DI
   
    MOV     CX,64000/2
    MOV     AL,12
    MOV     AH,AL
    REP     STOSW
which unfortunately fails as the program freezes at the REP STOSW instruction.
Now I'm a little lost as I can't find something obviously wrong. So why is this happening?
Here's my full source:
.MODEL LARGE
.STACK 100h
.DATA? 
buffer      DW ?
.CODE
Main:
    MOV     BX, SS 
    MOV     AX, ES  
    SUB     BX, AX  
    MOV     AX, SP 
    ADD     AX, 0fh
    SHR     AX, 4
    ADD     BX, AX
    MOV     AH, 4ah
    INT     21h
    MOV     AH, 48h
    MOV     BX, 64000/16 
    INT     21h
    MOV     buffer, AX
    MOV     BX, OFFSET BUFFER
    MOV     ES, BX
    XOR     DI,DI
   
    MOV     CX,64000/2
    MOV     AL,12
    MOV     AH,AL
    REP     STOSW
    MOV     AH,4ch  
    INT     21h 
   
END Main