Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

NEG problem

operator1operator1 Member Posts: 3
Hi ,I'm new to assembly and just reading great book about it but i have a problem with red line below.

NEG BYTE [BX] ; Negates byte quantity at DS:BX
[color=Red]NEG WORD [DI] ; Negates word quantity at DS:BX[/color]

this is what it says in the book but i dont understand how he got BX from DI.Is it mistake in the book or i skipped something,somewhere...(more probably)
I tried to load this into debug to c what happens but only thing are flags changing. :(
pls can somebody point me to what to look for .






Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [color=Blue]It is an obvious typo. Please do not be so literal about the book. Basic guidance on the instruction with memory location (or address) is this template:

    OPCODE SIZE [ADDRESS EXPRESSION], OPERAND2
    OPCODE OPERAND1, SIZE [ADDRESS EXPRESSION]

    where:
    OPCODE is just mnemonic of any CPU instruction
    SIZE is BYTE,WORD,DWORD or else (for x64 programming)
    OPERAND1,2 may be skipped, depending on mnemonic

    ADDRESS_EXPRESSION is the mixture of address registers and offsets and even more - it depends on a programming model:

    Examples of ADDRESS_EXPRESSION:
    [BX+SI+8] = valid address in DOS programming
    [EAX+EBX*4] = invalid for DOS, but valid for Windows

    In case if data type is obvious from the command itself - the SIZE part can be skipped. Example:

    MOV [SI+0122h], DX

    Because DX is used, it is obvious that SIZE=WORD, so it is not needed to specify it, however, next statement will give error message:

    MOV [SI+0122h], 7

    Because 7 can be a BYTE and a WORD and a DWORD, so assembler is missing type information to complete the instruction and that is why SIZE is needed in this case:

    MOV BYTE [SI+0122h], 7
    MOV WORD [SI+0122h], 7
    MOV DWORD [SI+0122h], 7

    Choose one from these ^^^.
    [/color]
  • operator1operator1 Member Posts: 3
    i was hoping its typo.Otherwise i would need to go back some 100 pages and see where i missed it.
    Many thanks :)
    cheers
Sign In or Register to comment.