View Single Post
Old Mar 11th, 2005, 1:37 AM   #1
liquidsilver
Newbie
 
liquidsilver's Avatar
 
Join Date: Mar 2005
Location: South Africa
Posts: 21
Rep Power: 0 liquidsilver is on a distinguished road
Post Self Modifying Code

I've just recently started with SMC (Self Modifying Code) and I'm having some problems:

.model tiny
.stack
.data
  key db 01h
.code
org 0100h

mov cx,3
StrLoop:
  dec cx
  mov di,(offset fix)
  add di,cx
  mov al,[di]
  xor al,key
  mov [di],al
  jcxz OutLoop
  jmp StrLoop
OutLoop:

fix db 0B9h, 036h, 003h ;mov ax,0237h
  ret
end main

This is my SMC.COM source. This works, but when I convert it to a EXE then it goes haywire. The correct data seems to not get targeted. I use MASM, please help.
__________________
Small is beautiful
liquidsilver is offline   Reply With Quote