forked from dannyfiresnake/rpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpn.macros
More file actions
34 lines (25 loc) · 684 Bytes
/
Copy pathrpn.macros
File metadata and controls
34 lines (25 loc) · 684 Bytes
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
# figure out N% discount (100 30 dis -> 70)
discount 100 / 2 pick * -
# reverse of discount
markup 100 / 1.0 swap - /
# convert to megabytes
meg 1024 1024 * *
# convert to kilobytes
k 1024 *
# value-of-the-word-containing-this-set-bit
bit 1 swap <<
# set the bit on the stack into the word preceding it
set bit |
# opposite of "set"
unset bit ~ &
# produce the word with a bit set for every position on
# the stack
$cbit swap set
bits bit depth -- repeat $cbit
# > 15 fill -> 15 14 13 12 etc
$-step dup --
fill dup repeat $-step
# produce all the valid IP header lengths
$ihlstep dup 4 * swap --
$ihls dup repeat $ihlstep
ihls 15 $ihls