summaryrefslogtreecommitdiff
path: root/support/lgrind/example
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/lgrind/example
Initial commit
Diffstat (limited to 'support/lgrind/example')
-rwxr-xr-xsupport/lgrind/example/asm2tex17
-rw-r--r--support/lgrind/example/asm2tex.bat14
-rwxr-xr-xsupport/lgrind/example/c2tex17
-rw-r--r--support/lgrind/example/c2tex.bat14
-rw-r--r--support/lgrind/example/egcprog.c34
-rw-r--r--support/lgrind/example/egmasm.asm145
-rw-r--r--support/lgrind/example/lgrindeg.tex51
-rw-r--r--support/lgrind/example/subst5
8 files changed, 297 insertions, 0 deletions
diff --git a/support/lgrind/example/asm2tex b/support/lgrind/example/asm2tex
new file mode 100755
index 0000000000..dcb2fc5a6f
--- /dev/null
+++ b/support/lgrind/example/asm2tex
@@ -0,0 +1,17 @@
+#!/bin/sh
+# convert .asm (Microsoft [or whatever] assembler) to .lg
+
+if [ -n "$1" ] && [ -f $1 -o -f $1.asm ]
+then
+ if [ `basename $1` = `basename $1 .asm` ]
+ then
+ lgrind -i -lmasm $1.asm > $1.lg
+ echo Created $1.lg
+ else
+ lgrind -i -lmasm $1 > `basename $1 .asm`.lg
+ echo Created `basename $1 .asm`.lg
+ fi
+else
+ echo Usage: $0 "<file>[.asm]"
+ echo $1.asm does not exist.
+fi
diff --git a/support/lgrind/example/asm2tex.bat b/support/lgrind/example/asm2tex.bat
new file mode 100644
index 0000000000..b89f223bab
--- /dev/null
+++ b/support/lgrind/example/asm2tex.bat
@@ -0,0 +1,14 @@
+@echo off
+rem convert .asm (Microsoft assembler) to .lg
+if not exist %1.asm goto Complain
+
+lgrind -i -lmasm %1.asm > %1.lg
+echo Created %1.lg
+goto Done
+
+:Complain
+echo '%1.asm' does not exist.
+
+:Done
+
+
diff --git a/support/lgrind/example/c2tex b/support/lgrind/example/c2tex
new file mode 100755
index 0000000000..48a301a726
--- /dev/null
+++ b/support/lgrind/example/c2tex
@@ -0,0 +1,17 @@
+#!/bin/sh
+# convert .c to .lg
+
+if [ -n "$1" ] && [ -f $1 -o -f $1.c ]
+then
+ if [ `basename $1` = `basename $1 .c` ]
+ then
+ lgrind -i -v subst $1.c > $1.lg
+ echo Created $1.lg
+ else
+ lgrind -i -v subst $1 > `basename $1 .c`.lg
+ echo Created `basename $1 .c`.lg
+ fi
+else
+ echo Usage: $0 "<file>[.c]"
+ echo $1.c does not exist.
+fi
diff --git a/support/lgrind/example/c2tex.bat b/support/lgrind/example/c2tex.bat
new file mode 100644
index 0000000000..f4b4a2fbc2
--- /dev/null
+++ b/support/lgrind/example/c2tex.bat
@@ -0,0 +1,14 @@
+@echo off
+rem convert .c to .lg
+if not exist %1.c goto Complain
+
+lgrind -i -v subst %1.c > %1.lg
+echo Created %1.lg
+goto Done
+
+:Complain
+echo '%1.c' does not exist.
+
+:Done
+
+
diff --git a/support/lgrind/example/egcprog.c b/support/lgrind/example/egcprog.c
new file mode 100644
index 0000000000..b79f448051
--- /dev/null
+++ b/support/lgrind/example/egcprog.c
@@ -0,0 +1,34 @@
+/* endian.c
+ * Demonstrates endian ordering
+ */
+
+#include <stdio.h>
+
+void main( void )
+{
+ short Data_16;
+ long Data_32;
+ char far *p;
+
+ Data_16 = 0x1234;
+ Data_32 = 0x56789abc;
+
+ p = (char far *)&Data_16;
+ printf("16-bit quantity, data=%04x\n", Data_16);
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+ p++ ;
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+ p++ ;
+
+
+ p = (char far *)&Data_32;
+ printf("32-bit quantity, data=%08lx\n", Data_32);
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+ p++ ;
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+ p++ ;
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+ p++ ;
+ printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
+
+}
diff --git a/support/lgrind/example/egmasm.asm b/support/lgrind/example/egmasm.asm
new file mode 100644
index 0000000000..b4baa5962c
--- /dev/null
+++ b/support/lgrind/example/egmasm.asm
@@ -0,0 +1,145 @@
+;************************************************
+; vgac.asm
+; PC VGA graphics control in assembly language
+; uses BIOS for keyboard read and setting graphics
+; modes, and procedure for setting a VGA pixel
+; version for C calling convention :-
+; LARGE model
+; no MAIN entry point
+; assemble only (no link)
+; underscore for C-callable functions
+; don't pop arguments off stack (caller does this)
+;
+; J Leis
+; 24 May 1994
+;************************************************
+
+TITLE vgac.asm - vga assembler program, callable from C
+.MODEL LARGE
+.286
+.DOSSEG
+
+; stack segment directive
+.STACK
+
+; data segment directive
+.DATA
+
+; code segment directive
+.CODE
+
+
+_VgaMode PROC
+
+ pusha
+ mov ah, 0 ; function 0 = set video mode
+ mov al, 12h ; mode 12 = vga graphics
+ int 10h
+ popa
+ ret
+
+_VgaMode ENDP
+
+
+_TextMode PROC
+
+ pusha
+ mov ah, 0 ; function 0 = set video
+ mov al, 03h ; mode 3 = text
+ int 10h
+ popa
+ ret
+
+_TextMode ENDP
+
+
+_ShowMessage PROC
+
+ pusha ; save registers if necessary
+
+ ; call DOS interrupt to display a message
+ mov bx, 01h
+ lea dx, mesg ; equivalent to mov dx, OFFSET mesg
+ mov cx, l_mesg
+ mov ah, 040h
+ int 021h
+
+ popa
+ ret
+
+_ShowMessage ENDP
+
+
+_ReadKey PROC
+
+ pusha ; save registers if necessary
+
+ mov ah, 00h ; function 0 - wait for key & read it
+ int 16h ; int 16h = keyboard services
+ ; al now equals ascii code of key
+
+ popa
+ ret
+
+_ReadKey ENDP
+
+
+; setpixel( xc, yc, color )
+; stacking order:
+; memory near call far call
+; color highest [bp+8] [bp+10]
+; y-coord [bp+6] [bp+8]
+; x-coord lowest [bp+4] [bp+6]
+;
+_SetPixel PROC
+
+ push bp
+ mov bp, sp
+
+ pusha ; save registers if necessary
+
+ mov dx, 03CEh ; graphics controller register
+
+ mov ax, 0205h ; write mode 2
+ out dx, ax
+
+ mov ax, 0003h ; function
+ out dx, ax
+
+ mov ax, 0A000h ; graphics screen segment
+ mov es, ax
+
+ mov ax, [bp+8] ; get y co-ord
+ mov bx, 640/8 ; 80 bytes/line
+ mul bx
+ mov bx, [bp+6] ; get x-coord
+ mov cl, 3 ; divide by 8 bits/byte
+ shr bx, cl
+ add bx, ax
+
+ mov al, es:[bx] ; dummy write to latch data in screen RAM
+ mov cx, [bp+6] ; get x-coord
+ and cx, 0007h ; get bit mask
+ mov al, 07h
+ sub al, cl
+ mov ah, 80h
+ shr ah, cl ; shift to bit position
+ mov al, 08h ; set mask register
+
+ mov dx, 03CEh ; dx destroyed by mul
+ out dx, ax ; write bit mask
+
+ mov cx, [bp+10]; color ; write the color value
+ mov es:[bx], cl
+
+ popa
+
+ pop bp
+ ret ; don't pop args off stack - C does this
+
+_SetPixel ENDP
+
+;no main procedure (main in C)
+
+; end of file
+END
diff --git a/support/lgrind/example/lgrindeg.tex b/support/lgrind/example/lgrindeg.tex
new file mode 100644
index 0000000000..5de9f4592f
--- /dev/null
+++ b/support/lgrind/example/lgrindeg.tex
@@ -0,0 +1,51 @@
+% lgrindeg.tex
+% Simple example program for testing `lgrind' additions
+% MATLAB/QBASIC/C/MASM/LaTeX
+% Note: Matlab,qbasic, masm are registered trademarks.
+%
+% John Leis, 18 June 1996
+% University of Southern Queensland
+% leis@usq.edu.au
+
+\documentclass[a4paper]{article}
+
+\usepackage{lgrind}
+
+\begin{document}
+
+\title{ Example of the `LGrind' Package }
+\author{ John Leis }
+\date{ 15 June 1996 }
+\maketitle
+
+\clearpage
+
+\begin{figure}
+ \begin{center}
+ \begin{tabular}{ll}
+ \hline\hline
+ Language & Command in DOS batch file \\
+ \hline
+ C & \verb+ lgrind -i -v subst %1.c > %1.lg + \\
+ MASM & \verb+ lgrind -i -lmasm %1.asm > %1.lg + \\
+ \hline \\
+ \end{tabular}
+ \end{center}
+ \caption{Commands for lgrind'ing source file into \LaTeXe\ format}
+ \label{fig:commands}
+\end{figure}
+
+
+\lagrind{egcprog.lg}{Example `C' language program.}{fig:egcprog}
+
+\clearpage
+\begin{center}
+ \textbf{\large This is a multi-page listing} \\
+ It has no caption. \\
+ Used for Appendices etc. \\
+\end{center}
+
+\lgrindfile{egmasm.lg}
+
+\end{document}
+
diff --git a/support/lgrind/example/subst b/support/lgrind/example/subst
new file mode 100644
index 0000000000..062741373c
--- /dev/null
+++ b/support/lgrind/example/subst
@@ -0,0 +1,5 @@
+x_gamma=x$\sb\gamma$
+f_1=f$_1$
+delta=$\delta$
+Data_16=Data$\sb{16}$
+Data_32=Data$\sb{32}$