Skip to content

Commit 2f213d8

Browse files
authored
Merge pull request nanochess#9 from humbertocsjr/master
ALIGN command implemented from NASM
2 parents e4afdfa + 0162e88 commit 2f213d8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

TINYASM.EXE

1.5 KB
Binary file not shown.

tinyasm.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ void do_assembly(fname)
12991299
int base;
13001300
int pline;
13011301
int include;
1302+
int align;
13021303

13031304
input = fopen(fname, "r");
13041305
if (input == NULL) {
@@ -1555,6 +1556,24 @@ void do_assembly(fname)
15551556
}
15561557
break;
15571558
}
1559+
if (strcmp(part, "ALIGN") == 0) {
1560+
p = avoid_spaces(p);
1561+
undefined = 0;
1562+
p2 = match_expression(p, &instruction_value);
1563+
if (p2 == NULL) {
1564+
message(1, "Bad expression");
1565+
} else if (undefined) {
1566+
message(1, "Cannot use undefined labels");
1567+
} else {
1568+
align = address / instruction_value;
1569+
align = align * instruction_value;
1570+
align = align + instruction_value;
1571+
while (address < align)
1572+
emit_byte(0x90);
1573+
check_end(p2);
1574+
}
1575+
break;
1576+
}
15581577
if (first_time == 1) {
15591578
#ifdef DEBUG
15601579
/*fprintf(stderr, "First time '%s' at line %d\n", line, line_number);*/

0 commit comments

Comments
 (0)