#105 Incorrect code for rem = rem - (a*1024)

closed-fixed
z80 port (188)
5
2001-09-09
2001-08-08
No

From: Nick Dolling <ndolling@apexus.com.au>
To: michaelh@juju.net.nz
Subject: GBDK 2.95-2 bug(?) report

Hi,

I'm by no means a c expert, but I think I may have
come across a bug in
this release, relating to a right shift or multiply
by 2^n.

rem = rem - (1024*quot); // this doesn't work

it generates this..

lda hl,4(sp) // point to quot
ld b,(hl) // load LSB of quot
in b (MSB of result)
ld c,#0x00 // fill LSB of result
w/ zeros
inc hl // I think this is
the problem
ld a,(hl) // loads MSB of quot
(should be LSB?)
add a,a // shift right once
add a,a // shift right again
ld b,a // save result

quot <<= 10;
rem = rem- quot; // this works OK

quot *= 1024;
rem = rem- quot; // so does this

Discussion

  • Michael Hope

    Michael Hope - 2001-09-09
    • status: open --> closed-fixed
     
  • Michael Hope

    Michael Hope - 2001-09-09

    Logged In: YES
    user_id=373

    Fixed

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks