diff --git a/src/assemble.c b/src/assemble.c index 3f317df..7992c48 100644 --- a/src/assemble.c +++ b/src/assemble.c @@ -638,6 +638,8 @@ void handle_asm_data(uint8_t wordtype) { void handle_asm_equ(void) { streamtoken_t token; + if(inConditionalSection == 1) return; + if(currentline.next) { if(getDefineValueToken(&token, currentline.next)) { if((token.terminator != 0) && (token.terminator != ';')) error(message[ERROR_TOOMANYARGUMENTS],0); @@ -652,6 +654,8 @@ void handle_asm_equ(void) { void handle_asm_adl(void) { streamtoken_t token; + if(inConditionalSection == 1) return; + if(currentline.next) { if(getDefineValueToken(&token, currentline.next) == 0) { error(message[ERROR_MISSINGOPERAND],0); @@ -690,6 +694,8 @@ void handle_asm_adl(void) { void handle_asm_org(void) { uint24_t newaddress; + if(inConditionalSection == 1) return; + parse_asm_single_immediate(); // get address from next token // address needs to be given in pass 1 newaddress = operand1.immediate; @@ -871,6 +877,8 @@ uint24_t alignment; uint24_t base; uint24_t delta; + if(inConditionalSection == 1) return; + parse_asm_single_immediate(); if(operand1.immediate <= 0) { error(message[ERROR_ZEROORNEGATIVE],"%s",operand1.immediate_name); @@ -904,6 +912,8 @@ void handle_asm_definemacro(void) { macro_t *macro; uint16_t startlinenumber,linelength,macrolength; + if(inConditionalSection == 1) return; + definelabel(address); _macrobuffer[0] = 0; // empty string @@ -1038,6 +1048,8 @@ void handle_asm_endif(void) { void handle_asm_fillbyte(void) { + if(inConditionalSection == 1) return; + parse_asm_single_immediate(); // get fillbyte from next token if((!ignore_truncation_warnings) && ((operand1.immediate < -128) || (operand1.immediate > 255))) { warning(message[WARNING_TRUNCATED_8BIT],"%s",operand1.immediate_name); @@ -1112,7 +1124,9 @@ void handle_assembler_command(void) { handle_asm_endif(); break; case(ASM_MACRO_END): - error(message[ERROR_MACRONOTSTARTED],0); + if(inConditionalSection == 0) { + error(message[ERROR_MACRONOTSTARTED],0); + } break; } return; diff --git a/tests/Conditional_asm/tests/adl.expect b/tests/Conditional_asm/tests/adl.expect new file mode 100644 index 0000000..0684d1c Binary files /dev/null and b/tests/Conditional_asm/tests/adl.expect differ diff --git a/tests/Conditional_asm/tests/adl.s b/tests/Conditional_asm/tests/adl.s new file mode 100644 index 0000000..99c5a8f --- /dev/null +++ b/tests/Conditional_asm/tests/adl.s @@ -0,0 +1,12 @@ +; Test conditional ADL +; + + assume ADL=1; disable startup assumptions and set up for failure if not implemented + + .if 1 + assume ADL=0 + .else ; will run if not implemented, resulting in ADL mode 1, resulting in an error later on + assume ADL=1 + .endif + + ld hl, 0 ; this should produce 0x21 0x00 0x00, if properly implemented diff --git a/tests/Conditional_asm/tests/align.expect b/tests/Conditional_asm/tests/align.expect new file mode 100644 index 0000000..aeb0a03 Binary files /dev/null and b/tests/Conditional_asm/tests/align.expect differ diff --git a/tests/Conditional_asm/tests/align.s b/tests/Conditional_asm/tests/align.s new file mode 100644 index 0000000..e27fd50 --- /dev/null +++ b/tests/Conditional_asm/tests/align.s @@ -0,0 +1,10 @@ +; Test alignment +; Don't specifically test else statement; if alignment doesn't respect if/else, then the output will be different + .db 0 + .if 1 + .align 16 + .else + .align 32 + .endif + + .db 0 diff --git a/tests/Conditional_asm/tests/equ.s b/tests/Conditional_asm/tests/equ.s new file mode 100644 index 0000000..a50988a --- /dev/null +++ b/tests/Conditional_asm/tests/equ.s @@ -0,0 +1,9 @@ +; Test conditional EQU + + .if 1 +test: EQU 1 + .else +test: EQU 2 ; will produce an error when not implemented + .endif + + .db test diff --git a/tests/Conditional_asm/tests/fillbyte.expect b/tests/Conditional_asm/tests/fillbyte.expect new file mode 100644 index 0000000..22896f3 Binary files /dev/null and b/tests/Conditional_asm/tests/fillbyte.expect differ diff --git a/tests/Conditional_asm/tests/fillbyte.s b/tests/Conditional_asm/tests/fillbyte.s new file mode 100644 index 0000000..e289663 --- /dev/null +++ b/tests/Conditional_asm/tests/fillbyte.s @@ -0,0 +1,11 @@ +; Test conditional fillbyte + + .if 1 + fillbyte 0x00 + .else + fillbyte 0x01 + .endif + + .db 0xff + .blkb 16; use fillbyte, should be 16x 0x00 if properly implemented + .db 0xff diff --git a/tests/Conditional_asm/tests/macro.expect b/tests/Conditional_asm/tests/macro.expect new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/tests/Conditional_asm/tests/macro.expect differ diff --git a/tests/Conditional_asm/tests/macro.s b/tests/Conditional_asm/tests/macro.s new file mode 100644 index 0000000..5fa38d2 --- /dev/null +++ b/tests/Conditional_asm/tests/macro.s @@ -0,0 +1,18 @@ +; Test conditional macros +; + + .if 1 + + macro test + .db 0 + endmacro + + .else + + macro test + .db 1 + endmacro + + .endif + + test diff --git a/tests/Conditional_asm/tests/org.expect b/tests/Conditional_asm/tests/org.expect new file mode 100644 index 0000000..414cd09 --- /dev/null +++ b/tests/Conditional_asm/tests/org.expect @@ -0,0 +1 @@ +ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ \ No newline at end of file diff --git a/tests/Conditional_asm/tests/org.s b/tests/Conditional_asm/tests/org.s new file mode 100644 index 0000000..6bc6f54 --- /dev/null +++ b/tests/Conditional_asm/tests/org.s @@ -0,0 +1,12 @@ +; Test conditional org + + .org 0x40000 + .db 0xff + + .if 1 + .org 0x40010 + .else + .org 0x40020 + .endif + + .db 0xff