Twopass
Twopass
h>
#include <stdlib.h>
#include <string.h>
struct symboltable {
char symbol[10];
int addr;
} s[10];
void main() {
int flag = 0, i, code = 0, addr;
int count = 0, tlen = 0, locctr;
char st[5], a[5], object[6];
char length[6], add[5], symbol[20], operand[20], op[20], label[20];
char mnemonic[10][10] = {"LDA", "STA", "ADD", "LDB", "STCH", "LDCH", "LDB"};
char opcode[10][10] = {"03", "14", "16", "69", "24", "13", "32"};
if (strcmp(op, "START") == 0) {
fprintf(stdout, "H^%s^00^%s\n", label, instructions[0][0]);
strcpy(st, instructions[0][0]);
}
// Processing instructions
for (i = 1; i < 2; i++) {
strcpy(label, instructions[i][1]);
strcpy(op, instructions[i][2]);
strcpy(operand, instructions[i][3]);
flag = 0;
strcpy(object, "");
// Handle literal WORD or BYTE values (not included in this simple example)
if ((strcmp(op, "WORD") == 0) || (strcmp(op, "BYTE") == 0)) {
code = atoi(operand);
flag = 1;
}
// Write E record
fprintf(stdout, "\nE^00%s", st);
}