;Alto->8086 small-c compiler rev 2.0
C←CODE SEGMENT

$INCLUDE(8086LIB.D)

$INCLUDE(rpctest.DEC)

ASSUME CS:C←CODE, DS:C←DATA

; #include <Alloc.h>

; extern AddToDispatcherSpecs();

; extern AddType();

; extern int *Allocate();

; extern struct ShortSTRING *CStringToString();

; extern Block();

; extern CallContext();

; extern int CallFormatted();

; extern CallSwat();

; extern int CONT();

; extern Dismiss();

; extern Free();

; extern int ExportFailed;

; extern ExportInterface();

; extern InitOS();

; extern int ImportFailed;

; extern int ImportInterface();

; extern struct VersionRange *matchAllVersions;

; extern Move2();

; extern MoveBlock();

; extern int mySoc;

; extern RPCInitialize();

; extern RPCInitializeCtx();

; extern int *StartDispatcherSpecs();

; extern StartNProcess();

; extern int StdDispatcher();

; extern Zero();

; extern ReadCalendar();

; extern int largest, totAv, routSent, routRcvd, calSent, calRcvd;

; extern struct ZN *sysZone;

; extern struct EncryptionKey nullKeyB;

; static struct Queue ctxQ;

; static int/*BOOL*/ running;

; static int/*BOOL*/ beUser;

; static int/*BOOL*/ beServer;

; static struct ShortSTRING *retRope;

; static struct ShortSTRING *srvr, *usr;

; static struct ShortSTRING *spNl, *spWd, *spSt, *spSt2, *spSq;

; static int remote;

; static struct Conversation *shhhh;

; extern/*forward*/ Client();

; Main() {
←Main:
 CALL StkChk
PUSH BP
MOV BP,SP

;   srvr = usr = 0;
MOV WORD PTR ←usr,0
MOV WORD PTR ←srvr,0

;   shhhh = unencrypted;
MOV WORD PTR ←shhhh,0

;   InitOS(); /* Sets up sysZone */
CALL ←InitOS

;   Zero(&ctxQ, 2);
MOV BX,2
LEA CX,←ctxQ
CALL ←Zero

;   RPCInitialize(&ctxQ);
LEA BX,←ctxQ
CALL ←RPCInitialize

;   spNl = (struct ShortSTRING *) Allocate(sysZone, 2);
MOV BX,2
MOV CX,←sysZone
CALL ←Allocate
MOV ←spNl,BX

;   spWd = CStringToString("W");
MOV BX,"W"
CALL ←CStringToString
MOV ←spWd,BX

;   spSt = CStringToString("S");
MOV BX,"S"
CALL ←CStringToString
MOV ←spSt,BX

;   spSt2 = CStringToString("DSS");
MOV BX,"DSS"
CALL ←CStringToString
MOV ←spSt2,BX

;   spSq = CStringToString("C");
MOV BX,"C"
CALL ←CStringToString
MOV ←spSq,BX

;   StartNProcess("Client", &ctxQ, &Client, 350, 90); /* ?? */
MOV BX,"Client"
PUSH BX
LEA BX,←ctxQ
PUSH BX
MOV BX,OFFSET ←Client
PUSH BX
MOV BX,05AX
MOV CX,015EX
CALL ←StartNProcess
ADD SP,6

;   while (true) { CallContext(ctxQ.head); }; };
X1:
MOV BX,WORD PTR ←ctxQ
CALL ←CallContext
JR X1
X2:
MOV SP,BP
POP BP
RET;

; static int time[2];

; static struct ImportInstance handle[1];

; static struct Seal sl;

; static struct InterfaceName *clientInterface;

; static struct ShortSTRING *tibet;

; static struct ShortSTRING *seqRope;

; static int res;

; static int teddyMode; /* Silent, but fast. */

; int args[10];

