ref: 6ccd386587c671250cf71c5099c0f9b6b0bd507a
parent: 34d40a67c91cf4f9763a6fc2768dd5d6e68115ce
author: Anthony J. Bentley <[email protected]>
date: Sun May 19 13:56:41 EDT 2013
Make it possible to disable emitting nop after halt.
--- a/src/asm/gameboy/yaccprt4.y
+++ b/src/asm/gameboy/yaccprt4.y
@@ -153,8 +153,13 @@
{ out_AbsByte(0xE3); }
;
-z80_halt : T_Z80_HALT
- { out_AbsByte(0x76); out_AbsByte(0x00); }
+z80_halt: T_Z80_HALT
+ {
+ out_AbsByte(0x76);
+ if (haltnop) {
+ out_AbsByte(0x00);
+ }
+ }
;
z80_inc : T_Z80_INC reg_r
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -8,6 +8,7 @@
#include <math.h>
#include <getopt.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,6 +30,8 @@
*
*/
+bool haltnop;
+
clock_t nStartClock, nEndClock;
SLONG nLineNo;
ULONG nTotalLines, nPass, nPC, nIFDepth, nErrors;
@@ -238,7 +241,8 @@
{
printf("RGBAsm v" ASM_VERSION " (part of ASMotor " ASMOTOR_VERSION
")\n\n");
- printf("Usage: rgbasm [-b chars] [-g chars] [-i path] [-o outfile] [-p pad_value] file\n");
+ printf("Usage: rgbasm [-h] [-b chars] [-g chars] [-i path] [-o outfile] [-p pad_value]\n"
+ " file\n");
exit(1);
}
/*
@@ -258,6 +262,8 @@
char *tzMainfile;
+ haltnop = true;
+
if (argc == 1)
PrintUsage();
@@ -275,7 +281,7 @@
newopt = CurrentOptions;
- while ((ch = getopt(argc, argv, "b:g:i:o:p:")) != -1) {
+ while ((ch = getopt(argc, argv, "b:g:hi:o:p:")) != -1) {
switch (ch) {
case 'b':
if (strlen(optarg) == 2) {
@@ -298,6 +304,9 @@
"4 characters for option 'g'\n");
exit(1);
}
+ break;
+ case 'h':
+ haltnop = false;
break;
case 'i':
fstk_AddIncludePath(optarg);
--- a/src/asm/rgbasm.1
+++ b/src/asm/rgbasm.1
@@ -6,6 +6,7 @@
.Nd Game Boy assembler
.Sh SYNOPSIS
.Nm rgbasm
+.Op Fl h
.Op Fl b Ar chars
.Op Fl g Ar chars
.Op Fl i Ar path
@@ -24,6 +25,17 @@
.It Fl g Ar chars
Change the four characters used for binary constants.
The defaults are 0123.
+.It Fl h
+By default,
+.Nm
+inserts a
+.Sq nop
+instruction immediately after any
+.Sq halt
+instruction.
+The
+.Fl h
+option disables this behavior.
.It Fl i Ar path
Add an include path.
.It Fl o Ar outfile
--- a/src/asm/yaccprt1.y
+++ b/src/asm/yaccprt1.y
@@ -1,6 +1,7 @@
%{
#include <ctype.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -14,6 +15,8 @@
#include "asm/rpn.h"
#include "asm/main.h"
#include "asm/lexer.h"
+
+extern bool haltnop;
char *tzNewMacro;
ULONG ulNewMacroSize;