From: io_x on 7 Mar 2010 04:59 What about write one recursive function that can report all errors? do you see some error? ------------- ; nasmw -fobj this.asm ; bcc32 -v this.obj section _DATA use32 public class=DATA global _main extern _printf RecursiveVar dd 0 ; here the min stack address IRetrunIIuIn db "Retrun=%u" , 13, 10, 0, 0 section _BSS use32 public class=BSS section _TEXT use32 public class=CODE ; return 0 all ok ; return -1 error, stack insufficient ; 0ra, 4P Recur: mov eax, esp sub eax, 100 ; one value for to be sure cmp eax, [RecursiveVar] jae .0 mov eax, -1 jmp short .z ; end recursion return error ..0: mov eax, dword[esp+ 4] cmp eax, 0 je .z ; end recursion return ok ..1: dec eax push eax call Recur ..z: ret 4 _main: mov eax, esp sub eax, 02000h jc .z ; this can not be mov [RecursiveVar], eax ; documentation here seems state that ; stack size min is 0x02000 ; it would be the right value? push 1000 ; number of call in recursion for be ok call Recur push eax push IRetrunIIuIn call _printf add esp, 8 ..z: xor eax, eax ret ------------ section _DATA use32 public class=DATA global _main extern _printf RecursiveVar dd 0 ; here the min stack address "Retrun=%u\n" db "Retrun=%u", 13, 10, 0, 0 section _BSS use32 public class=BSS section _TEXT use32 public class=CODE ; 0ra, 4P Recur: a=s |a-=100 ; one value for to be sure a<*RecursiveVar!#.0|a=-1|#.z ; end recursion return error ..0: a=^4| a==0#.z ; end recursion return ok ..1: --a|Recur(a) ..z: ret 4 _main: a=s|a-=02000h|jc .z *RecursiveVar=a ; documentation here seems state that ; stack size min is 0x02000 Recur(1000) _printf<("Retrun=%u\n", a) ..z: a^=a ret
|
Pages: 1 Prev: ASM macros... Next: misc idea: PE/COFF data embedding... |