School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 308,428 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,220 people online right now. Registration is fast and FREE... Join Now!




SPARC assembly, debugging problem.

 

SPARC assembly, debugging problem.

mattpd

3 Feb, 2009 - 06:25 PM
Post #1

New D.I.C Head
*

Joined: 15 Mar, 2008
Posts: 24

I wrote this program to compute multiple values of x, for a specific equation. My professor is going to set a break point in GDB at the label "done" and check the results. I have already done this and the results are correct, but the only problem is while debugging, GDB hits this break point at "done" 6 times (one for each x value). After hitting "c" to continue 6 times it finally exits. Why is GDB hitting this break point more than once? It should be running the "loop" 6 times, then finally reaching "done". Any ideas?

CODE

/*Constants are:*/

define(a2,56)
define(a1,14)

/*X and Y variable*/
define(x_r,l0)
define(y_r,l1)
define(x_max, l2)
define(y_max, l3)

    .global main
main:
    save  %sp, -96, %sp
    mov -2, %x_r

    .global loop
loop:
    cmp %x_r, 5      !Check if X is less than 5, if not jump to done.
    bge done
    
    mov %x_r, %o0  !This will compute x^6, the first part of equation
    mov %x_r, %o1
    call .mul
    nop
    mov %x_r, %o1
    call .mul
    nop
    mov %x_r, %o1
    call .mul
    nop
    mov %x_r, %o1
    call .mul
    nop
    mov %x_r, %o1
    call .mul
    nop
    mov %o0, %y_r       !Completes first part, and stores in y.

    mov %x_r, %o1       !This will compute 14x^2
    mov %x_r, %o0
    call .mul
    nop
    mov a1, %o1
    call .mul
    nop
    sub %y_r, %o0, %y_r !completes first two parts of equation

    mov a2, %o0         !computes 56x.
    mov %x_r, %o1
    call .mul
    nop
    add %y_r, %o0, %y_r !equation complete. Store result in y_r.

    cmp %y_r, %y_max    !Check to see if y_r is larger than previous.
    bg update           !If so, go to update
    cmp %y_r, %y_max
    ble loop
    nop
    
    
    
    


update:
    mov %y_r, %y_max  !y_r was bigger, so it replaces y_max
    mov %x_r, %x_max  !the corresponding x_r replaces x_max
    add %x_r, 1, %x_r !x++
    ba loop           !Go back to the loop.
    
done:    
    mov 1, %g1
    ta 0



User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/24/09 01:47PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month