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.

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

You really should read up on how equ and labels work. 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


On Sat, May 31, 2025, 20:55 hms--- via Freedos-user <
freedos-user@lists.sourceforge.net> wrote:

> Hi there
> Not a specific FreeDos question, but related. I recently disassembled a DOS
> .COM utility using "IDA Free", to see if I could make some minor mods.
> I am brand new to 8086 assembly language and looking for an answer.
> In the example test code below, I want to replace the instruction "cmp
> byte_369, 18h"
> with "cmp byte ptr [addr], 18h" or similar. I get an error message of
> "Illegal immediate".
> Do I need to use an intermediate instruction to achieve this?
> The assembler is Borland's TASM.
> Any help appreciated.
> Thanks,  John
>
> ; ------------------------------------------
>
> SOURCE:
>
>   .386
>   .model tiny
>
> addr equ 369h
>
> seg000 segment byte public 'CODE' use16
>   assume cs:seg000
>   org 100h
>   assume es:nothing, ss:nothing, ds:seg000, fs:nothing, gs:nothing
>   public start
>
> start proc near
>   jmp here
>
>   org 369h
> byte_369 db 18h
>
>   org 1234h
> here:
>   cmp byte ptr [addr], 18h
>   cmp byte_369, 18h
>
> start  endp
> seg000 ends
>         end start
> ; ------------------------------------------
>
> EDITED ASSEMBLER OUTPUT: (for brevity)
>
>   8                             org 100h
> 13 0100  E9 1131               jmp here
> 14
> 15                             org 369h
> 17 0369  18                  byte_369 db 18h
> 18
> 19                             org 1234h
> 21 1234                      here:
>
> 22 1234  80 3E 0369 18         cmp byte ptr [addr],18h
> **Error** test.ASM(22) Illegal immediate
>
> 23 1239  80 3E 0369r 18        cmp byte_369,18h
>
> ; end doc
>
>
>
> _______________________________________________
> Freedos-user mailing list
> Freedos-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-user
>
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to