Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix . handling in hex2 #20

Merged
merged 2 commits into from Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions M1-macro.c
Expand Up @@ -147,9 +147,9 @@ void NewBlob(int size)
{
blob_count = blob_count + 1;
struct blob* a = calloc(1, sizeof(struct blob));
require(NULL != a, "Exhusted available memory\n");
require(NULL != a, "Exhausted available memory\n");
a->Text = calloc(size + 1, sizeof(char));
require(NULL != a->Text, "Exhusted available memory\n");
require(NULL != a->Text, "Exhausted available memory\n");

int i = 0;
while(i <= size)
Expand All @@ -167,7 +167,7 @@ struct Token* newToken(char* filename, int linenumber)
struct Token* p;

p = calloc (1, sizeof (struct Token));
require(NULL != p, "Exhusted available memory\n");
require(NULL != p, "Exhausted available memory\n");

p->filename = filename;
p->linenumber = linenumber;
Expand Down Expand Up @@ -382,7 +382,7 @@ void hexify_string(struct blob* p)

require(1 != size, "hexify_string lacked a valid bytemode\n");
char* d = calloc(size, sizeof(char));
require(NULL != d, "Exhusted available memory\n");
require(NULL != d, "Exhausted available memory\n");
p->Expression = d;
char* S = p->Text;

Expand Down Expand Up @@ -466,7 +466,7 @@ char* pad_nulls(int size, char* nil)
else if (BINARY == ByteMode) size = size * 8;

char* s = calloc(size + 1, sizeof(char));
require(NULL != s, "Exhusted available memory\n");
require(NULL != s, "Exhausted available memory\n");

int i = 0;
while(i < size)
Expand Down Expand Up @@ -616,7 +616,7 @@ int stringify(char* s, int digits, int divisor, int value, int shift)
char* express_number(int value, char c)
{
char* ch = calloc(42, sizeof(char));
require(NULL != ch, "Exhusted available memory\n");
require(NULL != ch, "Exhausted available memory\n");
int size;
int number_of_bytes;
int shift;
Expand Down Expand Up @@ -684,7 +684,7 @@ char* express_word(int value, char c)
char* s = calloc(43, sizeof(char));
s[0] = '.';
char* ch = s + 1;
require(NULL != ch, "Exhusted available memory\n");
require(NULL != ch, "Exhausted available memory\n");
int size;
int shift;
int immediate;
Expand All @@ -700,7 +700,7 @@ char* express_word(int value, char c)
}
else if('~' == c)
{
/*Corresponds with RISC-V U format */
/* Corresponds with RISC-V U format */
if ((value & 0xfff) < 0x800)
{
immediate = value & 0xfffff000;
Expand Down
8 changes: 3 additions & 5 deletions hex2_word.c
Expand Up @@ -62,7 +62,7 @@ void UpdateShiftRegister(char ch, int value)
/* Will need architecture specific logic if more architectures go this route */
/* no range check because it needs to work with labels for lui/addi + AUIPC combos */
/* !label is used in the second instruction of AUIPC combo but we want an offset from */
/* the first instruction. */
/* the first instruction */
value = value + 4;
tempword = (value & 0xfff) << 20;
/* Update shift register */
Expand All @@ -86,7 +86,6 @@ void UpdateShiftRegister(char ch, int value)
{
/* Corresponds with RISC-V J format (formerly known as UJ) */
/* Will need architecture specific logic if more architectures go this route */
/* Possibly incorrect */
if ((value < -0x100000 || value > 0xfffff) || (value & 1)) outOfRange("J", value);

tempword = ((value & 0x7fe) << (30 - 10))
Expand All @@ -99,7 +98,6 @@ void UpdateShiftRegister(char ch, int value)
{
/* Corresponds with RISC-V U format */
/* Will need architecture specific logic if more architectures go this route */
/* Possibly incorrect */
if ((value & 0xfff) < 0x800) tempword = value & 0xfffff000;
else tempword = (value & 0xfffff000) + 0x1000;
shiftregister = shiftregister ^ tempword;
Expand Down Expand Up @@ -279,8 +277,8 @@ void WordFirstPass(struct input_files* input)
{
c = fgetc(source_file);
DoByte(c, source_file, FALSE, TRUE);
ip = ip - 1;
}
ip = ip - 4;
}
else if(in_set(c, "!@$~"))
{
Expand Down Expand Up @@ -347,9 +345,9 @@ void WordSecondPass(struct input_files* input)
{
c = fgetc(source_file);
DoByte(c, source_file, FALSE, TRUE);
ip = ip - 1;
}
UpdateShiftRegister('.', tempword);
ip = ip - 4;
}
else if(in_set(c, "%&")) WordStorePointer(c, source_file); /* Deal with % and & */
else if(in_set(c, "!@$~"))
Expand Down