Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;
- ; Set up my trap #1 handler
- ;
- move.l $84.w,old_trap1
- move.l #my_trap1,$84.w
- ;
- ; This routine catches mallocs and replaces them with more convinient code!
- ;
- my_trap1:
- movea.l SP,A0
- adda.l cpu_trap_offset,A0 ;that's either 6 or 8 (68000/68030)
- cmpi.w #$48,(A0) ;malloc?
- beq.s do_malloc
- cmpi.w #$68,(A0) ;mxalloc?
- bne.s no_malloc
- do_malloc: movea.l 2(A0),A0 ;requested memory amount
- move.l malloc_ptr(PC),D0 ;the pointer to memory we're going to give
- lea 0(A0,D0.l),A0 ;advance our pointer as many bytes as those reserved
- move.l A0,malloc_ptr ;save the pointer for next malloc
- rte ;and go back to program
- no_malloc: cmpi.w #$49,(A0) ;mfree?
- bne.s no_mfree
- rte ;do nothing
- no_mfree:
- old_trap1 EQU *+2
- jmp 0 ;jump to O/S' vector
- malloc_ptr: DC.L buffer
- cpu_trap_offset:DS.L 1
- buffer: DS.W 65535
- DS.W 65535
- DS.W 65535
- DS.W 65535
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement