From b75c633ad77164bd6f89ccca6ed9db6fb899679f Mon Sep 17 00:00:00 2001 From: VVWVV Date: Sat, 21 Jan 2017 21:21:32 +0300 Subject: [PATCH] Add support for float negative values to #emit Signed-off-by: VVWVV --- source/compiler/sc2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 55da378..cff0691 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -1346,10 +1346,16 @@ static int command(void) extern char *sc_tokens[];/* forward declaration */ char s2[33]="-"; if ((char)tok=='-') { - if (lex(&val,&str)==tNUMBER) { + int current_token=lex(&val,&str); + if (current_token==tNUMBER) { outval(-val,FALSE); code_idx+=opargs(1); break; + } else if (current_token==tRATIONAL) { + /* change the first bit to make the number negative */ + outval(val | 0x80000000,FALSE); + code_idx+=opargs(1); + break; } else { strcpy(s2+1, str); error(1,sc_tokens[tSYMBOL-tFIRST],s2);