; static Client() {
←Client:
 CALL StkChk
PUSH BP
MOV BP,SP

;   	int c, go;

;   while (true) {
ADD SP,0FFFCX
X3:

;   	go=false; remote=false; teddyMode=false;
MOV WORD PTR [BP-4],0
MOV ←remote,0
MOV ←teddyMode,0

; 	Wf("\r.");
MOV BX,"↑."
CALL ←Wf

; 	c = MyGetChar();
CALL ←MyGetChar

;	←c ← BX
MOV [BP-2],BX

; 	putchar(c);

;	BX ← ←c
MOV BX,[BP-2]
CALL ←putchar

; 	switch (c) {

;	BX ← ←c
MOV BX,[BP-2]
JR X5

; 	  case 'q': teddyMode=true;break;	/* be QUIET */
X7:
MOV ←teddyMode,0FFFFX
JR X6

; 	  case 'Q': teddyMode=false; break; /* shout */
X8:
MOV ←teddyMode,0
JR X6

; 	  case 'g': go=true;
X9:
MOV WORD PTR [BP-4],0FFFFX

; 	  case 'i': Initialize(); if (!go) break;
X10:
CALL ←Initialize

;	BX ← ←go
POP BX
PUSH BX
OR BX,BX
JNZ X11
JR X6
X11:

; 	  case 's': Server(); if (!go) break;
X12:
CALL ←Server

;	BX ← ←go
POP BX
PUSH BX
OR BX,BX
JNZ X13
JR X6
X13:

; 	  case 'b': Bind(); break
X14:
CALL ←Bind
JR X6

; 	  case 'r': remote = true; srvr = CStringToString("173#125#");
X15:
MOV ←remote,0FFFFX
MOV BX,"173#125#"
CALL ←CStringToString
MOV ←srvr,BX

; 				break;
JR X6

; 	  case 'x': {
X16:

; 		struct ShortSTRING *tester, *testee; /* random RNames, for now */
ADD SP,0FFFCX

; 		tester = CStringToString("Swinehart.pa");
MOV BX,"Swinehart.pa"
CALL ←CStringToString

;	←tester ← BX
MOV [BP-6],BX

; 		testee = CStringToString("Einstein.lark");
MOV BX,"Einstein.lark"
CALL ←CStringToString

;	←testee ← BX
POP DX
PUSH BX

; 		shhhh = StartConversation(tester, &nullKeyB, testee, slECB); break };

;	BX ← ←tester
MOV BX,[BP-6]
PUSH BX
LEA BX,←nullKeyB
PUSH BX
MOV BX,0200X

;	CX ← ←testee
MOV CX,[BP-8]
CALL ←StartConversation
ADD SP,4
MOV ←shhhh,BX
ADD SP,4
JR X6

; 	  case '1':
X17:

; 		res=CallFormatted(handle, Simple, spNl, spNl, 0); break;
JR $+8
X5:
JMP X18
X6:
JMP X19
LEA BX,←handle
PUSH BX
MOV BX,4
PUSH BX
MOV BX,←spNl
PUSH BX
XOR BX,BX
MOV CX,←spNl
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX
JMP X19

; 	  case '2': {
X20:

;   		args[0]= 0x1234
MOV ←args,01234X

;   		res = CallFormatted(handle, SArg, spWd, spNl, args); break; };
LEA BX,←handle
PUSH BX
MOV BX,5
PUSH BX
MOV BX,←spWd
PUSH BX
LEA BX,←args
MOV CX,←spNl
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX
JMP X19

; 	  case '3':
X21:

;   		res = CallFormatted(handle, SRet, spNl, spWd, 0);
LEA BX,←handle
PUSH BX
MOV BX,6
PUSH BX
MOV BX,←spNl
PUSH BX
XOR BX,BX
MOV CX,←spWd
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX

; 		Wf1("res = %xH\r", res); break;
MOV BX,←res
MOV CX,"res = %xH↑"
CALL ←Wf1
JMP X19

; 	  case '4':
X22:

; 		args[0] = (int) time;
LEA BX,←time
MOV ←args,BX

; 		args[1] = (int) tibet;
MOV BX,←tibet
MOV ←args+2,BX

; 		args[2] = (int) tibet;
MOV BX,←tibet
MOV ←args+4,BX

;   		res = CallFormatted(handle, SendRope, spSt2, spNl, args); break;
LEA BX,←handle
PUSH BX
MOV BX,7
PUSH BX
MOV BX,←spSt2
PUSH BX
LEA BX,←args
MOV CX,←spNl
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX
JMP X19

; 	  case '5': WfNFree("res = %s\r",
X23:

; 				res=CallFormatted(handle, GetRope, spNl, spSt, 0)); break;
LEA BX,←handle
PUSH BX
MOV BX,8
PUSH BX
MOV BX,←spNl
PUSH BX
XOR BX,BX
MOV CX,←spSt
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX
MOV CX,"res = %s↑"
CALL ←WfNFree
JMP X19

; 	  case '6': {
X24:

;   		args[0] = 0;
MOV ←args,0

;   		res = CallFormatted(handle, SendSeq, spSq, spWd, args);
LEA BX,←handle
PUSH BX
MOV BX,9
PUSH BX
MOV BX,←spSq
PUSH BX
LEA BX,←args
MOV CX,←spWd
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX

;   		args[0] =((int) &seqRope->maxLength);
MOV BX,←seqRope
INC BX
INC BX
MOV ←args,BX

;   		res = CallFormatted(handle, SendSeq, spSq, spWd, args);
LEA BX,←handle
PUSH BX
MOV BX,9
PUSH BX
MOV BX,←spSq
PUSH BX
LEA BX,←args
MOV CX,←spWd
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX

; 		break; };
JMP X19

; 	  case '7': {
X25:

;   		args[0]=0x4321
MOV ←args,04321X

;   		res = CallFormatted(handle, GetSeq, spWd, spSq, args);
LEA BX,←handle
PUSH BX
MOV BX,0AX
PUSH BX
MOV BX,←spWd
PUSH BX
LEA BX,←args
MOV CX,←spSq
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX

; 		Wf1("res = %xH\r", res); break; };
MOV BX,←res
MOV CX,"res = %xH↑"
CALL ←Wf1
JMP X19

; 	  case '8': {
X26:

; 		args[0] = (int) time;
LEA BX,←time
MOV ←args,BX

; 		args[1] = (int) tibet;
MOV BX,←tibet
MOV ←args+2,BX

; 		args[2] = (int) tibet;
MOV BX,←tibet
MOV ←args+4,BX

; 		AttachConversation(handle, shhhh);
MOV BX,←shhhh
LEA CX,←handle
CALL ←AttachConversation

;   		res = CallFormatted(handle, SendRope, spSt2, spNl, args);
LEA BX,←handle
PUSH BX
MOV BX,7
PUSH BX
MOV BX,←spSt2
PUSH BX
LEA BX,←args
MOV CX,←spNl
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX

; 		AttachConversation(handle, unencrypted); break; };
XOR BX,BX
LEA CX,←handle
CALL ←AttachConversation
JMP X19

; 	  case '9': {
X27:

; 		AttachConversation(handle, shhhh);
MOV BX,←shhhh
LEA CX,←handle
CALL ←AttachConversation

; 		WfNFree("res = %s\r",

; 				res=CallFormatted(handle, GetRope, spNl, spSt, 0));
LEA BX,←handle
PUSH BX
MOV BX,8
PUSH BX
MOV BX,←spNl
PUSH BX
XOR BX,BX
MOV CX,←spSt
CALL ←CallFormatted
ADD SP,6
MOV ←res,BX
MOV CX,"res = %s↑"
CALL ←WfNFree

; 		AttachConversation(handle, unencrypted); break; };
XOR BX,BX
LEA CX,←handle
CALL ←AttachConversation
JMP X19

; 	  case 'p':
X28:

; 		Wf1("res = %x\r", res); break;
MOV BX,←res
MOV CX,"res = %x↑"
CALL ←Wf1
JMP X19

; 	  case 't':
X29:

; 		ReadCalendar(time);
LEA BX,←time
CALL ←ReadCalendar

; 		Alloc(sysZone, 0);
XOR BX,BX
MOV CX,←sysZone
CALL ←Alloc

; 		Wf4("Time = (%o, %o), TotAv = %d, Largest = %d\r",

; 			time[1], time[0], totAv, largest);
MOV BX,"Time = (%o, %o), TotAv = %d, Largest = %d↑"
PUSH BX
MOV BX,←time+2
PUSH BX
MOV BX,←time
PUSH BX
MOV BX,←largest
MOV CX,←totAv
CALL ←Wf4
ADD SP,6

; 		Wf4("Rout/Cal Sent/Rcvd = %d, %d, %d, %d\r",

; 			routSent, routRcvd, calSent, calRcvd); break;
MOV BX,"Rout/Cal Sent/Rcvd = %d, %d, %d, %d↑"
PUSH BX
MOV BX,←routSent
PUSH BX
MOV BX,←routRcvd
PUSH BX
MOV BX,←calRcvd
MOV CX,←calSent
CALL ←Wf4
ADD SP,6
JMP X19

; 	  default: Wf(" ?? "); break; }; }; };
X30:
MOV BX," ?? "
CALL ←Wf
JMP X19
JMP X19
X18:
MOV AL,BH
OR AL,AL
JNZ X30
MOV AL,BL
CMP AL,071X
JMPZ X7
CMP AL,051X
JMPZ X8
CMP AL,067X
JMPZ X9
CMP AL,069X
JMPZ X10
CMP AL,073X
JMPZ X12
CMP AL,062X
JMPZ X14
CMP AL,072X
JMPZ X15
CMP AL,078X
JMPZ X16
CMP AL,031X
JMPZ X17
CMP AL,032X
JMPZ X20
CMP AL,033X
JMPZ X21
CMP AL,034X
JMPZ X22
CMP AL,035X
JMPZ X23
CMP AL,036X
JMPZ X24
CMP AL,037X
JMPZ X25
CMP AL,038X
JMPZ X26
CMP AL,039X
JMPZ X27
CMP AL,070X
JMPZ X28
CMP AL,074X
JMPZ X29
JMP X30
X19:
JMP X3
X4:
MOV SP,BP
POP BP
RET;

; static int MyGetChar() {
←MyGetChar:
 CALL StkChk
PUSH BP
MOV BP,SP

; 	while (!chav()) Block();
X31:
CALL ←chav
OR BX,BX
JNZ X32
CALL ←Block
JR X31
X32:

; 	return getchar(); };
CALL ←getchar
MOV SP,BP
POP BP
RET;

; static WfNFree(pat, str) int *pat; struct ShortSTRING *str; {
←WfNFree:
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH CX
PUSH BX

; 	int *cstr;

; 	if (str==0) return;
PUSH DX

;	BX ← ←str
MOV BX,[BP-4]
OR BX,BX
JNZ X33
MOV SP,BP
POP BP
RET;
X33:

; 	cstr = StringToCString(sysZone, str); Free(sysZone, str);

;	BX ← ←str
MOV BX,[BP-4]
MOV CX,←sysZone
CALL ←StringToCString

;	←cstr ← BX
POP DX
PUSH BX

;	BX ← ←str
MOV BX,[BP-4]
MOV CX,←sysZone
CALL ←Free

; 	if (!teddyMode) Wf1(pat, cstr); Free(sysZone, cstr); };
MOV BX,←teddyMode
OR BX,BX
JNZ X34

;	BX ← ←cstr
POP BX
PUSH BX

