I came across this code the other day, i cant figure out how it works. first it's odd that it uses int 21h with AH loaded with 02h cause that's for printing characters onto the screen and it just adds 30h to the value of DL once, so it doesnt convert the digits one by one, then instead of JUMP it uses CALL so that the stack is pushed a word onto. i just don't get it

Posted on 2006-04-13 22:00:36 by XCHG
For each CALL used, the RET will cause execution to continue after CALL (CALL pushes EIP onto the stack). So in effect, the "PrintIt" function will be called as many times as it is needed by simply using RET. The final RET will return to the original code that called WriteInt.

Pretty efficient for a number-by-number print function :)
Posted on 2006-04-14 01:20:50 by SpooK
It's a recursive function. It's quite neat ;)
Posted on 2006-04-14 05:09:51 by roticv
Very nice function. :) Where did you get it from?
Posted on 2006-04-14 06:35:57 by ti_mo_n
Hell yeah i just figured it out, so instead of for example CALL MyProcedure we can use this : PUSH OFFSET MyProcedure and then use RET

Thank you guys

Oh and btw it's a part of a project called NGASM, you can download the tutorial at www.download.com
Posted on 2006-04-14 21:05:09 by XCHG