![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 11
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Professional Programmer
|
gcc -S file.c ..
![]() your professor should be there for questions, go see him. We can teach you assembley in a post. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 11
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
.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)"
__________________
|
|
|
|
|
|
#5 | |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Quote:
__________________
"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 |
|
|
|
|
|
|
#6 |
|
Newbie
Join Date: Feb 2005
Posts: 11
Rep Power: 0
![]() |
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
HLTLast edited by samra; Feb 22nd, 2005 at 2:15 AM. |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Feb 2005
Location: Charlottesville, VA (rated #1 place to live)
Posts: 25
Rep Power: 0
![]() |
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) ![]() |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Feb 2005
Posts: 11
Rep Power: 0
![]() |
thank you, i couldnot follow. & yes assembly is difficult. right now we are using the turbo pascal editor.
regards |
|
|
|
|
|
#9 |
|
Newbie
Join Date: Mar 2005
Location: South Africa
Posts: 21
Rep Power: 0
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|