Category : Assembly Language Source Code
Archive   : LOC1.ZIP
Filename : LOC.MSG

 
Output of file : LOC.MSG contained in archive : LOC1.ZIP
/* Listing One - BOOT.C - DOS LOCATE UTILITY - DDJ Dec'87, p68 */

#include
#include
#include
#include
#include

#include "loc.h"
#include "externs.h"

void create_bootstrap(seg_list, entry)
SEG_DESCRIPTOR *seg_list ;
unsigned char *entry ;
{
unsigned int count ;
unsigned char *ptr ;

SEG_DESCRIPTOR *p, *q ;

/*
This function sets up a new class which contains the bootstrap
code to the program entry point. The bootstrap segment is
always located at physical address FFFF0H is ROMable.

The bootstrap record is appended to the load module for the
purpose of locate processing.
*/

/* Traverse the linked list to the end. */
p = seg_list ;
while (p->next != NULL)
p = p->next ;

/* Allocate the memory for the bootstrap record */
if ((q = (SEG_DESCRIPTOR *) malloc(sizeof (*p))) == NULL ) {
perror(_FILE_) ;
exit(1) ;
}

/* Append the bootstrap record to the end of the list */
p->next = q ;

/* Initalize the bootstrap segment descriptor */
strcpy(q->name, "??BOOT") ;
strcpy(q->class, "(ABSOLUTE)") ;
q->vseg = 0xffff ;
a->pseg = 0xffff ;
q->offset = 0x0000 ;
q->len = 5 ;
q->inited = TRUE ;
q->romable = TRUE ;
q->symbols = 0 ;
q->symbol_list = NULL ;
q-?next + NULL ;

/* Allocate RAM and build the reset vector code using a far jmp */
ptr = malloc(q->len ;
*ptr = 0xEA ;
*((unsigned char**)(ptr + 1)) = entry ;

/* Append the bootstrap code on tail of the load module */
q->position = lseek(tmp_file, 0L, SEEK_END) ;
count = write(tmp_file, ptr, q->len) ;
if (count != q->len) {
perror(_FILE_) ;
exit(1) ;
}

free(ptr) ;
return ;
}

/* Listing Twelve from the DOS LOCATE UTILITY - DDJ Jan'88, p42 */

/* EXTERNS.H */

/* This include file contains all of the external symbol definitions
for modules that refer to external data.
*/

#ifndef GLOBALS

extern unsigned int load_segment ;
extern SEG_DESCRIPTOR *seg_list ;

extern char config_fname[FILENAME], abs_fname[FILENAME] ;
extern char module_name[FILENAME], locate_fname[FILENAME] ;
extern char print_fname[FILENAME], exe_fname[FILENAME] ;
extern char map_fname[FILENAME], tmp_fname[FILENAME] ;

extern char command_line[COMMAND_LINE] ;

extern int tmp_file ;
extern int abs_file ;
extern int exe_file ;

extern FILE *map_file ;
extern FILE *print_file ;
extern FILE *config_file ;

extern BOOLEAN boot_rec, help, config, user_abort, hex_name ;

#endif

/* Listing Thirteen - GLOBALS.H - DOS LOCATE UTILITY, DDJ Jan'88 */

/*
Thid module contains all of the global data declarations
*/

#ifndef GLOBALS

unsigned int load_segment ;
SEG_DESCRIPTOR *seg_list ;

char config_fname[FILENAME], abs_fname[FILENAME] ;
char module_name[FILENAME], locate_fname[FILENAME] ;
char print_fname[FILENAME], exe_fname[FILENAME] ;
char map_fname[FILENAME], tmp_fname[FILENAME] ;

char command_line[COMMAND_LINE] ;

int tmp_file ;
int abs_file ;
int exe_file ;

FILE *map_file ;
FILE *print_file ;
FILE *config_file ;

BOOLEAN boot_rec = FALSE, help = FALSE, config = FALSE ;
BOOLEAN user_abort = FALSE, hex_name = FALSE ;

#define GLOBALS

#endif

/* Listing Fourteen - LOC.H - DOS LOCATE UTILITY DDJ Jan'88 */

#define MAX_TOKEN 80
#define MAX_LINE 80
#define FILENAME 80
#define COMMAND_LINE 256

#define PAGE_SIZE 512

#define ERROR 0 /* Error condition exists */
#define OK 1 /* No error(s) detected */

#define T_EOL -2 /* Reached the end of a line */
#define T_ERROR -1 /* Detected an error condition */
#define T_OK 0 /* Everything fine */
#define T_OCT 1 /* Octal format integer */
#define T_DEC 2 /* Decimal format integer */
#define T_HEX 3 /* Hexidecimal format integer */
#define T_WORD 4 /* Symbol character string */
#define T_OP 5 /* Operator character string */

typedef enum { FALSE = 0, TRUE } BOOLEAN ;

#define low_byte(x) ((x) & 0xff)
#define high_byte(x) (low_byte((x) >> 8))
#define dim(x) (sizeof(x)/sizeof(x([0]))

typedef struct {
unsigned int signature ;
unsigned int length ;
unsigned int pages ;
unsigned int reloc_items ;
unsigned int header_size ;
unsigned int min_para ;
unsigned int max_para ;
unsigned int stack_seg_disp ;
unsigned int initial_sp ;
unsigned int checksum ;
unsigned int initial_pc ;
unsigned int code_seg_disp ;
unsigned int first_reloc_item ;
unsigned int overlay_num ;
} EXE_HEADER ;

typedef struct sym_list {
struct sym_list *next ;
char name[32] ;
unsigned int value ;
unsigned char type ;
} SYMBOL_LIST ;

typedef struct seg_descriptor {
struct seg_descriptor *next ;
long position ;
char name[32] ;
char class[32] ;
unsigned int vseg ;
unsigned int pseg ;
unsigned int offset ;
unsigned int len ;
int inited ;
int romable ;
unsigned int symbols ;
SYMBOL_LIST *symbol_list ;
} SEG_DESCTIPTOR ;

char *load_exe_file() ;
SEG_DESCRIPTOR *build_seg_list() ;

int get_ch() ;
int unget_ch() ;
char *get_cmd() ;
char *get_line() ;

int get_token() ;

char *get_mem(unsigned long) ;
void free_mem(char *) ;

char *process_command_line() ;
void read_symbol_table(SEG_DESCRIPTOR *) ;

void output_hex_OMF(int, SEG_DESCRIPTOR *, unsigned char *) ;
void open_file_system() ;
void close_file_system() ;
void break_handler() ;

#define DATA_RECORD 0
#define EOF_RECORD 1
#define ADDR_RECORD 2
#define START_RECORD 3

void write_START_record(int, unsigned char *) ;
void write_ADDR_record(int, unsigned int ) ;
void write_DATA_record(int, unsigned int, unsigned char *,
unsigned int ) ;
void write_EOF_record(int) ;
void output_hex_record(int, unsigned char, unsigned int,
unsigned char *, unsigned char ) ;;


  3 Responses to “Category : Assembly Language Source Code
Archive   : LOC1.ZIP
Filename : LOC.MSG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/