Category:Dc: Difference between revisions

Content added Content deleted
(Expand the quick reference to cover OpenBSD dc.)
m (→‎Quick reference: Use literal numbers, not 'a' 'b' 'n', when those were not commands.)
Line 19: Line 19:
Sx : push to register x
Sx : push to register x
Lx : pop register x
Lx : pop register x
a b :x : store x[b] = a (x is register)
1 2 :x : store x[2] = 1 (x is register)
a ;x : retrieve x[b]
2 ;x : retrieve x[2]
<x >x =x : compare top 2 values: if true, then execute register x
<x >x =x : compare top 2 values: if true, then execute register x
!>x !<x !=x : (example: 5 2 <A executes register A if 2 < 5)
!>x !<x !=x : (example: 5 2 <A executes register A if 2 < 5)
! : shell command
! : shell command
q : quit, or break 2 execution levels
q : quit, or break 2 execution levels
n Q : break n execution levels
3 Q : break 3 execution levels
i : set input radix from top of stack
i : set input radix from top of stack
I : get current input base, push it on stack
I : get current input base, push it on stack
Line 50: Line 50:


Extensions in [[OpenBSD dc]]
Extensions in [[OpenBSD dc]]
n J : break n execution levels, then jump to next M
3 J : break 3 execution levels, then jump to next M
M : mark for the J command
M : mark for the J command
a N : boolean not: push 1 if a == 0, else push 0
R : pop and discard top of the stack
R : pop and discard top of the stack
<xey >xey : comparisons with an else branch: if true,
<xey >xey : comparisons with an else branch: if true,
=xey !<xey : then execute register x
=xey !<xey : then execute register x
!>xey !=xey : else execute register y
!>xey !=xey : else execute register y
a b G : equality: push 1 if b == a, else push 0
1 2 G : equality: push 1 if 2 == 1, else push 0
a b ( : less than: push 1 if b < a, else push 0
1 2 ( : less than: push 1 if 2 < 1, else push 0
3 N : boolean not: push 1 if 3 == 0, else push 0