JG>Ok, here's the code. I'm trying to write a TSR that pops a little message
up
JG>for a brief moment that says "RING" at the upper-left corner. But I can't
JG>quite get it right. Mangle it so that it works. :)
JG>I'm trying not to use the stack at all. I'm a beginner, and use TASM 5.0,
bu
JG>don't have any of the books for it. (Got it at a garage sale)
JG>.model tiny
JG>.code
JG>org 100h
JG>START:
JG> MOV AX, CS ;SET DS=CS w/out using stack
JG> MOV DS, AX
JG> MOV AH, 35h ;Function 35 GetIntAddress
JG> MOV AL, 1Ch ;of Int 1C (Timer)
JG> MOV OldInt1CSegment, ES ;Save
JG> MOV OldInt1COffset, BX ;Save
This doesn't do much unless you insert an INT 21h before you save the old
segments... also, since this is a com file, it automatically starts with
CS=DS=ES... you only need to make sure in the TSR part that you save ds, and
restore it at the end.
JG> MOV AH, 25h ;Function 25 SetIntAddress
JG> MOV AL, 1Ch ;of Int 1C (Timer)
JG> LEA DX, THETSR ;Beginning of TSR
JG> INT 21h ;GOforit
JG> MOV AH, 31h ;Function 31 (TSR)
JG> MOV AL, 0h ;ErrorLevel 0
JG> MOV AX, OFFSET THEENDOFPROG ;Paragraph conversion???? No clue
JG> MUL WORD 16 ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't know how you manage the MUL WORD 16, but when you do a MOV AX,
something, you lose what you put into AH and AL before. Try like this:
MOV AX, 3100h
MOV DX, OFFSET THEENDOFPROG
SHR DX, 4 ; this is the number of paragraphs to keep resident.
JG> INT 21h ;Terminate and Stay Resident
JG>THETSR: ;The Acutal Stuff
JG> MOV AH, 03h ;Function 3 (Check serial status)
JG> XOR AL, AL ;Clear AL
Hold on a minute here! If this is supposed to be a timer interrupt, you've
got to SAVE all the register you change, and restore them at the end. (except
CS, IP, and flags which are automatically pushed by an interrupt). You can
either add data to hold them in the code segment (you'll need to use CS:) or
push the registers... Also, couldn't you just make the above a single MOV AX,
0300h?
JG> MOV DX, 01h ;COM2
JG> INT 14h ;GO!
JG> TEST AL,01000000b ;See if RingIndicator is on
JG> JE RINGING ;If So, it's ringing!
You want to do the opposite here... this jump will go if bit 6 is turned
OFF... try changing this to a JNZ.
JG> CALL FAR [OldInt1CSegment]:[OldInt1COffset] ;?????? Call old INT1C
JG>;SYNTAX? I really have no idea.
The trick here is to store the offset first, and consider it a single
pointer...
CALL FAR PTR CS:[OldInt1CPtr]
JG> IRET
JG>RINGING:
JG> MOV AH, 03h ;Get Cursor Position
JG> MOV BH, 00h
JG> INT 10h
JG> MOV CursPos, DX ;And save it.
Hold on a minute here! Can't do it that way! This assumes DS=CS which is
ot
necessarily the case. You have to either 1. Save the caller's DS, then copy
CS into it, or 2. force the use of CS here.
JG> MOV DL, 00h ;Inefficient way, probably, of saving
JG> CALL SAVECHAR ;the first 4 chars so that I don't
JG> MOV Char1, AX ;just overrite it all.
JG> MOV DL, 01h
JG> CALL SAVECHAR
JG> MOV Char2, AX
JG> MOV DL, 02h
JG> CALL SAVECHAR
JG> MOV Char3, AX
JG> MOV DL, 03h
JG> CALL SAVECHAR
JG> MOV Char4, AX
I know of a much faster way to save 4 characters (will give more regs. to
save)...
MOV AX, 0B800h ; direct video memory access
MOV ES, AX
XOR DI, DI
MOV AX, CS ; make sure DS = CS, unnecessary if you've done so
MOV DS, AX ; earlier in the interrupt
MOV SI, OFFSET Char1
MOV CX, 4
REP MOVSW
JG> MOV AX, 5207h ; And write the RING in...
JG> CALL WRITECHAR
JG> MOV AX, 4907h
JG> CALL WRITECHAR
JG> MOV AX, 4E07h
JG> CALL WRITECHAR
JG> MOV AX, 4707h
JG> CALL WRITECHAR
Four calls to int 10h??? All you need to do is a write string... something
like this:
MOV AX, CS
MOV ES, AX
MOV AX, 1300h
MOV BX, 0007h
MOV CX, 0004h
XOR DX, DX
MOV BP, OFFSET RingStr
INT 10h
That works on all EGA and later... you could also use a REP MOVSW as
efore...
however on a CGA, you'd probably want to do a little bit of snow checking...
But I think if you used this many Int 10h calls, you'd have the interrupt
backing into itself in reentrancy problems... int 10h is one of the SLOWEST
known ways of accessing video memory... for mode switching it's ok, but for
graphics or text, it's too slow.
JG> NOP ;minor delay
JG> MOV AX, Char1 ;replace old chars
JG> CALL WRITECHAR
JG> MOV AX, Char2
JG> CALL WRITECHAR
JG> MOV AX, Char3
JG> CALL WRITECHAR
JG> MOV AX, Char4
JG> CALL WRITECHAR
JG> CALL FAR [OldInt1CSegment]: [OldInt1COffset] ;?????? Call old INT1C
JG>;again, no idea. :(
JG> IRET
This can be done as a rep movsw, and a CALL FAR PTR CS:[OldInt1CPtr].
>>> Continued to next message
* OLX 2.2 * OXYMORON - Ferringi Research Vessel
--- PCBoard (R) v15.3/M 10
---------------
* Origin: Next time, Dial The Wrong Number! (209) 943-1880 (1:208/205)
|