I am working on a floating point calculator for 16-bit processors, in particular 8086/8088. I use as88 Tracker , which does not implement floating points, not allowing me to use sscanf with "% f".
I was thinking about doing this in C code and calling this function from Assembly code, but I could not learn how to do this.
This is my code:
#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
I want to write a C function as:
float* getVal(char* ch) {
float fVal;
sscanf(ch, "%f", &fVal);
if(fVal == 0) return 0;
return fVal;
}
And call it from my Assembly code to translate the user-entered line number into the float.
Can anyone help me with this?
Thank!