assembly - Compare two values from the stack? -


this question has answer here:

i stuck in assembler code want compare 2 values of stack.

x86, syntax at&t

cmpl -4(%ebp), 4(%ebp) 

error: many memory references `cmp'

i think not possible compare 2 values based on multiplier , ebp. suggestions ?

you can compare 2 values in memory using cmpsd instruction.

op wants equivalent to:

  cmpl -4(%ebp), 4(%ebp) 

he can placing addresses of memory locations of interest in esi , edi respectively, , using cmpsd memory-to-memory string-compare instruction:

  lea   -4(%ebp), %esi   lea    4(%ebp), %edi   cmpsd 

(forgive non-expert abuse of at&t syntax).

that's different in practice. other answers provided here (load value register , compare) more practical. if nothing else, solutions burn 1 register, , hack burns two.

lesson: in assembler, there's more 1 way skin cat.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -