[Flashforth-devel] execute word from interpret and stack
Brought to you by:
oh2aun
From: Max S. <max...@gm...> - 2013-03-18 19:05:04
|
Hello All ! Does anybody can help me with problem ? for the 18F4685 board with f3.8 uart the task is to communicate with modem , i ve wrote the word to process modem answers as words and execute them. the first word from modem answer have to be interpreted with addr and length of remaining string on stack for ex an answer : OK AAA have to be interpreted as : execute word OK with addr and length of string AAA on stack here the test code : ------------------------------------------------------------------------------------------------------ -simcom marker -simcom hex ram create fpd 2 allot create inbuf 128 allot create npd 2 allot create outbuf 128 allot \ xu ... x0 u -- xu ... x0 xu : pick 2* 3 + sp@ swap - @ ; \ \ process answer from modem first word interprets as command , \ and remaining string addr2 and length n2 on stack as parameters \ to command \ : A2> ( a n a1 n1 -- a n a2 n2 a1 n1 ) dup >r over >r tuck + ( a n a1 n1 -- ... ) swap 2 pick swap - ( ... -- a n a2 n2 ) r> r> ( ... -- a n a2 n2 a1 n1 ) ; : proc_answ ( a n -- a2 n2 ) \ save variables 'source 2@ >r >r >in @ >r over over ( a n -- a n a n ) 'source 2! 0 >in ! ( a n a n -- a n ) \ get first word $20 parse ( a n c -- a n a1 n1 ) A2> ( a n a1 n1 -- a n a2 n2 a1 n1 ) cr ." Start INTERPRET: ------- " sp@ u. ." --------- " .s interpret ( a n a2 n2 a1 n1 -- a n ) cr ." End INTERPRET: ------- " sp@ u. ." -------- " .s \ restore variables r> >in ! r> r> 'source 2! ; \ \ : eee 90 ms ." AT+CPIN?" inbuf dup 100 accept ( -- a n ) proc_answ ( a n -- a n ) cr ." TP1 AFTR PROC------------------- " cr .s cr ; -testw marker -testw : LOG cr ." LOG s:" .s ; : OK ( a n a2 n2 -- a n ) cr ." TP2 exec +CPIN? : " cr .s LOG 1 2 3 + ; : OK2 ( a n a2 n2 -- a n ) cr ." TP2 exec +CPIN? : " cr .s LOG ; ------------------------------------------------------------- the problem is : when OK executes from eee via interpret and do something with stack, it always change two bottom stack elements 0 0 0 0 0 eee prompt >AT answer >OK ........some debug output......... ok<$,ram>1952 e 0 0 0 f178 2 f17a 0 1 5 0 0 0 0 0 eee AT OK2 ........some debug output ..... ok<$,ram>0 0 0 0 0 f178 2 f17a 0 Thank you in advance |