|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
assembly code optimizing
so i've been making some assembly code on sparc, now, is there a program which can optimize the program for me, like remove NOP's, etc and re-display the code?
please let me know, thanks. windows version is preferrable. |
|
#2
|
||||
|
||||
|
isnt that what the link loader does? from 'man ld'
Quote:
my question is: if you are already writing in asm, then why have you inserted NOP's in the first place? |
|
#3
|
|||
|
|||
|
because i'm just learning the language. so instead of learning how to rid them, which i somewhat know how to do, and which is time consuming, i thought there might be an easier way?
|
|
#4
|
||||
|
||||
|
im sorry but i still dont understand what you're talking about. maybe i'm slow or something, could u explain it better? r u trying to write shellcode?
|
|
#5
|
|||
|
|||
|
/*program that finds max value of 2x^3 - 7x^2 + 33x - 128 between x=-4 and x=6. */
Code:
.global main
main:
save %sp, -96, %sp !memory allocation
mov -4, %l0 !initialize -4 as start value
mov 6, %l1 !initialize 6 as end value
mov -1000, %l5 !set condition code -1000 for loop
loop:
mov %l0, %o0 !move constant into x
mov %l0, %o1 !move constant into x again
call .mul !multiply x*x
nop
mov %l0, %o1
mov %o0, %l3 !store x*x for later use
call .mul !multiply x*x*x
nop
mov 2, %o1 !set 2 for multiplying
call .mul !multiply 2*x*x*x
nop
mov %o0, %l4 !store 2x^3
mov %l3, %o0 !retrieve x^2
mov 7, %o1 !get 7
call .mul !7x^2
nop
sub %l4, %o0, %l4 !store (2x^3)-(7x^2)
mov %l0, %o0 !get x
mov 33, %o1 !get 33
call .mul !33*x
nop
add %l4, %o0, %l4 !store (2x^3)-(7x^2)+33x
sub %l4, 128, %l4 !store (2x^3)-(7x^2)+33x-128
check:
cmp %l4, %l5 !x>=0 then loop
bl next !if then goto next loop
nop
mov %l4, %l5 !store high value
nop
next:
cmp %l1, %l0 !check x
add %l0, 1, %l0 !x++
be end !goto end
nop
ba loop !goto loop
nop
end:
mov 1, %g1 !trap dispatch
ta 0 !trap to system
now, i need that optimized, such as filling delay slots by not using NOPs. |
![]() |
| Viewing: Dev Shed Forums > Other > Dev Shed Lounge > assembly code optimizing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|