08 January 2018, 22:44 | #1 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
vbcc 0.9e signed multiplication issue?
I'm struggling with the most basic of things now it seems.
This function (signed multiplication) Code:
int foo(int a, int b) { return a*b; } Code:
; stacksize=0 near code opt 0 opt NQLPSMRBT public _foo cnop 0,4 _foo movem.l l132,-(a7) move.l (4+l134,a7),d0 move.l (8+l134,a7),d1 move.l d0,d2 move.l d1,d3 swap d2 swap d3 mulu.w d1,d2 mulu.w d0,d3 mulu.w d1,d0 add.w d3,d2 swap d2 clr.w d2 add.l d2,d0 l130 l132 reg d2/d3 movem.l (a7)+,d2/d3 l134 equ 8 rts Code:
devkit/tools/win32/vbccm68k.exe -I. -Idevkit/vbcc-targets/m68k-amigaos/include -Idevkit/include -c99 -quiet -D__VBCC__ -D__AMIGA__ -D__MINSTART__ -DOVERSCAN=1 -cpu=68000 -O=0 -maxoptpasses=65535 -dontwarn=72 -sc -DNDEBUG -o=main._s main.c |
08 January 2018, 23:09 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
A 32 bit multiply on a 16 bit CPU?
|
09 January 2018, 00:46 | #3 |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
|
Are you getting incorrect results?
You're asking for a pair of 32-bit values to be multiplied, and for the lower 32-bits of the result (which would be 64-bit) to be returned, and that's what the code is doing. It doesn't matter that the code is using mulu for this - I think the difference in results between signed and unsigned multiplication will be in the upper 32-bits of the result, which you're discarding. |
09 January 2018, 08:47 | #4 | |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Quote:
I'm having weird sign-related errors in my program, but it must be related to something other than multiplication. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbcc bss clearing issue | dalton | Coders. C/C++ | 3 | 02 December 2017 22:50 |
vbcc 0.9f (windows) local includes issue? | dalton | Coders. C/C++ | 4 | 29 July 2017 21:33 |
vbcc 0.9d | phx | News | 43 | 13 July 2015 19:41 |
Best Way to Convert 32-bit Signed Value to 16 Bit? | AGS | Coders. Asm / Hardware | 31 | 29 December 2013 13:58 |
64 bit signed multiply | cdoty | Coders. General | 2 | 16 December 2007 12:24 |
|
|