sorting - Access violation in Masm when accessing memory offset -


i'm trying to selection sort in x86 assembly , i'm getting access error violation when try use variable access offset of array.

.data array byte "fairy tale" count = ($ - array) minindex byte ?  .code _main proc  mov eax, 0                           mov ebx, 0                            mov ecx, count                      ; move array count counter register dec ecx                             ; decrease counter lea esi, array   mov bl, 0                           ; = 0 l1: push ecx           mov minindex, bl                    ; minindex = mov al, minindex[esi]               ; gives error  ; rest of code...  ret  _main endp  end _main 

there no build errors, access violation @ run time. not allowed such operation in masm? there workaround?

mov al, minindex[esi] 

if think take value of minindex , use offset esi in read operation, you're incorrect. use the address of minindex.

you can change code to:

movzx eax,byte ptr minindex  ; zero-extend byte @ minindex eax.. mov al,[esi+eax]             ; ..and use offset array 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -