flat assembler
Message board for the users of flat assembler.
Index
> DOS > Problems setting up a TSR program |
Author |
|
Tomasz Grysztar 16 Jul 2003, 20:52
You should put your interrupt handler before the startdata label, because interrupt 27h frees all the memory after that label when you use it this way.
|
|||
16 Jul 2003, 20:52 |
|
keyoke 17 Jul 2003, 20:21
hi privalov,
can you or anyone else help me with this I'm trying to set a different interrupt vector. this is a different way i am trying. i copy my routine to a space in memory then try to set the vector to it Code: ;es=segment of the allocated block mov ax,2521h push es pop ds mov dx,100h int 21h here is my own code for before the int not all the correct pushes yet, but it doesnt even get to here yet... everything is copied fine but an error occures while trying the above ? Code: New_Int: pushf cmp ax,0BABEh jne Go_Old mov ah,09h mov dx,TestMsg int 21h Go_Old: call [Old_Int] TestMsg db 'Test',24h Old_Int dd ? End_New_Int: |
|||
17 Jul 2003, 20:21 |
|
Tomasz Grysztar 17 Jul 2003, 20:26
First: you are setting the interrupt vector to es:100h - if this is the block of memory that you have allocated, shouldn't it be es:0? Or are you for some reason copying the routine into the 100h address into that block?
Second: you cannot hook interrupt 21h this way - this is one of the vectors that is automatically restored by DOS when you terminate program (no matter with what function you terminate), to hook this interrupt you need a more advanced techniques - if you want just to learn how to make TSR, try hooking some other interrupt. Maybe you want some small example of TSR program written in fasm? |
|||
17 Jul 2003, 20:26 |
|
keyoke 17 Jul 2003, 20:36
oh ok...didnt know it was automatically restored
I changed it to different interrupt and dx to 0 now it runs... somehow i thought that a psp was placed before my code that i copy to mem location dunno heh. attached is my current useless attempt at creating an intterrupt F1h it loads into memory but bombs out when testing
|
|||||||||||
17 Jul 2003, 20:36 |
|
Tomasz Grysztar 17 Jul 2003, 21:01
I tried to make it (the example) as simple as possible, it hooks interrupt 2Fh and provides a simple function for checking whether it is installed correctly:
Code: org 100h jmp start handler: cmp ax,0BABEh je function jmp 0:0 label old_seg word at $-2 label old_offs word at $-4 function: mov ax,0BEEFh iret start: mov ax,352Fh int 21h mov [old_seg],es mov [old_offs],bx mov ax,252Fh mov dx,handler int 21h mov dx,start int 27h After running the above program you can check it with the code like: Code: mov ax,0BABEh int 2Fh cmp ax,0BEEFh je installed |
|||
17 Jul 2003, 21:01 |
|
keyoke 17 Jul 2003, 21:35
ok thanks i think this while help alot but
what exactly are you doing here Quote:
i suppose jmp 0:0 just will jump to the same line... why have you used label instead of normal variable declaration? I'm curious as i have never seen this before why word at $-2.... will that place that value -2 places before '$' our current line ? |
|||
17 Jul 2003, 21:35 |
|
Tomasz Grysztar 17 Jul 2003, 22:46
This is the run-time fixing of code - the instruction jmp 0:0 is assembled to five bytes: 0EAh - instruction opcode, then zero word - offset of jump destination, and again zero word - segment of jump destination. Then $-2 is the offset of word containing segment and $-4 is the offset of word containing offset - it is filled at run-time with valid values by startup routine - if it wasn't fixed, it would jump to 0:0 an therefore cause crash.
If you don't want to use run-time code modification techniques, you can do it this way: Code: org 100h jmp start handler: cmp ax,0BABEh je function jmp far dword [old_handler] old_handler: old_offset dw ? old_seg dw ? function: mov ax,0BEEFh iret start: mov ax,352Fh int 21h mov [old_seg],es mov [old_offs],bx mov ax,252Fh mov dx,handler int 21h mov dx,start int 27h |
|||
17 Jul 2003, 22:46 |
|
keyoke 18 Jul 2003, 10:30
ok thank you for the help
|
|||
18 Jul 2003, 10:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.