diff --git a/src/asm/gameboy/yaccprt4.y b/src/asm/gameboy/yaccprt4.y index b4b1cf70..fd880f4c 100644 --- a/src/asm/gameboy/yaccprt4.y +++ b/src/asm/gameboy/yaccprt4.y @@ -153,8 +153,13 @@ z80_ex : T_Z80_EX T_MODE_HL comma T_MODE_SP_IND { 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 diff --git a/src/asm/main.c b/src/asm/main.c index 175fff04..9bf96c20 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,8 @@ void setuplex(void); * */ +bool haltnop; + clock_t nStartClock, nEndClock; SLONG nLineNo; ULONG nTotalLines, nPass, nPC, nIFDepth, nErrors; @@ -238,7 +241,8 @@ PrintUsage(void) { 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 @@ main(int argc, char *argv[]) char *tzMainfile; + haltnop = true; + if (argc == 1) PrintUsage(); @@ -275,7 +281,7 @@ main(int argc, char *argv[]) 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) { @@ -299,6 +305,9 @@ main(int argc, char *argv[]) exit(1); } break; + case 'h': + haltnop = false; + break; case 'i': fstk_AddIncludePath(optarg); break; diff --git a/src/asm/rgbasm.1 b/src/asm/rgbasm.1 index 4bfc8ffa..61b86d9c 100644 --- 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 @@ The defaults are 01. .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 diff --git a/src/asm/yaccprt1.y b/src/asm/yaccprt1.y index e89265b3..ea99ff52 100644 --- a/src/asm/yaccprt1.y +++ b/src/asm/yaccprt1.y @@ -1,6 +1,7 @@ %{ #include #include +#include #include #include #include @@ -15,6 +16,8 @@ #include "asm/main.h" #include "asm/lexer.h" +extern bool haltnop; + char *tzNewMacro; ULONG ulNewMacroSize;