Ассемблер TASM переизбыток кода

Столкнулся с проблемой, связаной с TASM: имеется основной файл программы (291 строка) и подключаемый модуль с макросами (370 строк). Если попытаться добавить еще код в основной модуль, то программа перестает работать корректно. Происходит трансляция и линковка без проблем, но дальнейшая логика ломается (при вызове функции программа переходит по неверному адресу), даже если добавлена "пустышка" (5 раз push ax, 5 раз pop ax). Изменение модели памяти не привели ни к чему. Программа отрабатывает стабильно верно до этого, но если добавить новую процедуру (при этом даже не вызывать ее), то программа начинает ломаться. Заранее всем спасибо за помощь.

include hw5INC.inc
.286
.MODEL small
.386
.stack 4000
.data
;ntes dw 0;
;tes db 1h;
;==================================
;          MENU INIT
;==================================
;         DESCRIPTIONS
;==================================
matPrtD db '[1] Print matrix$'; 
matFllD db '[2] Fill matrix$'; 
maxValD db '[3] Find max value$';
;==================================
select db '[0] Exit$';, 10, 13, 
select2 db ' >>> $';
new_line db 10, 13, '$';
err_msg db 'Input error!', 10, 13, '$';
desc dw (offset matPrtD), (offset matFllD)
el_ctr db ($-desc)/4;
labels dw (offset matPrtF), (offset matFllF)
;len dw 0;
len dw $ - labels;
row_ctr db 10;
;==================================

buff db 10 dup(0);
bsize db 4;
res dw 0;

ti dw 0;
tj dw 0;
rows dw 2;
cols dw 3;
matrix dw 1, 2, -3, 4, 5, -6;
matFllMsg db 'Input matrix rows and collumns counters:', 10, 13, '$';
matFllELZ db 'Error: values must be greater than zero!', 10, 13, '$';
matFllETH  db 'Error: values is too high!', 10, 13, '$';
matFllIMsg db 'Input matrix values value by value', 10, 13, '$';

maxVal dw 0;
tmp dw 0;

.code
;==================================
;           FUNCTIONS
;==================================
matPrtF proc
    set_cursor 0, 0; 
    mat_print matrix, rows, cols, ti, tj; mat, rows, cols, ti, tj
    ret;
matPrtF endp

matFllF proc
    set_cursor 0, 0; 
    
    matFllFBeg:
    print matFllMsg;
    stoi buff, bsize, cols; fill rows counter
    ;itos rows;
    cmp cols, 0; 0 < rows < 20
    jle matFllLower0;
    cmp cols, 20;
    jge matFllGreater;
    
    stoi buff, bsize, rows; fill cols counter
    ;itos cols;
    cmp rows, 0; 0 < cols < 20
    jle matFllLower0;
    cmp rows, 20;
    jge matFllGreater;
    jmp matFllFill;
    matFllLower0:
        print matFllELZ; print error msg Lower Than Zero
        jmp matFllFBeg;
    
    matFllGreater:
        print matFllETH; print error msg Greater Than [20]
        jmp matFllFBeg;
    ;fill matrix values
    matFllFill:
    print matFllIMsg;
    mat_fill matrix, rows, cols, buff, bsize, res;matrix, rows, cols, buff, bsize, res;
    ret;
matFllF endp


;maxVF proc
    ;max_row_el matrix, tmp, cols, maxVal;
    ;itos maxVal;
    ;mov cx, rows;
    ;max_while_start:
    ;   dec cx;
    ;   mov tmp, cx;
    ;   inc cx;
    ;   max_row_el matrix, tmp, cols, maxVal;
    ;   itos maxVal;
    ;   loop max_while_start_end;
    ;max_while_start_end:
;   ret
;maxVF endp


;==================================
;          MENU FUNCTIONS
;==================================
cursor_move proc
    push ax;
    push dx;
    push bx;
    mov ah, 02h;
    mov dh, row_ctr;
    mov dl, 30;
    ;add dh, cl;
    mov bh, 00h;
    int 10h;
    pop bx;
    pop dx;
    pop ax;
    ret
cursor_move endp;

clear_screen proc;
    
    ;mov row_ctr, 10;
    push ax;
    push bx;
    push cx;
    push dx;
    xor ax, ax;
    mov al, 10;
    sub al, el_ctr;
    mov row_ctr, al;
    mov ax, 0600h;
    mov bh, 09h;
    mov cx, 0000;
    mov dx, 184Fh;
    int 10h;
    pop dx;
    pop cx;
    pop bx;
    pop ax;
    ret
clear_screen endp;

fun_print proc ; bx -> func address
    push ax;
    push dx;
    push bx;
    call clear_screen;
    mov ah, 02h;
    mov dh, row_ctr;
    sub dh, el_ctr;
    mov dl, 30;
    ;add dh, cl;
    
    mov bh, 00h;
    int 10h;
    
    call bx;
    
    mov ah, 07h;
    int 21h;
    pop bx;
    pop dx;
    pop ax;
    ret
fun_print endp

print_menu proc
    push ax;
    push bx;
    push dx;
    push cx;
    call clear_screen;
    ;mov ax, 0600h;
    ;mov bh, 07h;
    ;mov cx, 0000;
    ;mov dx, 184h;
    ;int 10h;
    ;mov ah,2
    ;mov bh,0
    ;mov dx,1800h
    ;int 10h
    mov cl, row_ctr;
    mov ah, 09h;
    mov di, 0;
    mov bx, offset desc;
    mov dx, offset new_line;
    ;int 21h;
    print_while:
        mov dx, [bx + di];
        call cursor_move;
        int 21h;
        add di, 2;
        inc cl;
        mov row_ctr, cl;
        ;inc row_ctr;
        cmp di, len;
        jae print_while_end;
        jmp print_while;
    print_while_end:
    mov dx, offset select;
    ;inc cl;
    call cursor_move;
    int 21h;
    
    mov dx, offset select2;
    inc cl;
    mov row_ctr, cl;
    call cursor_move;
    int 21h;
    inc cl;
    mov row_ctr, cl;
    ;mov row_ctr, cl;
    pop cx;
    pop dx;
    pop bx;
    pop dx;
    ret;
print_menu endp;

;==================================
;            MAIN
;==================================
main proc
    mov ax, @data;
    mov ds, ax;
    xor ax, ax;
    ;xor bx, bx;
    ;movzx bx, tes;
    ;mov ax, bx;
    ;mov ax, offset len;
    ;sub ax, offset labels;
    ;mov len, ax;
    ;mov cx, len;
    ;mov bx, n_len;
    ;xor bx, bx;
    xor cx, cx;
prog_start:
    call print_menu;
    xor ax, ax;
    xor dx, dx;
    mov cl, '1';
    mov di, 0;
    mov ah, 01h;
    int 21h;
    mov ah, 09h;
    mov dx, offset new_line;
    int 21h;
    cmp al, '0';
    je while_end;
while_start:
    cmp cl, al;
    je m_call;
    add di, 2;
    inc cl;
    cmp di, len;
    jae m_err;
    jmp while_start;
m_call:
    mov bx, [offset labels + di];
    
    ;push ax;
    ;push cx;
    ;mov cx, 3;
    ;call cursor_move;
    ;call clear_screen;
    ;call bx;
    call fun_print;
    ;mov ah, 07h;
    ;int 21h;
    ;pop cx;
    ;pop ax;
    jmp prog_start;
m_err:
    mov dx, offset err_msg;
    mov ah, 09h;
    int 21h;
    jmp prog_start;
while_end:
    
    mov ax, 4c00h;
    int 21h;
    ret;
main endp
;==================================
end main;

Ответы (0 шт):