| |
| |
| |
|
Comments:
<0> gn <1> Hey guys <1> is anybody around to help me with some relativly simple code? <2> don't ask to ask, guy. it's, like, in the topic. <1> point taken <1> im doing an asm ***ignment for a college ***ignment <1> and have ran into some trouble figuring out why a certain buffer seems to get nulled out <1> i will post the code on a paste bin now <2> okay. <1> http://wraith.pastebin.ca/339335 <1> on here, i wish to print out the variable called buffer <1> in option2
<1> but it seems to be nulled out <1> but when i want to print it inside option1, it prints perfectly <1> any help will be very appreciated <2> eh. fine. <2> i'll do it rogerian-like. <2> what's wrong? <2> the program seems to be working <1> if you run the program, then enter option a, feed it a string, then it will print it back to you, you can then enter another option b, which should also print back the buffer but does not. <2> why do you think option b doesn't print back the buffer correctly? it works. <2> it prints current contents of buffer. <1> it doesnt seem to for me, it does successfully print it back to after it states String loaded into buffer <1> but thats not where i wanted it, was there just for a test <1> after it has printed the buffer, input b <1> and it prints out "printing out buffer" but is just a blank line <2> mhm. correct. because the buffer is empty. <1> Can you tell me how it has become empty? <2> what does getoption do? <1> gets the choice letter, moves into into ebx and compares it, depending on the outcome jmps to that label <2> how does it get the choice letter <2> ? <2> [btw, try this: run your program and type 'blah' into it. maybe you'll get it.] <1> it has outputted just lah. So it has used the b for the option choice and outputted the ramaindor <2> indeed. <2> how does getoption get the choice letter? <1> it moves the lea of the variable that is to contain the data, calls a sub that uses this information in loop fashion to getchar and then stores it in the variable? <2> what variable? <2> and what is exactly stored in it? <1> the vairable called choice, and what is stored inside of it is the hex equavilent of the inputted letter? <1> oh. does it append a null? <2> mhm. <2> how big is variable choice? <2> and how big is the stuff stored into it? <1> 1 byte? and it stores 1byte? <1> so theres no room for a null? <2> choice is 1byte. <2> but it stored more than one byte in it. <2> which is bad. <1> so data is overflowing on the stack? <2> it is overflowing. <2> but not on the stack. <2> it is overflowing inside your data segment <2> the next variable that happens to be there is buffer. <2> the null byte ends up in buffer <1> as the first byte? <2> and that's why our program prints nothing. <1> Thank you :]
<1> now its working fine. <2> out of curiosity... what sort of OS is this? <2> using GNU as and names beginning with underscore... <1> cygwin <2> ugh. suspected so. <1> dont have X on linux <1> and we need to use insight <1> wont allow CL gdb <3> how can they decide what programs you can use? ;) <1> I dont think its strict but they ask for evidence of use of insight inside of labs <2> speaking of which... why didn't you just debug this thing with insight and set a watch on buffer? <1> I guess I didnt think of that <1> Lesson learnt <1> Thank you for all your help :] <4> anyone mind helping me out with some very basic MIPS code? I'm trying to swap elements in an array... "abcdef" -> "badcfe" - http://pastebin.perl.se/0b0a8c7e6c/ <5> could someone explain why right after the function prologue gcc is anding -16 with the stack pointer? <5> that is actually the start of a sequence of 3 instructions that i don't understand what gcc is doing <6> where it shifts 16 bits one way and then the other? <5> andl $-16, %esp <5> movl $0, %eax <5> subl %eax, %esp <5> i should add that this only seems to appear in main() <6> well, the first part is padding the stack <6> but yeah, those prologs always make me have to look at them a while <5> could you explain what you mean by padding the stack? <6> well, -16 in 2's compliment is like 11111111111111111111111111110000 <5> right <6> so, anding that with the stack pointer ensures the stack pointer is at some multiple of 4 <5> ohh <6> lik,e making room for some data types or whatever <5> hmm <6> i'm totally a n00b-, but i've seen wierd prologs like that right before variable ***ignment <6> plenty of times <6> and it's always something like -16, -8, -24.... <5> before that it: 1) pushes the ebp 2) moves the esp to ebp 3) subtracts space for the amount of local variables from esp <6> right <5> so my understanding was the subtraction aboce was when it made room for the data <5> s/aboce/above <6> right <5> hmm i guess i'll have to think about it some more <6> what about a return value <6> is there a function call later int he code? <5> yeah. i just have a super simple main that calls another super simple function <5> (basically wanted to see what p***ing structs on the stack looked like) <5> what did you want to know about the return value? <6> my inclination is that whenever you see the anding with a small negative number, the compiler is padding the stack to line up some data with the addresses properly <5> i see. that sounds logical, but i'll have to let it rattle a round in my head a bit before i can get it :) <6> it's really important when you're talking about arrays or strings <6> though, usually a string is referenced off the heap <5> it sounds like it does that to avoid unaligned memory access <6> right <7> Hey, anyone know how to get IDA Pro to dis***emble 8051? Trying to write a port of something <3> 8051? <7> 8051 processor <7> doesnt seem to be on the processor list :S
Return to
#asm or Go to some related
logs:
qemu eth1 gdesklets startbar config ubuntu removegnome #perl downgrade nvidia driver ubuntu #ldap #mysql gaim transparentes icon krfb logs opensuse sendmail.mc FC compile how to
|
|