]> git.sur5r.net Git - cc65/blob - libsrc/common/_heapblocksize.s
Disable the IRQ before calling mouse_uninstall
[cc65] / libsrc / common / _heapblocksize.s
1 ;
2 ; Ullrich von Bassewitz, 2004-07-17
3 ;
4 ; size_t __fastcall__ _heapblocksize (const void* ptr);
5 ;
6 ; Return the size of an allocated block.
7 ;
8
9         .importzp       ptr1
10         .export         __heapblocksize
11
12         .include        "_heap.inc"
13
14         .macpack        generic
15         .macpack        cpu
16
17 ;-----------------------------------------------------------------------------
18 ; Code
19
20 __heapblocksize:
21
22 ; Decrement the block pointer so it points to the admin data
23
24         sub     #HEAP_ADMIN_SPACE       ; Assume it's less than 256
25         bcs     L1
26         dex
27 L1:     sta     ptr1
28         stx     ptr1+1
29
30 ; Load the size from the given block
31
32         ldy     #1
33         lda     (ptr1),y
34         tax
35 .if (.cpu .bitand CPU_ISET_65SC02)
36         lda     (ptr1)
37 .else
38         dey
39         lda     (ptr1),y
40 .endif
41
42 ; Adjust it to the user visible size
43
44         sub     #HEAP_ADMIN_SPACE
45         bcs     L9
46         dex
47
48 ; Done
49
50 L9:     rts
51