Vittore Gravano
Vittore Gravano

Reputation: 766

Compare in Assembly language

I need to compare if the next character of string is the end of line ($) or not. This is my code:

data segment
string db 256 dup ('$')
data ends
...
n_loop equ 256
    mov cx, n_loop
    mov bx, offset string
start_loop:
    mov dl, [bx] 
    mov ah, 2
    int 21h
    mov dl, 32 
    mov ah, 2
    int 21h
    inc bx
    cmp word ptr [bx], '$' ; this is where I think I must to compare it
    loopne start_loop
    je fin
fin:
    ...

But unforlunetly I'm too new to Assembly language and my code doesn't work. And for true I even don't know if I'm right with idea to compare bx with $.

Upvotes: 0

Views: 269

Answers (1)

Brian Knoblauch
Brian Knoblauch

Reputation: 21369

You're comparing a 16-bit value (word ptr destination of BX) with an 8-bit immediate of "$". That's probably not doing exactly what you intend...

Upvotes: 3

Related Questions