Who's Online
79 user(s) are online (
47 user(s) are browsing
Forums )
Members: 0
Guests: 79
more...
Headlines
resrc4.lha - development/misc
Dec 15, 2025
amigagpt.lha - network/chat
Dec 15, 2025
vault.lha - network/misc
Dec 15, 2025
rvncd.lha - network/server
Dec 15, 2025
amiarcadia.lha - emulation/gamesystem
Dec 12, 2025
ticklish.lha - utility/misc
Dec 11, 2025
catacombgl.lha - game/fps
Dec 10, 2025
ubek.lha - game/fps
Dec 10, 2025
allkeys.lha - utility/misc
Dec 9, 2025
opengw.lha - game/shmup
Dec 8, 2025
Topic options
View mode
Newest First
DSI error in assembler code
Posted on:
2010/9/15 0:25
#1
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:01
From Norway
Group:
Registered Users
C code that works!
*((unsigned int *) (&output)) = *((unsigned int *) (&input));
// GCC loads r11 whit input address
10003b0 : 3d 20 01 01 lis r9 , 257
10003b4 : 39 69 00 40 addi r11 , r9 , 64
// GCC loads r9 whit output address
10003b8 : 3d 20 01 01 lis r9 , 257
10003bc : 39 29 00 48 addi r9 , r9 , 72
// GCC loads input address (r9) in to r0
10003c0 : 80 09 00 00 lwz r0 , 0 ( r9 )
// GCC store r0 outout address (r11)
10003c4 : 90 0b 00 00 stw r0 , 0 ( r11 )
This code crash!!!
asm(
" lwz 3,0(%1) \t\n"
" li 4,0 \t\n"
" stwbrx 3,4,%0"
:: "r" (&output), "r" (&input) );
// inline asm loads r11 whit input address
10003c8 : 3d 20 01 01 lis r9 , 257
10003cc : 39 69 00 40 addi r11 , r9 , 64
// inline asm loads r0 whit outout address
10003d0 : 3d 20 01 01 lis r9 , 257
10003d4 : 38 09 00 48 addi r0 , r9 , 72
// inline asm trys to load from r0 and crash
10003d8 : 80 60 00 00 lwz r3 , 0 ( 0 )
// not executed ...
10003dc : 38 80 00 00 li r4 , 0
10003e0 : 7c 64 5d 2c stwbrx r3 , r4 , r11
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: DSI error in assembler code
Posted on:
2010/9/15 2:04
#2
Quite a regular
Joined: 2006/12/2 0:35Last Login
: 2024/1/19 10:37
From Sydney
Group:
Registered Users
@LiveForIt So where is the register dump from the crash? What values were actually in the registers? Are those values what you expected? You seem to have your "input" and "output" addresses reversed.
cheers tony
Re: DSI error in assembler code
Posted on:
2010/9/15 5:32
#3
Not too shy to talk
Joined: 2006/11/28 14:16Last Login
: 2014/4/18 12:26
From Weston-Super-Mare, Somerset, UK, Europe, Earth, Milky Way, The Universe
Group:
Registered Users
@LiveForIt The lwz is reading from 0(0), you probably meant 0(r0). Try using a different register.
Re: DSI error in assembler code
Posted on:
2010/9/15 10:46
#4
Just popping in
Joined: 2006/11/24 17:08Last Login
: 2017/1/13 12:21
From Aachen, Germany
Group:
Registered Users
@LiveForIt
Quote:
LiveForIt wrote:
asm (
" lwz 3,0(%1) \t\n"
" li 4,0 \t\n"
" stwbrx 3,4,%0"
:: "r" (& output ), "r" (& input ) );
r0 can never be used as an address, it will always be 0 when used in such a way.
To ensure that a register is taken that works as a memory address, use the "b" constraint. Also, for memory references themselves (as in the lwz), you can use use "m".
Finaly, stwbrx is defined as
stwbrx rs, ra, rb
and the effective address is (ra|0)+(rb), so the code can be compressed llike this (since r0 is automatically used as constant 0, no need to load an additional register with it):
asm (
" lwz 3,%1\t\n"
" stwbrx 3,0,%0"
:: "b" (& output ), "m" ( input ) : "3" );
Note that this also adds r3 to the globbered registers, meaning that their value is undefined after the asm statement (otherwise, the compiler might assume that r3 wasn't change, which it was).
You might want to check if this works better for you.
Re: DSI error in assembler code
Posted on:
2010/9/22 23:15
#5
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:01
From Norway
Group:
Registered Users
@tfrieden Thanks, I it works now.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)