;	CX ← ←pat
MOV CX,[BP-2]
CALL ←Wf1
X34:

;	BX ← ←cstr
POP BX
PUSH BX
MOV CX,←sysZone
CALL ←Free
MOV SP,BP
POP BP
RET;

; static Initialize() {
←Initialize:
 CALL StkChk
PUSH BP
MOV BP,SP

;   RPCInitializeCtx(true);
MOV BX,0FFFFX
CALL ←RPCInitializeCtx

;   AddType('Z', 0);
XOR BX,BX
MOV CX,05AX
CALL ←AddType

;   Zero(handle, lenImportInstance);
MOV BX,6
LEA CX,←handle
CALL ←Zero

;   clientInterface = (struct InterfaceName *) Allocate(sysZone, lenInterfaceName);
MOV BX,4
MOV CX,←sysZone
CALL ←Allocate
MOV ←clientInterface,BX

;   clientInterface->type = CStringToString("TestLupine");
MOV BX,"TestLupine"
CALL ←CStringToString
MOV CX,BX
MOV BX,←clientInterface
MOV [BX],CX

;   clientInterface->instance = usr;
MOV BX,←clientInterface
MOV CX,←usr
MOV [BX+2],CX

;   Move2(&clientInterface->version, matchAllVersions);
MOV BX,←clientInterface
ADD BX,4
PUSH BX
MOV BX,←matchAllVersions
POP CX
CALL ←Move2

;   tibet = CStringToString("This rope went to Everest");
MOV BX,"This rope went to Everest"
CALL ←CStringToString
MOV ←tibet,BX

;   seqRope = CStringToString("This is really a sequence"); };
MOV BX,"This is really a sequence"
CALL ←CStringToString
MOV ←seqRope,BX
MOV SP,BP
POP BP
RET;

; static Bind () {
←Bind:
 CALL StkChk
PUSH BP
MOV BP,SP

;   { /* Implicit loop until ENABLE succeeds */

;   int serverMachine;
PUSH DX

;   serverMachine = 0;
MOV WORD PTR [BP-2],0

;   if (ENABLE(ImportFailed, &CONT, &sl))
MOV BX,←ImportFailed
PUSH BX
LEA BX,←sl
MOV CX,OFFSET ←CONT
CALL ←ENABLE
POP DX
OR BX,BX
JZ X35

; 	CallSwat(ecPup1+100);
MOV BX,04064X
CALL ←CallSwat
X35:

;   ImportInterface(serverMachine, clientInterface, handle); }; /* endloop */ };

