C Line to Forth
\ c++ to Forth 方法
\ C++ 原始描述輸入
uint16_t USART_ReceiveData(USART_TypeDef* USARTx)
{
/* Check the parameters */
assert_param(IS_USART_ALL_PERIPH(USARTx));
/* Receive Data */
return (uint16_t)(USARTx->DR & (uint16_t)0x01FF);
}
\ C++ 轉檔 Forth描述
c" uint16_t USART_ReceiveData(USART_TypeDef* USARTx)"
c" {"
c" /* Check the parameters */"
c" assert_param(IS_USART_ALL_PERIPH(USARTx));"
c" /* Receive Data */"
c" return (uint16_t)(USARTx->DR & (uint16_t)0x01FF);"
c" }"
\ Forth轉檔輸出
: USART_ReceiveData ( USART_TypeDef* USARTx -- uint16_t )
USARTx w!
USARTx->DR w@
0x01FF and
;
借勢使力不費力
C(other) -> Arm/Thumb ASM(類 LLVM)-> Other CPU ASM/(Forth VM)
LLVM : operation, op1, op2, result
Arm/Thumb : operation, result , op1, op2,
ForthVM : op1 op2 result operation