mov si,#prog mov BX,#data mov CX,#bracket dec si INTERPRET: inc si mov al,[si] cmp al,#'+ jz WAS_PLUS cmp al,#'- jz WAS_MINUS cmp al,#'> jz WAS_MR cmp al,#'< jz WAS_ML cmp al,#'[ jz WAS_PL cmp al,#'] jz WAS_PR cmp al,#'. jz WAS_PRINT jmp PROG_END WAS_PLUS: inc BYTE [BX] JMP INTERPRET WAS_MINUS: dec BYTE [BX] JMP INTERPRET WAS_MR: inc bx JMP INTERPRET WAS_ML: dec bx JMP INTERPRET WAS_PL: MOV AL,[BX] cmp AL,#0 jz SKIP_CODE_BLOCK ;have to enter loop MOV AX,SI inc CX inc CX push SI MOV SI,CX mov [SI],AX POP SI JMP INTERPRET SKIP_CODE_BLOCK: ;have to skip loop MOV DX,#0 SKIP_LOOP: INC SI mov AL,[SI] CMP AL,#'] JZ WAS_CLOSE1 CMP AL,#'[ JZ WAS_OPEN1 JMP SKIP_LOOP WAS_CLOSE1: CMP DX,#0 JZ INTERPRET DEC DX JMP SKIP_LOOP WAS_OPEN1: INC DX JMP SKIP_LOOP WAS_PR: mov AL,[BX] cmp AL,#0 JZ EXIT_PR push SI MOV SI,CX mov ax,[SI] POP SI mov si,ax JMP INTERPRET EXIT_PR: DEC CX DEC CX jmp INTERPRET WAS_PRINT: mov ah, #0x02 MOV DL,[BX] int #0x21 JMP INTERPRET PROG_END: hlt bracket: .BLKB 280 data: .BLKB 560 ;prog db '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.f' prog:.ASCII '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'