gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Loading a signed byte

#17517 - Lupin - Tue Mar 09, 2004 8:01 pm

What is the fastest way to do it?

I am currently using this:
ldrb r4,[r11,r1]
mov r4,r4,lsl #24
mov r4,r4,asr #24

#17520 - jd - Tue Mar 09, 2004 8:38 pm

Erm... Use the "load signed byte" instruction. :)

Code:

ldrsb r4,[r11,r1]

#17522 - Lupin - Tue Mar 09, 2004 8:57 pm

The obvious! O.o

[Images not permitted - Click here to view it]


Last edited by Lupin on Tue Mar 09, 2004 11:28 pm; edited 1 time in total

#17533 - Miked0801 - Tue Mar 09, 2004 11:07 pm

like teh suxors? None that here please ;)

#17535 - Lupin - Tue Mar 09, 2004 11:22 pm

maybe it's just a typo :P

Now that i am already writing i got another question...
I was told that i can do this...
cmp r0, #0
movlt r0, #0
...in one instruction, is that true?

#17536 - jma - Tue Mar 09, 2004 11:25 pm

I don't know about that, but you can certainly do:

asr r0,r0,#31

Now r0 is -1 if it was negative or 0 if not. Doing an MVN instruction right after should flip this if you want.

Jeff
_________________
massung@gmail.com
http://www.retrobyte.org

#17539 - Lupin - Tue Mar 09, 2004 11:43 pm

i had the flag already set but i didn't know :)

#17544 - Miked0801 - Wed Mar 10, 2004 12:56 am

Truthfully, a previous instruction should be able to give you the Zero/Carry/V flags. With that, you can easily 0 the register and probably do something else too. I love ARM assembly - what 20 things do you want to do at the same time today? :)