Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 21st, 2005, 10:17 AM   #1
samra
Newbie
 
Join Date: Feb 2005
Posts: 11
Rep Power: 0 samra is on a distinguished road
Unhappy urgent: please EXPERTS: convert C to assembly

HI, i am new here & i urgently need help :o
I need to rewrite this code in assembly language making the right adjusments
INTEGER B = 0
INTEGER C = 10
INTEGER D = 100
for (A= 15 ; A>=0; A--) 
{
B += C;
IF (B >= D)
B += C;
}

please please please i really need this urgently iam drawning in search & iam new in programming . help me. my professor will kill me
& i will appreciate your help very much it really means alot for me.
samra is offline   Reply With Quote
Old Feb 21st, 2005, 10:59 AM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
gcc -S file.c ..
your professor should be there for questions, go see him. We can teach you assembley in a post.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Feb 21st, 2005, 1:23 PM   #3
samra
Newbie
 
Join Date: Feb 2005
Posts: 11
Rep Power: 0 samra is on a distinguished road
thanku. nice to take time & reply.
u think i want the nswer ready?
well, no it's not this.
our pro. is not the kind of professors that might answer.
this is just a course in microprocessor lab & he gave us the assignment & did not teach us these stuff (self study i think)
but i am new & i really spent a lot of hours searching & i didn't get it. it's all driving me crazy with all the code & commands i see & i don't understand a bit.
+ i searched 3 books & not get any clue
is this it? u won't help me???

ok just give me aclue & i will continue my self.
i want to learn please
regards
samra is offline   Reply With Quote
Old Feb 21st, 2005, 2:29 PM   #4
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
        .file   "test.c"
        .text
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        movl    $0, -4(%ebp)
        movl    $10, -8(%ebp)
        movl    $100, -12(%ebp)
        movl    $15, -16(%ebp)
.L2:
        cmpl    $0, -16(%ebp)
        jns     .L5
        jmp     .L3
.L5:
        movl    -8(%ebp), %eax
        leal    -4(%ebp), %edx
        addl    %eax, (%edx)
        movl    -4(%ebp), %eax
        cmpl    -12(%ebp), %eax
        jl      .L4
        movl    -8(%ebp), %edx
        leal    -4(%ebp), %eax
        addl    %edx, (%eax)
.L4:
        leal    -16(%ebp), %eax
        decl    (%eax)
        jmp     .L2
.L3:
        movl    $0, %eax
        leave
        ret
        .size   main, .-main
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-3)"
__________________

tempest is offline   Reply With Quote
Old Feb 21st, 2005, 7:32 PM   #5
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Quote:
Originally Posted by samra
+ i searched 3 books & not get any clue
is this it? u won't help me???

ok just give me aclue & i will continue my self.
i want to learn please
regards
Dizzutch was trying to help you. What he was saying, is that if you have a copy of the GNU C compiler, then using the command he gave will turn your C code into assembly code.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Feb 22nd, 2005, 12:50 AM   #6
samra
Newbie
 
Join Date: Feb 2005
Posts: 11
Rep Power: 0 samra is on a distinguished road
thanku Dizzutch, tempest, Machiavelli, and all those who passed by.
i am sorrrrrrry for the misunderstanding. but i am REALLY NEW. & feel bad about my unconsciousness. in fact i use command prompt (DEBUG) to write the code, till now we have not met any of the assemblers i saw many talk about in the internet, like MASM, RASM etc.. if i am not wrong.
again thanks alot. & sorry for not mentioning this in the beginning.
& tempest i dont get the code u wrote, :o sorry
here is the code i felt will work but am not sure coz i don't know how to test
        MOV BX,0   ; THIS IS THE B=0
        MOV CX,10 ; THIS IS THE COUNTER a=15
        MOV AX,A  ; AX=C = 10
        MOV DX,64 ; D=100
ONE :CMP CX,0
        DEC CX
        JGE LP
LP:    ADD BX,AX
        CMP BX,DX
        JL ONE
        JGE LP
        HLT
any body know what i am talking about, if u dont mind check. & tell me whats wrong or what should be corrected?

Last edited by samra; Feb 22nd, 2005 at 1:15 AM.
samra is offline   Reply With Quote
Old Feb 22nd, 2005, 7:07 PM   #7
Christian_Rosenkreuz_777
Newbie
 
Join Date: Feb 2005
Location: Charlottesville, VA (rated #1 place to live)
Posts: 25
Rep Power: 0 Christian_Rosenkreuz_777 is on a distinguished road
In the debug util. . .

I don't know exactly how much you know, so I'll walk you through this step by step (btw, this is on how to test your program).

1.) type 'a'
2.) type your code
3.) type 'n'+(insert desired name of program here)+'.com' or '.exe' (depends on
presence or lack of stack; since you're a newbie, it's probably .com)
4.) type 'RCX'
5.) type 'A'
6.) type 'w'
7.) type 'q'
now just go to the directory where your program was and run the program by the name you gave it in step 3 (minus the 'n')
Hope this helps. I know assembly's hard (trust me)
Christian_Rosenkreuz_777 is offline   Reply With Quote
Old Mar 2nd, 2005, 11:11 PM   #8
samra
Newbie
 
Join Date: Feb 2005
Posts: 11
Rep Power: 0 samra is on a distinguished road
thank you, i couldnot follow. & yes assembly is difficult. right now we are using the turbo pascal editor.
regards
samra is offline   Reply With Quote
Old Mar 11th, 2005, 2:53 PM   #9
liquidsilver
Newbie
 
liquidsilver's Avatar
 
Join Date: Mar 2005
Location: South Africa
Posts: 21
Rep Power: 0 liquidsilver is on a distinguished road
I suggest you download MASM (or the likes) as it just makes it soo much easier.

Thanx for that gcc tip, I never new
__________________
Small is beautiful
liquidsilver is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC