-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdlib.urcl
62 lines (56 loc) · 1.07 KB
/
stdlib.urcl
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
@define MALLOC_MAINP M0
@define F16PI 0x4248
@define F16E 0x4170
@define NAN 0x7fff
.strlen
psh r1 // str *
psh r2 // additional reg
psh r3
imm r3 0
.strlen__loop1
lod r2 r1
bre .strlen__end r2 0
inc r3 r3
inc r1 r1
jmp .strlen__loop1
.strlen__end
mov r1 r3
pop r3
pop r2
pop r9
ret
.strcpy
psh r1 // dest str*
psh r2 // src str*
psh r3 // additional reg
.strcpy__loop1
lod r3 r2
bre .strcpy__end r3 0
str r1 r3
inc r2 r2
inc r1 r1
jmp .strcpy__loop1
.strcpy__end
pop r3
pop r2
pop r1
ret
.memcpy
psh r1 // dest *
psh r2 // src *
psh r3 // size
psh r4 // additional
.memcpy__loop1
lod r4 r2
str r1 r4
dec r3 r3
inc r1 r1
inc r2 r2
bre .memcpy__done r3 0
jmp .memcpy__loop1
.memcpy__done
pop r4
pop r3
pop r2
pop r1
ret