0

What's wrong with this? I don't see an error here. It tells me unknown register, but since I know little to nothing about assembly, I don't really know the problem.

;  Clicking button saves & builds using commands:
;    nasm -f elf -g -F stabs evil.asm
;    ld -o evil evil.o
section .data
Snippet: db "@E9>06G@Q:CN3C57I<)<)*"
SnipLen: equ $-Snippet
section .text
global _start
_start:
        nop
        mov ecx,Snippet
        mov edx,SnipLen
        mov eax,6
DoMore: add byte [ecx],af
        inc ecx
        inc eax
        dec edx
        jnz DoMore
        mov eax,4
        mov ebx,1
        sub ecx,SnipLen
        mov edx,SnipLen
        int 80H
        mov eax,1
        mov ebx,0
        int 80H
        nop
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Bahdoo
  • 31
  • 8
  • 4
    There is no register named `af`. – fuz May 24 '21 at 13:40
  • What should I replace it with? – Bahdoo May 24 '21 at 13:41
  • It's ah since it's byte sized. If you know little to no assembly, you should start learning assembly if you're going to code assembly... – m0skit0 May 24 '21 at 13:42
  • 4
    @redguard001 It depends on what you want this code to do. I suppose you wrote it; what did you think when you wrote this line? What did you want it to do? – fuz May 24 '21 at 13:44

1 Answers1

2
DoMore: add byte [ecx],af

The instruction allows for one argument to be register or memory, and the other is register only (in either order). Since [ecx] uses indirection syntax, it is clearly the "memory" usage, and the other parameter must be the name of a register.

I don't see any data label value af in your listing, if that's what you intended. But that won't work anyway, as the other argument must be a simple register name only.


update

You seem confused as to what you should write, in the comments.
Since you loaded eax with 6, I suspect you wanted to add 6 to where [ecx] is pointing, adding the next number to each byte in turn. In this case, you meant al, the low byte making up eax.

JDługosz
  • 5,592
  • 3
  • 24
  • 45
  • Looking at the `byte` size tag, my first guess was for a (wrongly written) immediate operand. BTW you don't mention that possibility in your 1st paragraph. You even seem to exclude it totally? The update nails it, I think. +1 – Sep Roland May 24 '21 at 21:07
  • @SepRoland it didn't occur to me that it might be a hex literal. But he is loading and updating `eax` that's not used for anything else, so that seemed to be what the code needed. – JDługosz May 25 '21 at 13:50