EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 13 forks source link

MC6800: __boolf __notf helper missing. #151

Closed zu2 closed 3 weeks ago

zu2 commented 3 weeks ago

sample program:

/*
 *      float bool
 */

int main(int argc, char *argv[])
{
  float a=3.0;

  if(a) {
        //
  }
  if(!a) {
        //
  }
  return 0;
}
$ fcc -O3 -m6800 9040-float.c
/opt/fcc//lib/6800/crt0.o: Unknown symbol '_exit'.
9040-float.o: Unknown symbol '__boolf'.
9040-float.o: Unknown symbol '__notf'.

When the compiler calls boolf or notf, it pushes the arguments onto the stack. This is different from the behavior of integer types (integers are passed with hireg,D). I created a helper to match the behavior of the compiler, but I cannot confirm whether it is correct.

    .export __boolf
    .export __notf
    .code
;
; if the 32bit float is 0.0 returns 1. otherwise Returns 0.
; 32bit float: sign 1bit, exp 8bit, mantissa 23bit.
; when 0.0: sign=0 or 1 (+0 or -0), exp=0, mantissa=0
;        => 0x000000 or 0x800000

;
;   return address 0-2,x
;   arg 3-6,x
;
__boolf:
    tsx
    ldaa 3,x
    anda #$7F
    oraa 4,x
    oraa 5,x
    oraa 6,x
    bne true
    jmp __false4
true:
    jmp __true4
;
__notf:
    tsx
    ldaa 3,x
    anda #$7F
    oraa 4,x
    oraa 5,x
    oraa 6,x
    beq true
    jmp __false4
EtchedPixels commented 3 weeks ago

Merged. Fails on Z8 : needs debug

EtchedPixels commented 3 weeks ago

Z8 debugged