;	BX ← ←serverMachine
POP BX
PUSH BX
PUSH BX
LEA BX,←handle
MOV CX,←clientInterface
CALL ←ImportInterface
POP DX
POP DX
MOV SP,BP
POP BP
RET;

; extern/*forward*/ DoSimple();

; extern/*forward*/ DoSArg();

; extern/*forward*/ int DoSRet();

; extern/*forward*/ int DoSendRope();

; extern/*forward*/ struct ShortSTRING *DoGetRope();

; extern/*forward*/ int DoSendSeq();

; extern/*forward*/ int DoGetSeq();

; static Server()  {
←Server:
 CALL StkChk
PUSH BP
MOV BP,SP

;   struct InterfaceName *interface;

;   int *specs;
ADD SP,0FFFCX

;   interface = (struct InterfaceName *) Allocate(sysZone, lenInterfaceName);
MOV BX,4
MOV CX,←sysZone
CALL ←Allocate

;	←interface ← BX
MOV [BP-2],BX

;   interface->type = CStringToString("TestLupine");
MOV BX,"TestLupine"
CALL ←CStringToString
MOV CX,BX

;	BX ← ←interface
MOV BX,[BP-2]
MOV [BX],CX

;   interface->instance = srvr;	/* Field broadcasts if not remote (for now)! */

;	BX ← ←interface
MOV BX,[BP-2]
MOV CX,←srvr
MOV [BX+2],CX

;   Move2(&interface->version, matchAllVersions);

;	BX ← ←interface
MOV BX,[BP-2]
ADD BX,4
PUSH BX
MOV BX,←matchAllVersions
POP CX
CALL ←Move2

;   specs = StartDispatcherSpecs(9);
MOV BX,9
CALL ←StartDispatcherSpecs

;	←specs ← BX
POP DX
PUSH BX

;   AddToDispatcherSpecs(specs, Simple, &DoSimple, spNl, spNl);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,4
PUSH BX
MOV BX,OFFSET ←DoSimple
PUSH BX
MOV BX,←spNl
MOV CX,←spNl
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, SArg, &DoSArg, spWd, spNl);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,5
PUSH BX
MOV BX,OFFSET ←DoSArg
PUSH BX
MOV BX,←spNl
MOV CX,←spWd
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, SRet, &DoSRet, spNl, spWd);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,6
PUSH BX
MOV BX,OFFSET ←DoSRet
PUSH BX
MOV BX,←spWd
MOV CX,←spNl
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, SendRope, &DoSendRope, spSt2, spWd);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,7
PUSH BX
MOV BX,OFFSET ←DoSendRope
PUSH BX
MOV BX,←spWd
MOV CX,←spSt2
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, GetRope, &DoGetRope, spNl, spSt);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,8
PUSH BX
MOV BX,OFFSET ←DoGetRope
PUSH BX
MOV BX,←spSt
MOV CX,←spNl
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, SendSeq, &DoSendSeq, spSq, spWd);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,9
PUSH BX
MOV BX,OFFSET ←DoSendSeq
PUSH BX
MOV BX,←spWd
MOV CX,←spSq
CALL ←AddToDispatcherSpecs
ADD SP,6

;   AddToDispatcherSpecs(specs, GetSeq, &DoGetSeq, spWd, spSq);

;	BX ← ←specs
POP BX
PUSH BX
PUSH BX
MOV BX,0AX
PUSH BX
MOV BX,OFFSET ←DoGetSeq
PUSH BX
MOV BX,←spSq
MOV CX,←spWd
CALL ←AddToDispatcherSpecs
ADD SP,6

;   ExportInterface(interface, &StdDispatcher, specs);

;	BX ← ←interface
MOV BX,[BP-2]
PUSH BX

;	BX ← ←specs
MOV BX,[BP-4]
MOV CX,OFFSET ←StdDispatcher
CALL ←ExportInterface
POP DX

;   retRope = CStringToString("Don\'t fence me in"); };
MOV BX,"Don't fence me in"
CALL ←CStringToString
MOV ←retRope,BX
MOV SP,BP
POP BP
RET;

; static DoSimple() {};
←DoSimple:
 CALL StkChk
PUSH BP
MOV BP,SP
MOV SP,BP
POP BP
RET;

