我正在爲16位處理器,特別是8086/8088處理浮點計算器。 我使用的是as88 Tracker,它沒有實現浮點,不允許我在「%f」中使用sscanf。使用as88彙編器從彙編代碼調用C函數
我想過在C代碼中這樣做,並從我的彙編代碼中調用此函數,但無法找到如何去做。
這是到目前爲止我的代碼:
#include "../syscalnr.h" .sect .text _code_: push bp mov bp, sp push SEGOP-PRIOP ! Pushes PRIOP String Size into the stack push PRIOP push STDOUT push _WRITE ! System Call to print string on the display sys add sp, 8 mov di, rasc ! Prepares DI to receive char push _GETCHAR 1: sys cmpb al, '\n' ! Compares with EOL and keeps storing the string chars je 2f stosb ! Stores char into variable rasc jmp 1b 2: xorb al, al ! Clears registers add sp, 2 .sect .data _data_: PRIOP: .asciz "Insert first operand:\n " SEGOP: .ascii "Insert second operand: " FORMAT: .asciz "%u" F_CHAR: .asciz "%c" F_STR: .asciz "%s\n" .sect .bss _bss_: rasc: .space 10
我希望能夠寫一個C函數爲:
float* getVal(char* ch) {
float fVal;
sscanf(ch, "%f", &fVal);
if(fVal == 0) return 0;
return fVal;
}
從我的彙編代碼中調用它翻譯的串號輸入由用戶變成浮動。
任何人都可以幫助我嗎?
謝謝!
你想要的功能似乎是'strtod',它是標準庫的一部分。 – 2011-05-28 21:22:07
似乎我也可以使用那個,但回到主要觀點,我怎樣才能從我的彙編代碼調用這個函數? – 2011-05-28 22:56:22