Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added BUILD
Empty file.
Empty file added Tools/build/BUILD
Empty file.
10 changes: 10 additions & 0 deletions Tools/build/build.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def bison(name, src):
CFILE = "%s.c" % name
HFILE = "%s.h" % name
native.genrule(
name = name,
srcs = [src],
outs = [CFILE, HFILE],
cmd = "bison --defines=$(location {}) --output=$(location {}) $<".format(HFILE, CFILE)
)

68 changes: 68 additions & 0 deletions Tools/esp/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
load("//Tools/build:build.bzl", "bison")

cc_binary(
name = "esp",
srcs = [
"assert.c",
"assert.h",
"class.h",
"code.c",
"code.h",
"cond.h",
"data.c",
"data.h",
"dword.h",
"esp.h",
"expr.c",
"expr.h",
"fixup.c",
"fixup.h",
"flopcode.h",
"flopcodes.h",
"keywords.h",
"lmem.c",
"main.c",
"model.h",
"object.c",
"object.h",
"opcodes.h",
"scan.c",
"scan.h",
"segment.h",
"symbol.c",
"symbol.h",
"table.c",
"table.h",
"type.c",
"type.h",
":parse.c",
],
deps = [
"//Tools/include",
"//Tools/include/compat",
"//Tools/utils",
":bisonlib",
],
)

cc_binary(
name = "printobj",
srcs = ["printobj.c"],
deps = [
"//Tools/include",
"//Tools/include/compat",
"//Tools/utils",
],
)

cc_library(
name = "bisonlib",
srcs = [":parse.h"],
includes = [""]
)

bison(
name = "parse",
src = "parse.y"
)

4 changes: 0 additions & 4 deletions Tools/esp/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
* source pass in MASM.
*
***********************************************************************/
#ifndef lint
static char *rcsid =
"$Id: assert.c,v 1.12 93/09/09 12:34:45 adam Exp $";
#endif lint

#include "esp.h"

Expand Down
2 changes: 2 additions & 0 deletions Tools/esp/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void __eprintf (); /* Defined in gnulib */

# ifdef __STDC__

extern void abort();

