ORG $5000 BUFSIZ EQU 80 ;input buffer size OPSTK DS.B 20 ;size of operations stack INPUTBUF DS.B BUFSIZ START LEA INPUTBUF,A0 ;load address of input buffer into A0 MOVE.W #BUFSIZ,D0 ;set D0 to size of input buffer ;(A0) = address of input, ;(D0.W) = max number of characters to read ;on input (D0.W) is # of characters to input JSR STRIN ;get input JSR STROUT ;echo input SUBQ #2,D0 ;adjust character count for DB instruction LEA INPUTBUF,A1 ;set A1 to top of stack SCANNEXT CMPI.B #'0',(A0) ;input='0'? BLT.S EVALUATE ;if input<0 then input is operator MOVE.B (A0)+,-(A1) ;push input onto stack SUBI.B #'0',(A1) ;convert stack entry to binary BRA.S CHKCNT ;test for more input EVALUATE MOVE.B (A1)+,D2 ;pop the operand stack MOVE.B (A1)+,D1 CMPI.B #'*',(A0)+ ;is operand an '*'? BEQ ANDOP ;Yes it is - goto AND operand OR.B D1,D2 ;otherwise OR arguements BRA.S PUSHOP ANDOP AND.B D1,D2 ;AND arguements PUSHOP MOVE.B D2,-(A1) ;push result onto stack CHKCNT DBF D0,SCANNEXT PUTANS ADDI.B #'0',(A1) ;convert stack to ASCII MOVEA.L A1,A0 ;set up pointer to output, i.e. A0 MOVE.W #1,D0 ;set up # of characters to output, i.e. D0.W JSR STROUT JSR NEWLINE