#6 sign opcode gives always 1 with optimization

compiler
closed-fixed
John Hansen
NBC (24)
5
2007-04-25
2007-02-27
Anonymous
No

I use NBC on LINUX.
Thnak you for this wonderful program !!

# The Problem

Without optimization,

sign a, b

gives codes as follows:

1: set sb0002, 0x0
2: brtst EQ, lbl000F, ub0000
3: set sb0002, 0xFFFF
4: brtst LT, lbl000F, ub0000
5: set sb0002, 0x1
6: lbl000F: mov ub0003, sb0002

With optimization, line 6 is replaced by:

6: lbl000F: set ub0003, 0x1

Therefore, the result(ub0003) is always 1.

# A Solution

In uNXTClasses.pas, at line 7188,
please check whether ALNext has any label.

7185 else begin
7186 arg1 := AL.Args[0].Value;
7187 arg2 := ALNext.Args[1].Value;
7188 if (arg1 = arg2) then begin
7189 // set|mov __D0,whatever (__D0 or __stack_nnn)
7190 // mov X,__D0 <-- replace these two lines with
7191 // nop (if arg1 and arg2 are stack or register vari
7191 ables)
7192 // set|mov X,whatever

Discussion

  • John Hansen
    John Hansen
    2007-04-25

    Logged In: YES
    user_id=661666
    Originator: NO

    I implemented a fix for this bug in beta 28.

     
  • John Hansen
    John Hansen
    2007-04-25

    • status: open --> closed-fixed