User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 429,971 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,575 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 1427 | Replies: 1
Reply
Join Date: Mar 2007
Posts: 1
Reputation: 8ball is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
8ball 8ball is offline Offline
Newbie Poster

a little assembly app for arm cpu

  #1  
Mar 15th, 2007
I need to create a little assembly app for arm cpu which reads two 32 bit numbers from the address which register r0 points out. Then it compares absolute value of those two numbers and puts them back to those same addresses the way there's number which absolute value is higher in the first address. Finally the app sets 0 as the register r0 value, if the numbers were in the right order and sets 1 if the number orders needed to be changed.

The problem is that my little app isn't workin.
Hope someone can help me solve the problems there. thanks.

  1. ldr r1,[r0,#0]
  2. ldr r2,[r0,#4]
  3. mov r3,#-1
  4. cmp r1, #0
  5. mulmi r4, r1, r3
  6. movpl r4, r1
  7. cmp r2, #0
  8. mulmi r5, r2, r3
  9. movpl r5, r2
  10. subs r3,r4,r5
  11. strmi r1,[r0,#4]
  12. strmi r2,[r0,#0]
  13. strpl r2,[r0,#4]
  14. strpl r1,[r0,#0]
  15. movpl r0,#0
  16. movmi r0,#1
Last edited by 8ball : Mar 15th, 2007 at 4:48 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Location: South Florida
Posts: 4
Reputation: bitbank is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bitbank's Avatar
bitbank bitbank is offline Offline
Newbie Poster

Re: a little assembly app for arm cpu

  #2  
Mar 23rd, 2007
Originally Posted by 8ball View Post
I need to create a little assembly app for arm cpu which reads two 32 bit numbers from the address which register r0 points out. Then it compares absolute value of those two numbers and puts them back to those same addresses the way there's number which absolute value is higher in the first address. Finally the app sets 0 as the register r0 value, if the numbers were in the right order and sets 1 if the number orders needed to be changed.

The problem is that my little app isn't workin.
Hope someone can help me solve the problems there. thanks.

  1. ldr r1,[r0,#0]
  2. ldr r2,[r0,#4]
  3. mov r3,#-1
  4. cmp r1, #0
  5. mulmi r4, r1, r3
  6. movpl r4, r1
  7. cmp r2, #0
  8. mulmi r5, r2, r3
  9. movpl r5, r2
  10. subs r3,r4,r5
  11. strmi r1,[r0,#4]
  12. strmi r2,[r0,#0]
  13. strpl r2,[r0,#4]
  14. strpl r1,[r0,#0]
  15. movpl r0,#0
  16. movmi r0,#1


The problem is easy to fix. You used an unsigned multiply. Another way of doing it is this:

LDMIA r0,{r1,r2}
orrs r1,r1,r1
rsbmi r4,r1,#0
movpl r4,r1
orrs r2,r2,r2
rsbmi r5,r2,#0
movpl r5,r2
cmp r4,r5
strlt r2,[r0]
strlt r1,[r0,#4]
mov r0,#0
movlt r0,#1

There's no need to write back the 2 values if their places don't need to be swapped.

Larry B.
P.S. my blog covers topics like this:
bitbank.wordpad.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 11:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC