小编sad*_*uee的帖子

比较程序集中的整数值

我们的任务是比较整数值并打印出适当的提示以显示哪些值更大.

我在下面的代码分别将'i'和'j'初始化为5和4.目标是比较"变量"而不是直接值本身.所以在这个例子中,我把'i'和'j'放在cmp中,而不是5和4.

global _main
extern _printf, _system 

section .text


_main:
; clear screen
    push clr
    call _system
    add esp, 4

;Test prints out i. Successfully does the job.
    push dword [i]          ; why did it work here and not in *cmp*?
    push prompt2
    call _printf      
    add esp, 8

;compare values and do a conditional jump.
    CMP dword [i], dword [j]            ; compares values stored in i and j. i and j are base 10 nums. This is where …
Run Code Online (Sandbox Code Playgroud)

assembly integer compare intel cmp

2
推荐指数
1
解决办法
2363
查看次数

标签 统计

assembly ×1

cmp ×1

compare ×1

integer ×1

intel ×1