aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2018-11-07 17:26:53 +0100
committerCamil Staps2018-11-07 17:26:53 +0100
commitbee9b0b371279f086e0a495f18837e7445fc541c (patch)
tree4ef03c59c1064ef3575eb1af98b3b848d2743a05
parentUpdate download links (diff)
Add mac.tex
-rw-r--r--.gitlab-ci.yml3
-rw-r--r--README.md4
-rw-r--r--cheatsheet.cls28
-rw-r--r--linux-x64.tex91
-rw-r--r--mac.tex8
-rw-r--r--registers.tex48
-rw-r--r--system-v-abi.tex14
7 files changed, 108 insertions, 88 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c5ee74a..b3b3cdd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,9 @@ pdf:
script:
- pdflatex linux-x64.tex
- pdflatex linux-x64.tex
+ - pdflatex mac.tex
+ - pdflatex mac.tex
artifacts:
paths:
- linux-x64.pdf
+ - mac.pdf
diff --git a/README.md b/README.md
index e5be760..b343d2b 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@ run-time system. Clone the repository to build the PDFs or download them here:
## Download links
-- [Linux x64][linux-x64]
+- [Linux (x64)][linux-x64]
+- [Mac][mac]
- [Zip with all cheat sheets][zip]
## Naming conventions
@@ -19,4 +20,5 @@ run-time system. Clone the repository to build the PDFs or download them here:
[Clean]: http://clean.cs.ru.nl
[linux-x64]: https://gitlab.science.ru.nl/cstaps/clean-rts-cheat-sheet/-/jobs/artifacts/master/raw/linux-x64.pdf?job=pdf
+[mac]: https://gitlab.science.ru.nl/cstaps/clean-rts-cheat-sheet/-/jobs/artifacts/master/raw/mac.pdf?job=pdf
[zip]: https://gitlab.science.ru.nl/cstaps/clean-rts-cheat-sheet/-/jobs/artifacts/master/download?job=pdf
diff --git a/cheatsheet.cls b/cheatsheet.cls
new file mode 100644
index 0000000..dfe1191
--- /dev/null
+++ b/cheatsheet.cls
@@ -0,0 +1,28 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{cheatsheet}%
+ [2018/11/07 v1.0 Clean RTS Cheat Sheets]
+
+\LoadClass{article}
+
+\RequirePackage[a6paper,margin=8mm,top=5mm,bottom=5mm]{geometry}
+\RequirePackage{xcolor}
+\RequirePackage[hidelinks]{hyperref}
+
+\pagestyle{empty}
+
+\setlength\fboxrule{.5pt}
+\setlength\fboxsep{0pt}
+\renewcommand{\arraystretch}{1.2}
+\setlength{\tabcolsep}{.5em}
+\parindent0pt
+\centering
+
+\newcommand{\cheatsheettitle}[2][]{%
+ \begin{center}
+ \textbf{Clean RTS Cheat Sheet, \ifx#1\empty\else#1 \fi#2}
+ \end{center}}
+
+\AtEndDocument{%
+ \par\bigskip
+ \scriptsize
+ \url{https://gitlab.science.ru.nl/cstaps/clean-rts-cheat-sheet}}
diff --git a/linux-x64.tex b/linux-x64.tex
index 25c4ef5..d8e3c96 100644
--- a/linux-x64.tex
+++ b/linux-x64.tex
@@ -1,91 +1,8 @@
-\documentclass{article}
-
-\usepackage[a6paper,margin=8mm,top=5mm,bottom=5mm]{geometry}
-\usepackage{xcolor}
-\usepackage[hidelinks]{hyperref}
-
+\documentclass{cheatsheet}
\begin{document}
-
-\pagestyle{empty}
-
-\setlength\fboxrule{.5pt}
-\setlength\fboxsep{0pt}
-\renewcommand{\arraystretch}{1.2}
-\setlength{\tabcolsep}{.5em}
-\parindent0pt
-
-\begin{center}
- \textbf{Clean RTS cheat sheet, x64 linux}
-\end{center}
-
-{\hfill%
-\fcolorbox{black}{white}{%
- \begin{tabular}{ll}
- A0 & rcx \\
- A1 & rdx \\
- A2 & r8 \\
- \hline
- B0 & rax \\
- B1 & rbx \\
- B2 & r10 \\
- B3 & r11 \\
- B4 & r12 \\
- B5 & r13 \\
- B6 & r14 \\
- \hline
- asp & rsi \\
- bsp & rsp \\
- hp & rdi \\
- free & r15 \\
- \hline
- scratch & rbp \\
- scratch & r9 \\
- \end{tabular}%
-}%
-\hfill%
-\fcolorbox{black}{white}{%
- \begin{tabular}{ll}
- rax & B0 \\
- rbx & B1 \\
- rcx & A0 \\
- rdx & A1 \\
- \hline
- rbp & scratch \\
- rdi & hp \\
- rsi & asp \\
- rsp & bsp \\
- \hline
- r8 & A2 \\
- r9 & scratch \\
- r10 & B2 \\
- r11 & B3 \\
- r12 & B4 \\
- r13 & B5 \\
- r14 & B6 \\
- r15 & free \\
- \end{tabular}%
-}%
-\hfill}
-
-\bigskip
-\centering
-\fcolorbox{black}{white}{%
- \setlength{\tabcolsep}{.2em}%
- \begin{tabular}{lcccccc}
- \multicolumn{7}{c}{\textbf{Function Calls}}\\\hline
- Arguments: & rdi & rsi & rdx & rcx & r8 & r9\\
- & hp & asp & A1 & A0 & A2 & scr\\
- \hline
- Result: & rax & rdx \\
- & B0 & A1 \\
- \hline
- Callee-saved: & rbx & rbp & r12 & r13 & r14 & r15 \\
- & B1 & scr & B4 & B5 & B6 & free \\
- \end{tabular}%
-}
+\cheatsheettitle[x64]{Linux}
+\input{registers}
\bigskip
-\scriptsize
-\url{https://gitlab.science.ru.nl/cstaps/clean-rts-cheat-sheet}
-
+\input{system-v-abi}
\end{document}
diff --git a/mac.tex b/mac.tex
new file mode 100644
index 0000000..0c1e909
--- /dev/null
+++ b/mac.tex
@@ -0,0 +1,8 @@
+\documentclass{cheatsheet}
+\begin{document}
+\cheatsheettitle{Mac}
+\input{registers}
+
+\bigskip
+\input{system-v-abi}
+\end{document}
diff --git a/registers.tex b/registers.tex
new file mode 100644
index 0000000..0fd363f
--- /dev/null
+++ b/registers.tex
@@ -0,0 +1,48 @@
+{\hfill%
+\fcolorbox{black}{white}{%
+ \begin{tabular}{ll}
+ A0 & rcx \\
+ A1 & rdx \\
+ A2 & r8 \\
+ \hline
+ B0 & rax \\
+ B1 & rbx \\
+ B2 & r10 \\
+ B3 & r11 \\
+ B4 & r12 \\
+ B5 & r13 \\
+ B6 & r14 \\
+ \hline
+ asp & rsi \\
+ bsp & rsp \\
+ hp & rdi \\
+ free & r15 \\
+ \hline
+ scratch & rbp \\
+ scratch & r9 \\
+ \end{tabular}%
+}%
+\hfill%
+\fcolorbox{black}{white}{%
+ \begin{tabular}{ll}
+ rax & B0 \\
+ rbx & B1 \\
+ rcx & A0 \\
+ rdx & A1 \\
+ \hline
+ rbp & scratch \\
+ rdi & hp \\
+ rsi & asp \\
+ rsp & bsp \\
+ \hline
+ r8 & A2 \\
+ r9 & scratch \\
+ r10 & B2 \\
+ r11 & B3 \\
+ r12 & B4 \\
+ r13 & B5 \\
+ r14 & B6 \\
+ r15 & free \\
+ \end{tabular}%
+}%
+\hfill}%
diff --git a/system-v-abi.tex b/system-v-abi.tex
new file mode 100644
index 0000000..fccfab5
--- /dev/null
+++ b/system-v-abi.tex
@@ -0,0 +1,14 @@
+\fcolorbox{black}{white}{%
+ \setlength{\tabcolsep}{.2em}%
+ \begin{tabular}{lcccccc}
+ \multicolumn{7}{c}{\textbf{Function Calls}}\\\hline
+ Arguments: & rdi & rsi & rdx & rcx & r8 & r9\\
+ & hp & asp & A1 & A0 & A2 & scr\\
+ \hline
+ Result: & rax & rdx \\
+ & B0 & A1 \\
+ \hline
+ Callee-saved: & rbx & rbp & r12 & r13 & r14 & r15 \\
+ & B1 & scr & B4 & B5 & B6 & free \\
+ \end{tabular}%
+}%