-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemset3.asm
129 lines (112 loc) · 1.76 KB
/
memset3.asm
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
;
; File generated by cc65 v 2.18 - Ubuntu 2.18-1
;
.fopt compiler,"cc65 v 2.18 - Ubuntu 2.18-1"
.setcpu "6502"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank
.importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
.macpack longbranch
.forceimport __STARTUP__
.export _memset8
.export _main
; ---------------------------------------------------------------
; void __near__ memset8 (__near__ unsigned char *, const unsigned char, const unsigned char)
; ---------------------------------------------------------------
.segment "CODE"
.proc _memset8: near
.segment "BSS"
L0002:
.res 1,$00
.segment "CODE"
;
; {
;
jsr pusha
;
; for (i = 0; i < n; i++) {
;
lda #$00
sta L0002
L001B: lda L0002
ldy #$00
cmp (sp),y
bcs L0004
;
; dest[i] = c;
;
ldy #$03
jsr ldaxysp
clc
adc L0002
bcc L001A
inx
L001A: sta ptr1
stx ptr1+1
ldy #$01
lda (sp),y
dey
sta (ptr1),y
;
; for (i = 0; i < n; i++) {
;
inc L0002
jmp L001B
;
; }
;
L0004: jmp incsp4
.endproc
; ---------------------------------------------------------------
; int __near__ main (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _main: near
.segment "BSS"
L000F:
.res 2,$00
L0011:
.res 1,$00
L0013:
.res 1,$00
.segment "CODE"
;
; uint8_t *dest = (uint8_t *) 0x0600;
;
ldx #$06
lda #$00
sta L000F
stx L000F+1
;
; uint8_t bytes = 0xff;
;
lda #$FF
sta L0011
;
; uint8_t fill = 0x00;
;
lda #$00
sta L0013
;
; memset8(dest, fill, bytes);
;
lda L000F
ldx L000F+1
jsr pushax
lda L0013
jsr pusha
lda L0011
jsr _memset8
;
; return 0;
;
ldx #$00
txa
;
; }
;
rts
.endproc