Hi.
This is not a short-answer question, but I'll try to give you some idea of what's going on.
PostScript is a stack-based language, so when the csm procedure is called
portraitMode 1056 6924 csm
the values portraitMode (a number being used as a switch), 1056, and 6924 are pushed onto a stack, with portraitMode being the bottommost, like so:
6924
1056
0 <— this is portraitMode
The csm procedure uses these values to rearrange the coordinate system. It scales by 1/dpi2point, then offsets the origin by x,y = 6924,1056 (here using the example numbers from above), removing the top two numbers from the stack, leaving only the portraitMode value (0 or 1, evidently) still on the stack. This is used to rotate either 90 or -90 degrees.
The upshot to this is that PostScript operators within a procedure (or anywhere else) take their arguments from the operand stack, those arguments having been placed there before the procedure is called. The only way to really understand what’s happening is to draw the stack (on paper) and then work through the code, redrawing the stack as needed.
I'm sorry if this is cryptic, but for a full understanding of what’s going on, you’ll need to learn how the PostScript language works; it’s a fun language (well, I enjoy it), but very different from any other language you’ve probably encountered. The PostScript Language Reference Manual does a good job of describing the language and there are some long-out-of-print books you can still get on Amazon. I teach PostScript classes when anyone wants one (pretty infrequently these days) and have several dozen free “Acumen Journals” with PostScript articles you may find useful, downloadable at acumentraining.com/acumenjournal.html.
Hope this helped a bit.
Best regards,
John
-------
John Deubert
Acumen Training
PostScript & PDF consulting and training
john@acumentraining.com
www.acumentraining.com