aboutsummaryrefslogtreecommitdiff
path: root/src/new_format_ip.s
blob: 5fab2ba66b15ce59b674a8de0ae530178a5b6465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
	.fopt		compiler,"cc65 v 2.12.9"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	off
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.export		_new_format_ip

	.segment "BSS"
buf:
	.res 20,$0

	.segment "RODATA"
fmt: .byte "%d.%d.%d.%d", 0

; unsigned char* __fastcall__ format_ip (__near__ unsigned int[2]*)
	.segment "CODE"
_new_format_ip:
	sta ptr1
	stx ptr1+1

	lda #<buf
	ldx #>buf
	jsr pushax

	lda #<fmt
	ldx #>fmt
	jsr pushax

	ldy #0
	lda (ptr1),y
	jsr pusha0

	ldy #1
	lda (ptr1),y
	jsr pusha0

	ldy #2
	lda (ptr1),y
	jsr pusha0

	ldy #3
	lda (ptr1),y
	jsr pusha0

	ldy #$0c
	jsr _sprintf

	lda #<buf
	ldx #>buf

	rts