[Done] PB 6.00 Alpha 3 - Different type casting (C and ASM) during operations with quads and longs

All bugs related to new C backend
User avatar
STARGÅTE
Addict
Addict
Posts: 1621
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

[Done] PB 6.00 Alpha 3 - Different type casting (C and ASM) during operations with quads and longs

Post by STARGÅTE »

Combining Quads and Longs in various operations result in different values in the ASM-backend and C-backend:
(Probably related to viewtopic.php?f=43&t=77574)

Code: Select all

Define Quad.q = $60000000
Define Long.l = $60000000

Define x.q
Define y.l

y = Long + Long
Debug "long = long + long = " + y
x = Long + Long
Debug "quad = long + long = " + x
x = Long + Quad
Debug "quad = long + quad = " + x
x = Quad + Long
Debug "quad = quad + long = " + x
x = Quad + Quad
Debug "quad = quad + quad = " + x
Debug "---"


y = Long * Long
Debug "long = long * long = " + y
x = Long * Long
Debug "quad = long * long = " + x
x = Long * Quad
Debug "quad = long * quad = " + x
x = Quad * Long
Debug "quad = quad * long = " + x
x = Quad * Quad
Debug "quad = quad * quad = " + x
Debug "---"
ASM-backend
long = long + long = -1073741824
quad = long + long = 3221225472
quad = long + quad = 3221225472
quad = quad + long = 3221225472
quad = quad + quad = 3221225472
---
long = long * long = 0
quad = long * long = 2594073385365405696
quad = long * quad = 2594073385365405696
quad = quad * long = 2594073385365405696
quad = quad * quad = 2594073385365405696
---
C-backend
long = long + long = -1073741824
quad = long + long = -1073741824
quad = long + quad = 3221225472
quad = quad + long = 3221225472
quad = quad + quad = 3221225472
---
long = long * long = 0
quad = long * long = 0
quad = long * quad = 2594073385365405696
quad = quad * long = 2594073385365405696
quad = quad * quad = 2594073385365405696
---
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 4.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
juergenkulow
User
User
Posts: 66
Joined: Wed Sep 25, 2019 10:18 am

Re: PB 6.00 Alpha 3 - Different type casting (C and ASM) during operations with quads and longs

Post by juergenkulow »

Code: Select all

; // x = Long + Long
; v_x=(v_long+v_long);
; 
; 00000001400010AD     | 8B05 D5460000            | mov eax,dword ptr ds:[140005788]     |
; 00000001400010B3     | 01C0                     | add eax,eax                          |
; 00000001400010B5     | 48:98                    | cdqe                                 |
; 00000001400010B7     | 48:8905 D2460000         | mov qword ptr ds:[140005790],rax     |
; eax is a 32 Bit Register, 64 bit needed.

; Try:
! v_x=((quad)v_long+v_long);

;-----------------------------------------------------------------------------------------

; // x = Long * Long
; v_x=(v_long*v_long);
; 
; 0000000140001153     | 8B05 2F460000            | mov eax,dword ptr ds:[140005788]     |
; 0000000140001159     | 0FAFC0                   | imul eax,eax                         |
; 000000014000115C     | 48:98                    | cdqe                                 |
; 000000014000115E     | 48:8905 2B460000         | mov qword ptr ds:[140005790],rax     |
; eax is a 32 Bit Register, 64 bit needed.

; Try:
! v_x=((quad)v_long*v_long);
Fred
Administrator
Administrator
Posts: 14413
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.00 Alpha 3 - Different type casting (C and ASM) during operations with quads and longs

Post by Fred »

Fixed.
Post Reply