【问题标题】:How to compare characters in x86 assembly如何比较 x86 程序集中的字符
【发布时间】:2014-04-10 22:45:37
【问题描述】:

我将这两个词存储在变量中,分别称为 first 和 second。如何比较每个字符串的字符以查看哪个更大?

section .data

greet: db "Type a word: "
greetL: equ $-greet

section .bss

first: resb 20
second: resb 20

section .text

global _start

_start:
    nop
    mov eax, 4
    mov ebx, 1
    mov ecx, greet
    mov edx, greetL
    int 80H

    mov eax, 3
    mov ebx, 0
    mov ecx, first
    mov edx, 20
    int 80H

然后我只是做同样的事情来得到第二个单词

【问题讨论】:

    标签: string assembly x86 compare nasm


    【解决方案1】:

    我不知道,cmp 我想...

        xor ecx, ecx ; index
    top
        mov al, [first + ecx]
        cmp [second + ecx], al
        jb first_is_bigger
        ja second_is_bigger
        cmp al, LF ; LF equ 10
        je they_are_equal
        inc ecx
        jmp top
    

    那是未经测试的。我最近有很多脑胀气——最好检查一下。如果讨厌的用户输入超过20个字符,你可能陷入了泥潭……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      相关资源
      最近更新 更多