![]() |
|
#51
|
|||
|
|||
Re: Assembly Tutorial?Code:
CPP / C++ / C Code:
Code:
So very good!!! What's next? Implement your invention into a function??? (yes) Ready to move into the 'power.s' function example of "Programming From the Ground Up"? |
|||
|
#52
|
|||
|
|||
Re: Assembly Tutorial?Hi, Howard. Finally all those posts did not go to waiste, first of all thanks for all your support i think this step would not be accomplished without your help.
CPP / C++ / C Code:
CPP / C++ / C Code:
1-what happen if we add two bytes together and the sum is > FF let's say : item1: .byte 0xff. add $0x30,item1 ==> item1 = 12f > ff so may be that overflow but what happen to the first byte in item1 then what will be in item1+1byte. Last edited by zatora : 02-Jan-2009 at 23:28.
|
|
#53
|
|||
|
|||
Re: Assembly Tutorial?Well first play around with one byte in a register and see how the operators work. Then work with data space.
Try using the next size up just for the incrementing , then gdb-check the bl bh bx and ebx registers for the exciting results!!!. CPP / C++ / C Code:
Quote:
As Bill would say, where do you want to go today..... (yeah right, a bigger machine is where , $cha$ching ) Sorry, that's all I've got right now, I gotta go. Last edited by Howard_L : 03-Jan-2009 at 12:51.
|
|
#54
|
|||
|
|||
Re: Assembly Tutorial?Hi all,
Howard, i need some guidance before i start posting some weirdo questions again (lol) esp : ebp: eip: what is the difference between these registers in terms of which one hold the address pointed by the stack when we pop our stack i read it through the book i got a little confused so i wanted to have a different perspective i am still digging chap 4 in the book. I have to admit i am kinda afraid of the stack part cause in school they did not coverthat well. I hope you have a better way to explain the stack operation and these register how they are related to the stack in terms of addressing mode thank you. |
|
#55
|
|||
|
|||
Re: Assembly Tutorial?I made a small example program and tried to explain the stack pointers and their use.
Compile, link and run in gdb using the gdb display setup lines as I show in the code sample. Run up to the 'STOP 1' , then step through the program as you read the explaination text which follows the code. CPP / C++ / C Code:
Code:
Code:
|
|
#56
|
|||
|
|||
Re: Assembly Tutorial?Quote:
Here you touched a gray zone in my c ++ ? because i don't really get What is a pointer and that the NULL pointer ? is the null pointer a pointer initialized to zero Also the arg[c] arg[v] i saw that in c but what is arg[c] anyway ? i know a function like : double example_function(arg 1, arg 2, ......arg n) but when it comes to something like main(arg[v]. arg[c]) i don't even know what is that also i saw this and i did not get it $1 = (void (*)()) 0x8048077 <_start+3> i did obtain the same result when i did use gdb to examine the decimal value in ebp and eip and esp so what is the start in void it is a pointer Other than that i am following your last post and also i am working at the power function in chap 4 |
|
#57
|
|||
|
|||
Re: Assembly Tutorial?Quote:
See what value prints for 'NULL' in C or C++. Quote:
It's for getting user input from the command line and it's: CPP / C++ / C Code:
The value of argc is the number of command line arguments the user gave. argv is a pointer to an array of pointers zero terminated strings. Learn it NOW: gidforums.com/t-14554.html?highlight=command+line+args Quote:
You left off the preceding command it's like this: Code:
It is saying that the value in (void*)eip is 0x8048077 and that that address is at <_start+3> (3 bytes up from _start) Keep going over the function until you 'get it' |
|
#58
|
|||
|
|||
Re: Assembly Tutorial?I am so sorry i did not realize that i typed start intead of star
so i want to define a pionter first than why we see a void in the stack related registers we don't see values like what is void( *) i saw even functions written this way int func1(void())and this is what i wanted to say. thank you ( i am reading the argc , argv[]) by the way you said what they teach us in school well listen tothis 1 - my first c++ class when we started functions i asked the teacher what is the difference between void and a non void function the answer was " the first does not return value and we can use to return more than one value) but the non void return only one value 2-my second class in c++ i goes what is the void type anyway and what is argc and argv[] the answer was: well "it is a void type that does not return any value and he said don't worry too much about argc , argv[] for now. but they charge 800$ per class to tell you that (LOL) (lol : it said maybe it is not that funny after all) bye for now |
|
#59
|
|||
|
|||
Re: Assembly Tutorial?Quote:
But I guess they are teaching you something you seem to be doing pretty well. I don't know why they try to start at the top... Lack of basic understanding leaves you with way too many question marks. Yes? Is your textbook any good? Do you use it??? Get yourself a K&R Second Eddition for C basics. No offense but could you Capitalize the first letter of a sentence and end it with a period for clarity. I'm getting old and it is hard to pick up where you end one thought and begin the next. Are you allowed to turn in work like that? Think of 'void' as a datatype just like char, int etc.. The wierd thing though is that void means 'no datatype'. Strange huh. So when we see: void myfunction(void) { blah } we are saying: 'no retun data' myfunction('no argument data') These things need to be known so that the compiler can make code to handle (or not for void) argument dataspace in the stack and/or retrieve return values. I C when we declare a pointer we also associate a datatype with to like this: char * cptr The * indicates you want a pointer (an int size spce to hold an address), and char indicates we intend to use it to point to char size data (1byte) When we increment or derement the pointer it adjusts by sizeof char (1 byte). If it were pointer to short it would be two, pointer to int: four, etc. Now, we can also declare: void * vptr; vptr would have NO size associated with it. So data size is a VERY big deal and people are interested to know... espeially when debugging! gdb takes this into consideration with it's report: Code:
In assembly we have to handle size issues ourselves with things like movb, mov, movl, movq. So it's not really of too much interest to us BUT gdb is for C and C++ too. If you were debugging either of them it might be real handy to see that in the printout in order to solve a problem. It could very well be the key! Get too know these two references to know more about C in general and here is a primer (the pointer section): Programming in C: A Tutorial Brian W. Kernighan lysator.liu.se/c/bwk-tutor.html#pointers ...and this is EXCELLENT: A TUTORIAL ON POINTERS AND ARRAYS IN C by Ted Jensen home.netcom.com/~tjensen/ptr/pointers.htm Last edited by Howard_L : 13-Jan-2009 at 13:54.
|
|
#60
|
|||
|
|||
Re: Assembly Tutorial?Hi, all
i was trying to follow the power function in chapter 4 where this is the source code. CPP / C++ / C Code:
we pushed 3 on the stack so 3 is at esp-4 we pushed 2 on the stack so 2 is at esp-8 then we are calling power. we pushed ebp on the stack so ebp is at esp-12 we copied the esp into ebp so ebp =esp-12 subl $4, %esp so our stack is at esp-16 (not sure here) movl 8(ebp),%ebx so we are at the value 2 cuz ebp =esp-12 so if we add 8(ebp) then we are at the argument =2 movl 12(ebp), %ecx we are moving 12(ebp) =12(esp-12) which equal to 3 movl %ebx, -4(%ebp) so this is going back to where the esp were wich esp-16 or ebp-4 so we are moving the first arg=2 from ebx to ebp-4 if i am following it right till here then i am going into the right way other wise i need some intervention from your side. (btw i had to this from work my pc is down and i am trying to fix so i can't use gdb ) on a different topic i am taking java class in school i googled some java compiler and i fount netbeans......(your comments here are needed please!!!) also i am pround that i don't do Windows Anymore i just hate it i can believe 400$ for an OS (vista ultimate ) does it have 24k gold inside or what ??? thanks as always. |
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mixing C and assembly in x86 - Makefile nuances | aijazbaig1 | Assembly Language | 3 | 23-Apr-2008 09:29 |
| Tutorial: How to Make a Web 2.0-Style Logo | PhotoshopTrend | Graphics Forum | 0 | 20-Sep-2007 06:57 |
| Assemblers & assembly language | BlueFireCO. | Assembly Language | 2 | 26-Mar-2007 10:56 |
| Photoshop Tutorial: Make An Inspirational/Mystical Picture | ToddSAFM | Graphics Forum | 9 | 09-Aug-2005 21:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The