assembly program won't run

aceman817

Senior member
Jul 15, 2001
204
0
0
hey guys! i came across this assembly program that is similar to a project that i'm working on and i can't seem to get it to run. the address is http://www.programmersheaven.com/c/MsgB...oard=1&MsgID=282042&Setting=A9999F0001
and the instructions and code are listed below. it seems like it crashes at the mov [edi], al line when i debug

"Write a Near32 procedure split-octal which converts an 16-bit interger to a string of exactly six characters representing the value of the number in split octal. The procedure will have two parametters, passed on the stack:
1) the number
2) the address of the destination string
The procedure will remove parameters from the stack and must modify no register."

.STACK 4096 ; reserve 4096-byte stack

.DATA ; reserve storage for data

kill_high5 equ 00000111b ;
kill_high6 equ 00000011b ;
prompt BYTE "Enter a number: ", 0
number BYTE 20 DUP (?)
result BYTE cr,Lf,"The 2's complement representation is "
splitOct BYTE 8 DUP (?), cr,Lf, 0

.CODE ; start of main program code
_start:
output prompt ; prompt for number
input number,20 ; read ASCII characters
atoi number ; convert to integer

lea edi, splitOct+7 ; address for last character
mov edx, eax ; copy pattern

kill_5: and al, kill_high5 ; zero all but last 3 digits
add al, 30h ; add 30h into al to convert the digit to ASCII
mov [edi], al ; move ASCII into memory location with pointer in EDI
dec edi ; move to the next location
mov al, dl ; re-initialize value in al
ror al, 3
jnz kill_5

ror al, 2
kill_6: and al, kill_high6 ; zero all but last 2 digits
add al, 30h ; add 30h into al to convert the digit to ASCII
mov [edi], al ; move ASCII into memory location with pointer in EDI
dec di ; move to the next location

mov BYTE PTR [edi], ' '
mov dl, dh
mov al, dl ; re-initialize value in al
jnz kill_5

output result ; output label and split-octal value

INVOKE ExitProcess, 0 ; exit with return code 0

PUBLIC _start ; make entry point public

END