Re: A92: fixed code


[Prev][Next][Index][Thread]

Re: A92: fixed code




>Thanks.  A couple of questions:
>What exactly is a heap?  Isn't Fargo on top of the heap so that if I did
what you are suggesting, I
>would overwrite Fargo code?

In fact your code would be just 'before' Fargo, it will be a little like that
	| Heap | Your code | Fargo |


>And how exactly can I set the interupt to trigger the code at a preset
interval?

Auto-int 1 runs approximately at 350Hz.
So you should have at the beginning of your code something like that:
	tst.w	var
	beq	code
	add.w	#1,var		;increments it
	and.w	#%00000111,var;if (var == 8)  var = 0
	move.l	old_int,-(a7)	;old_int adress
	rts			;quits

code:	(your code here)

	(...)

var	dc.w	0

With that your code is executed about 350/8 = 43.75 times per second.



>Xavier VASSOR - The Doors Team wrote:
>
>> >I want to do write a little utility that would display the amount of
>> >free memory on the status bar.  It would be updated at a certain
>> >interval.  The way I see it is this: an interrupt is set that at the
>> >given interval would jump to the routine.  The problem is that programs
>> >aren't fixed in memory.  Does anyone know how to place some code in the
>> >memory and ensure that it won't be moved or deleted by TiOS?
>>
>> The only way is that you make a resident program which would be located at
>> the top of the memory.
>> Here is a piece of code which copies a program at the top of the memory and
>> links it with auto-int1:
>>
>>         move.w          #$700,d0
>>         trap            #1                      ;ints off
>>         bclr.b          #1,$600001              ;memory protection off
>>         move.l          $64,old_int             ;get the old auto-int
handler adress and saves it in
>> a long variable.
>>         lea             tios::globals+$18F6,a0 ;a0 points to the adress
of the Top of heap
>>         move.l          #endprog-start,d1       ;d1 is the size of your
resident code
>>         sub.l           d1,(a0) ;diminuates the adress of the top of heap
>>         move.L          (a0),a0 ;a0 now points to the top of heap and
not its adress
>>         lea             start(pc),a1    ;load the adress of your
resident code
>>         move.l          a0,$64          ;changes the auto-int1 handler
>>
>>         subq.l          #1,d1
>> \cpy    move.b          (a1)+,(a0)+     ;copies the resident code at
>>         dbra            d1,\cpy ;the top of memory
>>
>>         bset.b          #1,$600001      ;mem protect on
>>         clr.w           d0
>>         trap            #1              ;ints on
>>
>> notes: -endprog is the label located just after the end of the resindent
code
>>         -the size of the resident code MUST be an even adress, of course.
>>         -this code should work on every ROM version (1.x & 2.1). It
should work on
>> a 92+ but I'm not sure (just replace 'tios::globals+$18F6' with
$4C00+$18F6)
>>
>> I hope this can help.
>>



Xavier VASSOR
---The Doors Team
E-mail:xvassor@mail.dotcom.fr
Doors Homepage: http://doorshome.home.ml.org
ICQ:10241721


References: