I've never used JWASM but some things that come to mind:
- doesn't the 'Reg8' parameter need some kind of affix? Like "@Reg8"? I seem to remember this from old TASM days.
- are you defining the macro in keeping with JWASM's manual? See the example in section 3.17 of the link you posted.
- the error refers to the UPC macro. What happens if you comment out the part where it is called? The 'UPC BH' line.
- what happens if you just inline the macro?
Looking at my old TASM code, it's just could be possible that you need to wrap Reg8 parameter name in some brackets in the IF statement, but only within that statement. You did wrap BL already in round brackets, same could be required for Reg8 too.
TASM required angle brackets, the macro did look like this:
I've never used JWASM but some things that come to mind:
- doesn't the 'Reg8' parameter need some kind of affix? Like "@Reg8"? I seem to remember this from old TASM days.
- are you defining the macro in keeping with JWASM's manual? See the example in section 3.17 of the link you posted.
I don't know if there is an affix necessary. I got the syntax mainly from an assembler book written for MASM and I'm trying to adapt my code to JWASM.
Using
1IF (Reg8 EQ @BL)
doesn't work and gives the error message:
Error A2102: Symbol not defined: @BL
- the error refers to the UPC macro. What happens if you comment out the part where it is called? The 'UPC BH' line.
The error is in the IF..ELSE section inside the UPC macro. If i comment out all the IF...ELSE stuff, then it assembles without errors.
vstrakhwrote on 2022-10-24, 17:59:Looking at my old TASM code, it's just could be possible that you need to wrap Reg8 parameter name in some brackets in the IF st […] Show full quote
Looking at my old TASM code, it's just could be possible that you need to wrap Reg8 parameter name in some brackets in the IF statement, but only within that statement. You did wrap BL already in round brackets, same could be required for Reg8 too.
TASM required angle brackets, the macro did look like this:
I agree. I've just tried the brute force method because I'm running out of options. 😉
The manual mentions upercase IF and ELSE and other key words in the Appendix A. JWasm Reserved Words chapter at least.
But how to use them with JWASM and register names? That's the big question. Is it not supported? Is it a bug? https://www.japheth.de/JWasm/Manual.html#AA
I'm not sure what are you doing, because it works exactly the same as in TASM, which in turn follows the MASM rules.
Here's with case-insensitive IF comparison:
Your issue with EQ might be related to data types expected by this operator.
TASM manual say the EQ treats its arguments as unsigned numbers. I'd guess the same applies to MASM, so EQ should not be used for texts comparison.
I'm not sure what are you doing, because it works exactly the same as in TASM, which in turn follows the MASM rules.
Well
1 ifidni <Reg8>,<BL>
and
1 if (Reg8 EQ BL)
do have a different key word and syntax and are not the same.
The latter is an example from the assembler book i am reading which is written for MASM. Thus, this works in MASM.
JWASM trys to be compatible to MASM, but it seems that here the compatibility ends.
Your
1 ifidni <Reg8>,<BL>
is a completely other solution. And yes it works. But how should i know that, when my MASM books says i should use
1 IF (PART1 Operator PART2)
?
With one of the following operators:
EQ = equal
NE = not equal
LT = less than
LE = less or equal
GT = greater
GE = greather or equal
And where PART1 and PART2 can be registers.
Here's with case-insensitive IF comparison:
Thanks.
Note the BL branch is taken for bl register, and the other branch is taken for all the other registers, just what you tried to achieve.
Exactly.
But it doesn't work with this MASM syntax in JWASM, at least not when using a register. It seems to work with other things like constants.
Last edited by Exploit on 2022-10-24, 20:41. Edited 2 times in total.
Your issue with EQ might be related to data types expected by this operator.
TASM manual say the EQ treats its arguments as unsigned numbers. I'd guess the same applies to MASM, so EQ should not be used for texts comparison.
No, MASM eats this. The book and its examples are written for MASM.
But it seems to be this could be true:
TASM manual say the EQ treats its arguments as unsigned numbers. I'd guess the same applies to MASM JWASM, so EQ should not be used for texts comparison.
1In an MASM expression, the numeric value of any symbol is its memory address. In a C++ expression, the numeric value of a variable is its actual value, not its address. Data structures do not have numeric values. Instead, they are treated as actual structures and you must use them accordingly. The value of a function name or any other entry point is the memory address and is treated as a function pointer. If you use a symbol that does not correspond to a C++ data type (such as an unmodified module name), a syntax error occurs. 2 3The MASM expression evaluator treats all numbers as ULONG64 values. The C++ expression evaluator casts numbers to ULONG64 and preserves type information of all data types.
This hints that result of expression is always a number. If something is not a number, then it's a symbol, and the value of such expression is the address of the symbol. That's why JWASM could not immediately tell "this is not a number", it hoped to find the address of the symbol, that's why the warning message say it wanted "a constant or relocatable item".
The JWASM can't recommend one operator over another, it's assumed you know the rules and use appropriate operators or directives.
Exploitwrote on 2022-10-24, 20:38:Can you tell me, which if##### key word corresponds to which if operator of the following list? […] Show full quote
Can you tell me, which if##### key word corresponds to which if operator of the following list?
1EQ = equal 2NE = not equal 3LT = less than 4LE = less or equal 5GT = greater 6GE = greather or equal
Now i know, that ifidni <parm1>, <parm2> can be used instead of IF ( parm1 EQ parm2..).
But the others?
Did you notice the 'i' at the end of 'ifidni'? This means case-insensitive. The case sensitivity does not apply to numbers. EQ/NE/LT/LE/GT/GE - it's all relational operators, they compare numbers obtained after evaluating the expressions. Now 'ifidni', 'ifdif' - are the directives, doing something else than IF. It does not take the expression, it operates on some other conditions. These do not mix, and not an alternatives of each other.
This hints that result of expression is always a number. If something is not a number, then it's a symbol, and the value of such expression is the address of the symbol. That's why JWASM could not immediately tell "this is not a number", it hoped to find the address of the symbol, that's why the warning message say it wanted "a constant or relocatable item".
MASM uses the @ sign to tell MASM that a register is a register and not a hexadecimal number.
So
1IF (param1 EQ BL)
should be better written as:
1IF (param1 EQ @BL)
But JWASM doesn't accept that either.
The value of a register should be treated as a number in this case. MASM does this at least.
The JWASM can't recommend one operator over another, it's assumed you know the rules and use appropriate operators or directives.
Yes, it seems so. MASM provides at least the @ sign to make clear if AH is a name of a register or a hexadecimal number.
Did you notice the 'i' at the end of 'ifidni'? This means case-insensitive. The case sensitivity does not apply to numbers. EQ/NE/LT/LE/GT/GE - it's all relational operators, they compare numbers obtained after evaluating the expressions.
I wasn't referring about the is case sensitive and is not case insensitive issue.
I asked what directive is the replacement for the following operators.
Now 'ifidni', 'ifdif' - are the directives, doing something else than IF. It does not take the expression, it operates on some other conditions. These do not mix, and not an alternatives of each other.
Well, what i learned today is. That i can't use IF in JWASM when using registers. I must use ifidni (EQ) and other directives (for the other operators NE/LT/LE/GT/GE) .