Author Topic: Inconsistent results...  (Read 1303 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Inconsistent results...
« on: June 06, 2019, 12:34:48 AM »
 Hello Charles, if there are no updates yet, I would like to ask for one that may be complex...
but certainly easier than it would be for me to achieve the same.

 It doesnt matter if i have to wait, because this is going to represent a few days or even weeks
of work that you may have easier access to fixing.

 With all the pain in my soul, I'm going to have to roll my operator routines back, not because
they dont work, but because they run inconsistently between 32bit and 64bit, and sometimes
the executable is produced corrupted. I dont know why, but removing the code for the operators
fixes the issue.

 Please see image attached. PluriBASIC displays that error, but the produced executable does not
run if i invoke it from the windows Explorer either.

 These are my routines, i dont see anything wrong with them. Maybe implementing them at a
lower level will fix any issues.

Code: [Select]
FUNCTION ¤NOT(byval quad v1) AS QUAD
    dword w1
    dword w2
    quad r   
    copy @w1, @v1, 4
    copy @w2, @v1+4, 4   
    w1 = not(w1)
    w2 = not(w2)   
    copy @r,   @w1, 4
    copy @r+4, @w2, 4
    return r
END FUNCTION

FUNCTION ¤AND(byval quad v1, v2) as quad
    dword w1
    dword w2
    quad r
    copy @w1, @v1, 4
    copy @w2, @v2, 4   
    w1 = (w1 and w2)   
    copy @r, @w1, 4   
    copy @w1, @v1+4, 4
    copy @w2, @v2+4, 4
    w1 = (w1 and w2)   
    copy @r+4, @w1, 4   
    return r   
end function

FUNCTION ¤OR(byval quad v1, v2) as quad
    dword w1
    dword w2
    quad r
    copy @w1, @v1, 4
    copy @w2, @v2, 4   
    w1 = (w1 or w2)   
    copy @r, @w1, 4   
    copy @w1, @v1+4, 4
    copy @w2, @v2+4, 4
    w1 = (w1 or w2)   
    copy @r+4, @w1, 4   
    return r   
end function

 I believe that, in order to fix them correctly, i may have to break the statements into parts and
compute every operation manually. This would represent a lot of work that you may already have
an bigger opportunity to get access to, because you are already doing that in your engine and i am not.

 I believe that basically what you would need to do, is to check if the operands are quads, or single or double,
then convert them to a quad and use the routines above. This would make them work properly, as it is
working here already but inconsistently, at the point of making it unusable.

 No rush, no pressure, no obligation either, but it would ease my work porting completely the engine, so
i request this as i have no way to do it at the moment (too much things to do).

 The reason i have to believe that you may have easier access to this is, is beause you are already using OR
with DWORD and LONG, it would just be a matter of  using QUADs to complete the operation with the routines
above. I believe this would complete the stuff needed to make the engine full 64 bit compatible, meaning it supports
also 64bit operators.

 Thanks for reading this long post! :)
 



Brian Alvarez

  • Guest
Re: Inconsistent results...
« Reply #1 on: June 06, 2019, 01:13:44 AM »
Btw... implementing them at low level would mean doing the calculations in a point in which
using assembly would be possible, making them much faster.

 And since you are going to have to fix this anyway...

Code: [Select]
print str(31 / 7 OR 3) chr(13, 10)
 You may as well work on 64bit operators.  ;D

 Please?  :)

Charles Pegge

  • Guest
Re: Inconsistent results...
« Reply #2 on: June 06, 2019, 02:11:39 AM »
Hi Brian,

Yes, assembler is shorter and faster for this kind of task. It should also be consistent for both platforms.

Code: [Select]
FUNCTION ¤NOT(byval QUAD v1) AS QUAD
  'asm
  addr rcx,v1
  not dword [rcx]
  not dword [rcx+4]
  return v1 
END FUNCTION

FUNCTION ¤AND(byval QUAD v1, v2) AS QUAD
  'asm
  addr rcx,v1
  addr rdx,v2
  mov eax,[rcx]
  and eax,[rdx]
  mov [rcx],eax
  mov eax,[rcx+4]
  and eax,[rdx+4]
  mov [rcx+4],eax
  return v1 
end function

FUNCTION ¤OR(byval QUAD v1, v2) AS QUAD
  'asm
  addr rcx,v1
  addr rdx,v2
  mov eax,[rcx]
  or eax,[rdx]
  mov [rcx],eax
  mov eax,[rcx+4]
  or eax,[rdx+4]
  mov [rcx+4],eax
  return v1 
end function