This message was edited by anthrax11 at 2005-10-20 2:34:15
: Just a thought...
:
: When you read the program to memmory, wont it overwrite the loading program? Both program's can't start at 100h...
:
: If this is the case, solve it by allocating some memmory for the loading program, and then run it...
:
: The one and only
Niklas Ulvinge aka IDK
:
:
Yes, that was the idea, to overwrite it. It was a bad idea, forget it.
OK, I tried allocating memory, but for some reason I always get an insufficient memory error(8), even if I try to get like 32 bytes or so. I dont know if the rest of the code works:
.MODEL TINY
.CODE
ORG 0100H
MAIN:
START:
mov ah,48h ;Function 48h(Allocate memory)
mov bx,4 ;Number of 16-byte blocks to allocate
int 21h ;Do it
jc err_exit ;Exit if an error occurs(it does)
mov jmpcomseg,ax ;Int 21h returns the segment in ax
mov ah,3dh ;Function 3dh(open file)
mov al,0 ;Open for reading
mov dx,offset ProgramName ;Offset to the program
int 21h ;Open the COM file
mov ProgHnd,ax ;Save the file handle
mov ds,jmpcomseg ;Read to the allocated
mov dx,100h ;memory
mov ah,3fh ;Function 3fh(read file)
mov bx,ProgHnd ;Get the handle we saved earlier
mov cx,64 ;Read 64 bytes(size of the program)
int 21h ;Read from the file
db 0eah ;jmp far jmpcomseg:100h
dw 0100h ;(Jump to the program)
jmpcomseg dw ?
err_exit:
ret
ProgramName DB "my_prog.com$"
ProgHnd dw ?
END MAIN
END
Btw, I didn't get the automatic notification thingy. Whats up?
My e-mail provider(live.hot.ee) is going through major changes and everyones flaming them because of all the bugs, maybe thats the problem, I dont know.
Haha, Got all the letters 2 minutes after posting never mind then.