Want to take part in these discussions? Sign in if you have an account, or apply for one below
Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
1 to 12 of 12
Bah, I really hate those simple simple simple programming mistakes. I bumped into one this morning a little bit after midnight (I don't know the time exactly though) and I didn't figure out what was wrong until 6:28 am... I spent many hours trying to figure this one out.
Pretty much I was programming in x86 assembly for GAS (GNU Assembler) on Linux. I just learned how to open files, close files, write to them, read from them, retrieve argc, your program name from within the program, and retrieve argv. Anyhow, I decided to practice by writing my own version of cat in assembly. I then decided to write my own version of echo. I then tried writing something that would just ouput argc. For some reason, I couldn't get argc to output!
This was suppose to simply return the number of arguments (argc). For example, if the binary for this was called test, executing ./test 1 2 3 should output 4 (it's including the program name). When I executed the program, it would return nothing. I was staring to get mad, browsed the Internet like crazy, poked at the code trying to figure out why it wasn't working. Spent hours and hours. I was gettng really mad because it's suppose to be this ultra simple thing.
Anyhow, the answer was really simple, it was because I wasn't converting the number into ASCII . I found out when I decided to test it by not printing out the number, but have it return argc when the program exits and then just executing echo $?. It worked, I talked with a friend and that's when it all made sence, I wasn't converting into ASCII, which means all I had to do was add 48 to the number....If it has multiple digits, I already created an algorithm long ago when I was programming in Perl that would was really basic, it didn't use anything fancy, and I could do it in assembly without too much trouble I think, it would just look really really really scary. We can even discuss that algorithm later if you guys want to.
Well, I am glad I am finally getting my hands dirty with assembly. C just isn't enough for what I want to do.
I decided to post this little rant, I also know that a lot of you guys are web developers and programmers, and more likely have bumped into an issue like this before, I have, and probably have a story to tell so please share!
sialer: Aprz I appreciate what you've done and this is a free forum. Do not be discouraged by savages of the popular crowd.