; static DoSArg(a) int a; {if (!teddyMode) Wf1("  ||SArg Called With %xH\r",a);};
←DoSArg:
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH BX
MOV BX,←teddyMode
OR BX,BX
JNZ X36

;	BX ← ←a
POP BX
PUSH BX
MOV CX,"  ||SArg Called With %xH↑"
CALL ←Wf1
X36:
MOV SP,BP
POP BP
RET;

; static int DoSRet()  {return 0x7654; };
←DoSRet:
 CALL StkChk
PUSH BP
MOV BP,SP
MOV BX,07654X
MOV SP,BP
POP BP
RET;

; static int DoSendRope(d, r, s) struct ShortSTRING *r, *s; int *d; { 
←DoSendRope:
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH CX
PUSH BX

; 	WfNFree("  ||SendRope Called With %s and %s and %d\r", r, s, d[0]); return 0-true; };
MOV BX,"  ||SendRope Called With %s and %s and %d↑"
PUSH BX

;	BX ← ←r
MOV BX,[BP-2]
PUSH BX

;	DI ← ←d
MOV DI,[BP+4]
MOV BX,[DI]

;	CX ← ←s
MOV CX,[BP-4]
CALL ←WfNFree
ADD SP,4
MOV BX,1
MOV SP,BP
POP BP
RET;

; static struct ShortSTRING *DoGetRope() { return retRope; };
←DoGetRope:
 CALL StkChk
PUSH BP
MOV BP,SP
MOV BX,←retRope
MOV SP,BP
POP BP
RET;

; static int DoSendSeq(s) int *s; {
←DoSendSeq:
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH BX

; 	if (!teddyMode) Wf1("  ||SendSeq Called With %xH\r",s); 
MOV BX,←teddyMode
OR BX,BX
JNZ X37

;	BX ← ←s
POP BX
PUSH BX
MOV CX,"  ||SendSeq Called With %xH↑"
CALL ←Wf1
X37:

; 	if (s) Free(sysZone, s); return 0-true; };

;	BX ← ←s
POP BX
PUSH BX
OR BX,BX
JZ X38

;	BX ← ←s
POP BX
PUSH BX
MOV CX,←sysZone
CALL ←Free
X38:
MOV BX,1
MOV SP,BP
POP BP
RET;

; static int DoGetSeq(a) int *a; {return ((int) &retRope->maxLength); };
←DoGetSeq:
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH BX
MOV BX,←retRope
INC BX
INC BX
MOV SP,BP
POP BP
RET;

; char *StringToCString(zone, s)
←StringToCString:

;   struct ZN *zone;

;   struct ShortSTRING *s;
 CALL StkChk
PUSH BP
MOV BP,SP
PUSH CX
PUSH BX

;   {

;   int len, i; char b[];
ADD SP,0FFFAX

;   len = s->length;

;	DI ← ←s
MOV DI,[BP-4]
MOV BX,[DI]

;	←len ← BX
MOV [BP-6],BX

;   b = (char *) Allocate(zone, len/2+1);

;	BX ← ←len
MOV BX,[BP-6]
SAR BX
INC BX

;	CX ← ←zone
MOV CX,[BP-2]
CALL ←Allocate

;	←b ← BX
POP DX
PUSH BX

;   for (i = 0; i<len; ++i) b[i] = s->text[i];
MOV WORD PTR [BP-8],0
X41:

;	BX ← ←len
MOV BX,[BP-6]

;	CX ← ←i
MOV CX,[BP-8]
CMP CX,BX
JGE X40
JR X39
X42:
INC WORD PTR [BP-8]
JR X41
X39:

;	BX ← ←i
MOV BX,[BP-8]

;	CX ← ←b
POP CX
PUSH CX
ADD BX,CX

;	CX ← ←s
MOV CX,[BP-4]
ADD CX,4

;	AX ← ←i
MOV AX,[BP-8]
ADD AX,CX
MOV DI,AX
MOV AL,[DI]
MOV [BX],AL
JR X42
X40:

;   b[i]=0;

;	BX ← ←i
MOV BX,[BP-8]

;	CX ← ←b
POP CX
PUSH CX
ADD BX,CX
MOV BYTE PTR [BX],0

;   return(b);

;	BX ← ←b
POP BX
PUSH BX
MOV SP,BP
POP BP
RET;

;   };

; Externals Declared Here
PUBLIC ←Main
PUBLIC ←args
PUBLIC ←StringToCString

C←CODE ENDS

; Number of Bytes of Code = 06E0X, (1760)