![]() |
| ||
| comparing return values of subroutines hey everybody. i've got what might be a simple question about return values of subroutines in assembly. okay here goes. say i've got a subroutine that under normal conditions will do a normal return (RET), and under one condition will return zero (RET 0). so now back in main after this function has been called, i need to compare the return value with zero....only i dont know what the syntax is, or rather, how a subroutine's return value can be referenced in main. does anyone know how to do this? can i just do cmp 0??? i havent tried it, but it doesnt seem right. thanks in advance. my code is below. i know it looks liek a lot, its mostly subroutines, and the part i need help with is towards the bottom. THANKS AGAIN TITLE Homework 7 |
| ||
| Re: comparing return values of subroutines Return values are normally passed back in registers -- its standard practice to put a 16-bit int (short in C) in AX, 32-bit in EAX or DX::AX and 64-bit on EDX::EAX. But you can do it anyway you want. pointers to arrays etc are done the same way. If those registers contain anything the calling function needs to keep then push them onto the stack before calling the function. |
| ||
| Re: comparing return values of subroutines Quote:
it seems to me then, that nothing is actually returned in terms of data that the subroutine computed. is that an accurate statement? below is my updated code. TITLE Homework 7 so just for your own edification, this program is supposed to prompt the user twice, once to change the foreground color with char codes (r, g, b, y, w) and once to change the background with the same codes. its supposed to keep prompting until the user enters an empty string after either of the prompts. so now am i returning values correcntly? thanks. also if anybody has a burning desire to run my code and check it out feel free! :icon_cheesygrin: |
| ||
| Re: comparing return values of subroutines Quote:
Quote:
|
| ||
| Re: comparing return values of subroutines Quote:
Also what is the syntax for returning zero if it is automatic? can i just say RET 0....as in.... ret 0 ???? I know I have a lot of questions, but I'm not an assembly pro...not anywhere near it. So please be clear and articulate with your answers cuz I want to understand rather than just know YES or NO you can't do that in assembly. thanks WaltP and Ancient Dragon for your responses so far... |
| All times are GMT -4. The time now is 6:43 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC