Saturday 15 March 2014

assembly - "NTVDM CPU has encountered an illegal instruction" caused by RET instruction -



assembly - "NTVDM CPU has encountered an illegal instruction" caused by RET instruction -

well, i've got big problem here. code supposed work; did not write it, teacher give me. code bit longer, concat operation betwen 2 strings, , has 2 more procs, 1 not called proc, so, i've been debuggin separately.

.model big .386 .stack 200h .data _max_caracteres_ equ 30 __aux_cadena_ db _max_caracteres_ dup(?), '$' cad1 db "primer cadena", '$', 37 dup(?) cad2 db "segunda cadena", '$', 36 dup(?) cad3 db _max_caracteres_ dup(?), '$' .code begin: .startup mov ax, @data mov ds, ax finit ;;;;;;;;;;;;;;;strlen;;;;;;;;;;;;;; strlen proc ;mov bx, 0 ;jmp strl01 ;strl01: ;cmp byte ptr[si+bx], '$' ;js strend ;inc bx ;jmp strl01 ;strend: retn strlen endp ;;;;;;;;;;;;main;;;;;;;;;;;;; mov ax, @data mov es, ax mov si, offset cad1 mov di, offset __aux_cadena_ phone call strlen ;call copiar ;mov si, offset cad2 ;mov di, offset __aux_cadena_ ;call concat ;mov si, offset __aux_cadena_ ;mov di, offset cad3 ;call copiar mov ax, 4c00h int 21h end begin

as might see, i've been commenting lines find problem was. came conclusion problem ret instruction. programme linked, when execute i've got next windows dialog:

"the ntvdm cpu has encountered illegal instruction. cs:0712 ip:0927 op:ff 7f 00 00 00 take 'close' terminate application."

the code works in part:

mov ax, @data mov es, ax mov si, offset cad1 mov di, offset __aux_cadena_

until

phone call strlen

then, within strlen instruction non-commented ret. that's why assume problem.

i've been reading lot, couldn't find problem yet.

somewhere in web i've read stack corrupted, when proc "returns", returns invalid memory address, processor cannot understand.

please, wish help me this, don't know do, i've tried lot. inquire me whatever need if explanation not clear or info not enough. give thanks much.

oh, way, i'm running windows xp mode 32bits

assembly tasm ntvdm

No comments:

Post a Comment