# define __assert(expression, file, line) \
(__eprintf ("Failed assertion " expression \
" at line %d of `" file "'.\n", line), \
Expand Down
45 changes: 18 additions & 27 deletions Tools/esp/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@
* Code generators. All functions are FixProc's...
*
***********************************************************************/
#ifndef lint
static char *rcsid =
"$Id: code.c,v 3.43 95/09/20 14:50:21 weber Exp $";
#endif lint

#include "esp.h"
#include "fixup.h"
Expand Down Expand Up @@ -587,6 +583,7 @@ FixupReadWriteCheck(int *addrPtr, /* IN/OUT: Address of inst start */
{
case FR_UNDEF: return(FR_UNDEF);
case FR_ERROR: return (FR_ERROR);
default:;
}

/*
Expand Down Expand Up @@ -2203,6 +2200,7 @@ Code_Arith2(int *addrPtr, /* IN/OUT: Address of instruction start */
{
case FR_UNDEF: return(FR_UNDEF);
case FR_ERROR: return (FR_ERROR);
default:;
}

/*
Expand Down Expand Up @@ -2459,6 +2457,7 @@ Code_BitNF(int *addrPtr, /* IN/OUT: Address of instruction start/end */
{
case FR_UNDEF: return(FR_UNDEF);
case FR_ERROR: return (FR_ERROR);
default:;
}

/*
Expand Down Expand Up @@ -3248,7 +3247,6 @@ Code_DPShift(int *addrPtr, /* IN/OUT: Address of instruction start */
* + sib + 4 disp + db */
byte *ip = ibuf;
int opSize;
int isDWord; /* 1 if opSize is 4, 0 if not */
ExprResult res1, res2;
FixResult result;
long count = (long)data;
Expand Down Expand Up @@ -3277,7 +3275,6 @@ Code_DPShift(int *addrPtr, /* IN/OUT: Address of instruction start */
{
return(FR_ERROR);
}
isDWord = (opSize == 4) ? 1 : 0;

if (RES_IS_CONST(res1.type) || RES_IS_CONST(res2.type)) {
Notify(NOTIFY_ERROR, expr1->file, expr1->line,
Expand Down Expand Up @@ -3785,7 +3782,6 @@ Code_Fcom(int *addrPtr, /* address of instruction start */
int fixAddr;
OpCode *op = (OpCode *)data;
int delay=0, startAddr, typesize;
byte regValue;



Expand All @@ -3795,8 +3791,6 @@ Code_Fcom(int *addrPtr, /* address of instruction start */

ADD_FWAIT_FOR_8087(fixAddr, ip);

/* regValue contains register info for modrm byte */
regValue = (byte)((op->value & 0xf000) >> 12);
if (expr1 == NULL) /* if no operands, just stick in the opcode */
{
*ip = (byte)((op->value & 0x0f00) >> 8);
Expand Down Expand Up @@ -4488,7 +4482,7 @@ Code_Fxch(int *addrPtr, /* IN/OUT: Address of instruction start */
FixResult result;
int fixAddr;
OpCode *op = (OpCode *)data;
int delay, startAddr;
int delay;

START_CODEGEN(pass, *addrPtr, FR_DONE, FR_ERROR);

Expand Down Expand Up @@ -4532,7 +4526,6 @@ Code_Fxch(int *addrPtr, /* IN/OUT: Address of instruction start */
/*
* Install the instruction itself.
*/
startAddr = *addrPtr;
if (res == NULL) /* no operands */ {
CodeFinal(addrPtr, pass, ip-ibuf, prevSize, ibuf, res,
-1, NullID, 0, delay);
Expand Down Expand Up @@ -6722,6 +6715,7 @@ Code_Move(int *addrPtr, /* IN/OUT: Address of instruction start */
{
case FR_UNDEF: return(FR_UNDEF);
case FR_ERROR: return (FR_ERROR);
default:;
}

/*
Expand Down Expand Up @@ -7079,7 +7073,6 @@ Code_NoArg(int *addrPtr, /* IN/OUT: Address of instruction start */
{
OpCode *op = (OpCode *)data;
byte ibuf[3], *ip = ibuf;
int len = 1;

START_CODEGEN(pass, *addrPtr, FR_DONE, FR_ERROR);

Expand Down Expand Up @@ -8619,7 +8612,6 @@ Code_Xchg(int *addrPtr, /* IN/OUT: Address of instruction start */
int opSize;
int notByte; /* 0 if opSize is 1, 1 if not -- used
* when forming opcodes */
int isDWord; /* 1 if opSize is 4, 0 if not */
int delay, startAddr;

START_CODEGEN(pass, *addrPtr, FR_DONE, FR_ERROR);
Expand Down Expand Up @@ -8666,7 +8658,6 @@ Code_Xchg(int *addrPtr, /* IN/OUT: Address of instruction start */
}

notByte = (opSize == 1) ? 0 : 1;
isDWord = (opSize == 4) ? 1 : 0;

/*
* Handle special case of exchanging AX with a word register...
Expand Down Expand Up @@ -8744,19 +8735,19 @@ static const struct {
word pop;
int mask;
} regsave[] = {
0x50, 0x58, 1L << REG_AX,
0x51, 0x59, 1L << REG_CX,
0x52, 0x5a, 1L << REG_DX,
0x53, 0x5b, 1L << REG_BX,
0x54, 0x5c, 1L << REG_SP,
0x55, 0x5d, 1L << REG_BP,
0x56, 0x5e, 1L << REG_SI,
0x57, 0x5f, 1L << REG_DI,
0x06, 0x07, 1L << (REG_SEGBASE+REG_ES),
0x16, 0x17, 1L << (REG_SEGBASE+REG_SS),
0x1e, 0x1f, 1L << (REG_SEGBASE+REG_DS),
0x0fa0, 0x0fa1, 1L << (REG_SEGBASE+REG_FS),
0x0fa8, 0x0fa9, 1L << (REG_SEGBASE+REG_GS),
{ 0x50, 0x58, 1L << REG_AX },
{ 0x51, 0x59, 1L << REG_CX },
{ 0x52, 0x5a, 1L << REG_DX },
{ 0x53, 0x5b, 1L << REG_BX },
{ 0x54, 0x5c, 1L << REG_SP },
{ 0x55, 0x5d, 1L << REG_BP },
{ 0x56, 0x5e, 1L << REG_SI },
{ 0x57, 0x5f, 1L << REG_DI },
{ 0x06, 0x07, 1L << (REG_SEGBASE+REG_ES) },
{ 0x16, 0x17, 1L << (REG_SEGBASE+REG_SS) },
{ 0x1e, 0x1f, 1L << (REG_SEGBASE+REG_DS) },
{ 0x0fa0, 0x0fa1, 1L << (REG_SEGBASE+REG_FS) },
{ 0x0fa8, 0x0fa9, 1L << (REG_SEGBASE+REG_GS) },
};

#define ALL_REG ((1L<<REG_SEGBASE)-1)
Expand Down
5 changes: 1 addition & 4 deletions Tools/esp/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
* (there being nothing to optimize or finalize as far as data go).
*
***********************************************************************/
#ifndef lint
static char *rcsid =
"$Id: data.c,v 1.35 94/11/10 14:51:34 adam Exp $";
#endif lint

#if defined(__HIGHC__)
pragma Code("MYDATA");
Expand Down Expand Up @@ -1932,6 +1928,7 @@ Data_Enter(int *addrPtr, /* IN/OUT: address at which to store */
case TYPE_PTR:
return Data_Enter(addrPtr, type->tn_u.tn_array.tn_base,
expr, type->tn_u.tn_array.tn_length);
default:;
}
}

Expand Down
11 changes: 4 additions & 7 deletions Tools/esp/esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef _ESP_H_
#define _ESP_H_

#include <config.h>
#include "config.h"
#include <compat/queue.h>
#include <compat/string.h>
#include <compat/stdlib.h>
Expand All @@ -30,17 +30,14 @@
#include <stdio.h>
#undef sprintf
#include <stdarg.h>
#include <stdint.h>

#include <mem.h>
#include <os90.h>
#include <bswap.h>
#include <st.h> /* String table definitions */
#include <malloc.h>

#if !defined(_LINUX)
#define alloca(size) alloca_isnt_portable_you_goob_so_dont_use_it()
#endif

#define FALSE 0
#define TRUE (!FALSE)

Expand Down Expand Up @@ -201,8 +198,8 @@ extern ID *libNames; /* Name(s) of library being assembled */
extern int numLibNames;

/* parse.y */
extern void yywarning(char *fmt, ...);
extern void yyerror(char *fmt, ...);
extern void yywarning(const char *fmt, ...);
extern void yyerror(const char *fmt, ...);
extern int yyparse(void);
extern int dot;
extern int fall_thru; /* Set if .fall_thru directive was
Expand Down
Loading