Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6a3463c7
authored
Nov 09, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added simple comp library
parent
e54b5743
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
src/comp.c
src/comp.h
src/comp.c
0 → 100644
View file @
6a3463c7
#include "comp.h"
int
cstack
[
128
];
int
cstack_size
;
void
cpush
(
int
n
)
{
cstack
[
cstack_size
]
=
n
;
cstack_size
++
;
}
void
cpop
()
{
if
(
cstack_size
==
0
)
return
;
cstack_size
--
;
}
int
cpeek
()
{
return
cstack
[
cstack_size
-
1
];
}
void
cadd
()
{
if
(
cstack_size
<
2
)
return
;
int
a
=
cpeek
();
cpop
();
int
b
=
cpeek
();
cpop
();
cpush
(
a
+
b
);
}
void
cmult
()
{
if
(
cstack_size
<
2
)
return
;
int
a
=
cpeek
();
cpop
();
int
b
=
cpeek
();
cpop
();
cpush
(
a
*
b
);
}
void
csub
()
{
if
(
cstack_size
<
2
)
return
;
int
a
=
cpeek
();
cpop
();
int
b
=
cpeek
();
cpop
();
cpush
(
a
-
b
);
}
void
cdiv
()
{
if
(
cstack_size
<
2
)
return
;
int
a
=
cpeek
();
cpop
();
int
b
=
cpeek
();
cpop
();
cpush
(
a
/
b
);
}
src/comp.h
0 → 100644
View file @
6a3463c7
#ifndef _INC_COMP
#define _INC_COMP
void
cpush
(
int
n
);
void
cpop
();
int
cpeek
();
void
cadd
();
void
cmult
();
void
csub
();
void
cdiv
();
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment