Hi, On at 2025-06-02 22:11:27 +0200, Wolf Bergenheim via Freedos-user <freedos-user@lists.sourceforge.net> wrote: >Hi, > >I'm not an assembly coder, but I know enough to be dangerous. 🙈😜 > >Anyway first please check the CMP instruction parameters and you'll find >that it takes 2 arguments a register or memory address and an immediate or >2 register/memory addresses. > >When you write > >addr equ 369h > >You are not creating a label (memory address) but instead it's a mnemonic >for a numeric value. So basically the assembler will simply substitute all >instances of addr with the number 369h. > >This means that your cmp statement which was > >cmp byte ptr [addr], 18h > >Is converted to > >cmp byte ptr [369h], 18h > >And this is not a valid instruction.
Incorrect. A memory access can be done using a hardcoded offset without any registers. This addressing mode encodes the offset as a plain number. If you use a memory variable, the assembler or linker will resolve the offset to a plain number in the machine code. Likewise, disassembly won't differ between accessing a memory variable or a plain number offset if they happen to encode the same offset. The last example you gave here is valid for the line assembler of MS-DOS Debug, FreeDOS Debug, or lDebug if you drop the "h" suffixes. Likewise it is valid to NASM if you drop the "ptr" keyword (or add a %idefine ptr that expands to nothing). I'm confident that TASM allows to hardcode numeric values for the offset to use in a memory operand. I do not know exactly how to get it to do so, which is the reason I didn't respond before. >Instead you want to use addr as offset or load it in a register to use it. > >I think this should work. > >xor bx, bx >cmp byte ptr [bx+addr], 18h This may work but it uses more code space, time, and adds the use of an additional register. It is not the correct solution to the presented question. >You really should read up on how equ and labels work. I agree that this is needed, albeit if anyone already knows they could quote or paraphrase the relevant workings. I only occasionally use TASM, usually to port existing code bases to NASM. You may want to try: addr equ byte ptr 369h > You might also want >to define a data segment so you don't need to use the org statements to >intermingle data and code (unless tou have to). > >Also get your hands on the borland turbo assembler manuals, or switch to >masm and read its programming manual or watch videos to learn more about >how labels and pointers work in assembly. > >Hope this helps, >--Wolf Regards, ecm _______________________________________________ Freedos-user mailing list Freedos-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-user