use16 org 100h mov si,prg mov di,mem L: mov al,[si] ; mov dl,al ; mov ah,02h ; int 21h and al,al jz ending call proc_sym ; mov dl,[si] ; mov ah,02h ; int 21h inc si jmp L proc_sym: cmp al,'<' je less cmp al,'>' je more cmp al,'+' je plus cmp al,'-' je minus cmp al,'.' je print cmp al,',' je read cmp al,'[' je open cmp al,']' je close ret open: cmp byte ptr di,0 je find_close cmp bx,br_stack_end je print_error mov [bx],si add bx,2 ret find_close: xor cx,cx M: lodsb cmp al,'[' jne M2 inc cx jmp M M2: cmp al,']' jne M3 dec cx jnz M dec si ret M3: test al,al jne M jmp print_error close: cmp bx,br_stack je print_error ; mov dx,si ; mov ah,02h ; int 21h sub bx,2 cmp byte ptr di,0 je c mov si, [bx] dec si c: ret less: cmp di,mem je zero dec di ret zero: mov cx,mem mov di,8000h add di,cx ret more: mov cx,mem sub di,cx cmp di,8000h je arend add di,cx inc di ret arend: mov di,mem ret plus: inc byte ptr di ret minus: dec byte ptr di ret print: mov dl,[di] mov ah,02h int 21h ; push si ; sub si,prg ; mov dx,si ; mov ah,02h ; int 21h ; pop si ret read: mov ah,01h int 21h mov [di],al ret print_error: mov dx, ermsg mov ah, 9 int 21h ending: ; mov dx,[si-1] ; mov ah,02h ; int 21h mov ah,4ch int 21h prg: db ',>,[-<+>]<.,.',0 mem: db 32768 dup(0) ermsg: db 'Fatal error. Explosion in 10 secs$' br_stack: dw 1024 dup(0ffffh) br_stack_end: