]> git.sur5r.net Git - cc65/blob - libsrc/dbg/dbgdump.s
Fixed _textcolor definition.
[cc65] / libsrc / dbg / dbgdump.s
1 ;
2 ; Ullrich von Bassewitz, 11.08.1998
3 ;
4 ; char* __cdecl__ DbgMemDump (unsigend Addr, char* Buf, unsigned char Length);
5 ;
6
7         .export         _DbgMemDump
8         .import         addysp1
9         .import         __hextab
10         .importzp       sp, tmp2, tmp3, tmp4, ptr3, ptr4
11
12 _DbgMemDump:
13         ldy     #0
14         lda     (sp),y          ; Get length
15         sta     tmp4
16         iny
17         lda     (sp),y          ; Get the string buffer
18         sta     ptr3
19         iny
20         lda     (sp),y
21         sta     ptr3+1
22         iny
23         lda     (sp),y          ; Get the address
24         sta     ptr4
25         iny
26         lda     (sp),y
27         sta     ptr4+1
28         jsr     addysp1         ; Drop the parameters
29
30         lda     #0
31         sta     tmp2            ; String index
32         sta     tmp3            ; Byte index
33
34 ; Print the address
35
36         lda     ptr4+1          ; Hi address byte
37         jsr     dump            ; Print address
38         lda     ptr4            ; Lo address byte
39         jsr     dump
40         jsr     putspace        ; Add a space
41
42 dump1:  dec     tmp4            ; Bytes left?
43         bmi     dump9           ; Jump if no
44         jsr     putspace        ; Add a space
45         ldy     tmp3
46         inc     tmp3
47         lda     (ptr4),y
48         jsr     dump
49         jmp     dump1
50
51 dump9:  lda     #0
52         ldy     tmp2
53         sta     (ptr3),y        ; Add string terminator
54         lda     ptr3
55         ldx     ptr3+1          ; We assume this is not zero
56         rts
57
58 ; Dump one hex byte
59
60 dump:   pha
61         lsr     a
62         lsr     a
63         lsr     a
64         lsr     a
65         tax
66         lda     __hextab,x
67         jsr     putc
68         pla
69         and     #$0F
70         tax
71         lda     __hextab,x
72 putc:   ldy     tmp2
73         inc     tmp2
74         sta     (ptr3),y
75         rts
76
77 putspace:
78         lda     #$20
79         bne     putc
80
81