-
Notifications
You must be signed in to change notification settings - Fork 1
/
24.src
executable file
·89 lines (89 loc) · 1.46 KB
/
24.src
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
.IPPcode18
JUMP $$MAIN
LABEL length
CREATEFRAME
DEFVAR TF@s
POPS TF@s
DEFVAR TF@len
STRLEN TF@len TF@s
PUSHS TF@len
RETURN
PUSHS int@0
RETURN
LABEL substr
CREATEFRAME
DEFVAR TF@s
POPS TF@s
DEFVAR TF@i
POPS TF@i
DEFVAR TF@n
POPS TF@n
DEFVAR TF@strval
MOVE TF@strval string@
DEFVAR TF@cmpres
LT TF@cmpres TF@i int@1
JUMPIFEQ substr$loopend TF@cmpres bool@true
SUB TF@i TF@i int@1
DEFVAR TF@len
STRLEN TF@len TF@s
SUB TF@len TF@len TF@i
GT TF@cmpres TF@n TF@len
JUMPIFNEQ strcmp$chk1 TF@cmpres bool@true
MOVE TF@n TF@len
LABEL strcmp$chk1
LT TF@cmpres TF@n int@0
JUMPIFNEQ strcmp$chk2 TF@cmpres bool@true
MOVE TF@n TF@len
LABEL strcmp$chk2
DEFVAR TF@char
LABEL substr$loopstart
GT TF@cmpres TF@n int@0
JUMPIFNEQ substr$loopend TF@cmpres bool@true
SUB TF@n TF@n int@1
GETCHAR TF@char TF@s TF@i
CONCAT TF@strval TF@strval TF@char
ADD TF@i TF@i int@1
JUMP substr$loopstart
LABEL substr$loopend
PUSHS TF@strval
RETURN
PUSHS string@
RETURN
LABEL asc
CREATEFRAME
DEFVAR TF@s
POPS TF@s
DEFVAR TF@i
POPS TF@i
DEFVAR TF@len
STRLEN TF@len TF@s
DEFVAR TF@cmp
SUB TF@i TF@i int@1
LT TF@cmp TF@i TF@len
JUMPIFNEQ asc$cmpfail TF@cmp bool@true
LT TF@cmp TF@i int@0
JUMPIFNEQ asc$cmpfail TF@cmp bool@false
DEFVAR TF@ascval
STRI2INT TF@ascval TF@s TF@i
PUSHS TF@ascval
RETURN
LABEL asc$cmpfail
PUSHS int@0
RETURN
PUSHS int@0
RETURN
LABEL chr
CREATEFRAME
DEFVAR TF@i
POPS TF@i
DEFVAR TF@s
INT2CHAR TF@s TF@i
PUSHS TF@s
RETURN
PUSHS string@
RETURN
LABEL $$MAIN
CREATEFRAME
DEFVAR TF@a
MOVE TF@a int@10
WRITE TF@a