Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ xlink_obj := \
rgbfix_obj := \
src/rgbfix/main.o

asmy_artifacts := \
src/asm/asmy.h \
src/asm/asmy.y

all: rgbasm xlib xlink rgbfix

clean:
rm -rf rgbasm $(rgbasm_obj)
rm -rf xlib $(xlib_obj)
rm -rf xlink $(xlink_obj)
rm -rf rgbfix $(rgbfix_obj)
rm $(asmy_artifacts)

rgbasm: $(rgbasm_obj)
gcc $(cflags) -o $@ $^ -lm
Expand Down
68 changes: 34 additions & 34 deletions src/asm/gameboy/yaccprt4.y
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ z80_ld : z80_ld_mem
z80_ld_hl : T_Z80_LD T_MODE_HL comma '[' T_MODE_SP const_8bit ']'
{ out_AbsByte(0xF8); out_RelByte(&$6); }
| T_Z80_LD T_MODE_HL comma const_16bit
{ out_AbsByte(0x01|(REG_HL<<4)); out_RelWord(&$4) }
{ out_AbsByte(0x01|(REG_HL<<4)); out_RelWord(&$4); }
;
z80_ld_sp : T_Z80_LD T_MODE_SP comma T_MODE_HL
{ out_AbsByte(0xF9); }
| T_Z80_LD T_MODE_SP comma const_16bit
{ out_AbsByte(0x01|(REG_SP<<4)); out_RelWord(&$4) }
{ out_AbsByte(0x01|(REG_SP<<4)); out_RelWord(&$4); }
;

z80_ld_mem : T_Z80_LD op_mem_ind comma T_MODE_SP
Expand Down Expand Up @@ -321,7 +321,7 @@ z80_ld_a : T_Z80_LD reg_r comma T_MODE_C_IND
;

z80_ld_ss : T_Z80_LD reg_ss comma const_16bit
{ out_AbsByte(0x01|($2<<4)); out_RelWord(&$4) }
{ out_AbsByte(0x01|($2<<4)); out_RelWord(&$4); }
;

z80_nop : T_Z80_NOP
Expand Down Expand Up @@ -443,56 +443,56 @@ z80_xor : T_Z80_XOR op_a_n { out_AbsByte(0xEE); out_RelByte(&$2); }
| T_Z80_XOR op_a_r { out_AbsByte(0xA8|$2); }
;

op_mem_ind : '[' const_16bit ']' { $$ = $2 }
op_mem_ind : '[' const_16bit ']' { $$ = $2; }
;

op_hl_ss : reg_ss { $$ = $1 }
| T_MODE_HL comma reg_ss { $$ = $3 }
op_hl_ss : reg_ss { $$ = $1; }
| T_MODE_HL comma reg_ss { $$ = $3; }
;

op_a_r : reg_r { $$ = $1 }
| T_MODE_A comma reg_r { $$ = $3 }
op_a_r : reg_r { $$ = $1; }
| T_MODE_A comma reg_r { $$ = $3; }
;

op_a_n : const_8bit { $$ = $1 }
| T_MODE_A comma const_8bit { $$ = $3 }
op_a_n : const_8bit { $$ = $1; }
| T_MODE_A comma const_8bit { $$ = $3; }
;

comma : ','
;

ccode : T_CC_NZ { $$ = CC_NZ }
| T_CC_Z { $$ = CC_Z }
| T_CC_NC { $$ = CC_NC }
| T_MODE_C { $$ = CC_C }
ccode : T_CC_NZ { $$ = CC_NZ; }
| T_CC_Z { $$ = CC_Z; }
| T_CC_NC { $$ = CC_NC; }
| T_MODE_C { $$ = CC_C; }
;

reg_r : T_MODE_B { $$ = REG_B }
| T_MODE_C { $$ = REG_C }
| T_MODE_D { $$ = REG_D }
| T_MODE_E { $$ = REG_E }
| T_MODE_H { $$ = REG_H }
| T_MODE_L { $$ = REG_L }
| T_MODE_HL_IND { $$ = REG_HL_IND }
| T_MODE_A { $$ = REG_A }
reg_r : T_MODE_B { $$ = REG_B; }
| T_MODE_C { $$ = REG_C; }
| T_MODE_D { $$ = REG_D; }
| T_MODE_E { $$ = REG_E; }
| T_MODE_H { $$ = REG_H; }
| T_MODE_L { $$ = REG_L; }
| T_MODE_HL_IND { $$ = REG_HL_IND; }
| T_MODE_A { $$ = REG_A; }
;

reg_tt : T_MODE_BC { $$ = REG_BC }
| T_MODE_DE { $$ = REG_DE }
| T_MODE_HL { $$ = REG_HL }
| T_MODE_AF { $$ = REG_AF }
reg_tt : T_MODE_BC { $$ = REG_BC; }
| T_MODE_DE { $$ = REG_DE; }
| T_MODE_HL { $$ = REG_HL; }
| T_MODE_AF { $$ = REG_AF; }
;

reg_ss : T_MODE_BC { $$ = REG_BC }
| T_MODE_DE { $$ = REG_DE }
| T_MODE_HL { $$ = REG_HL }
| T_MODE_SP { $$ = REG_SP }
reg_ss : T_MODE_BC { $$ = REG_BC; }
| T_MODE_DE { $$ = REG_DE; }
| T_MODE_HL { $$ = REG_HL; }
| T_MODE_SP { $$ = REG_SP; }
;

reg_rr : T_MODE_BC_IND { $$ = REG_BC_IND }
| T_MODE_DE_IND { $$ = REG_DE_IND }
| T_MODE_HL_INDINC { $$ = REG_HL_INDINC }
| T_MODE_HL_INDDEC { $$ = REG_HL_INDDEC }
reg_rr : T_MODE_BC_IND { $$ = REG_BC_IND; }
| T_MODE_DE_IND { $$ = REG_DE_IND; }
| T_MODE_HL_INDINC { $$ = REG_HL_INDINC; }
| T_MODE_HL_INDDEC { $$ = REG_HL_INDDEC; }
;

%%
4 changes: 0 additions & 4 deletions src/asm/globlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,18 @@ SLONG ascii2bin(char *s)

ULONG ParseFixedPoint(char *s, ULONG size)
{
char dest[256];
ULONG i = 0, dot = 0;

while (size && dot != 2) {
if (s[i] == '.')
dot += 1;

if (dot < 2) {
dest[i] = s[i];
size -= 1;
i += 1;
}
}

dest[i] = 0;

yyunputbytes(size);

yylval.nConstValue = (SLONG) (atof(s) * 65536);
Expand Down
2 changes: 1 addition & 1 deletion src/asm/yaccprt3.y
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const_16bit : relocconst
{
yyerror( "Expression must be 16-bit" );
}
$$=$1
$$=$1;
}
;

Expand Down