How to extract 32bit numbers in assemblyHow does the stack work in assembly language?How to view the assembly behind the code using Visual C++?How do I achieve the theoretical maximum of 4 FLOPs per cycle?cmp assembly language instruction - gas formatWhy does GCC generate 15-20% faster code if I optimize for size instead of speed?How assembly accesses/stores variables on the stackReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsAssembling 32bit Assembly on 64bit MachineC++ code for testing the Collatz conjecture faster than hand-written assembly - why?Local variables in assembly — assembler not emitting `sub esp, X` instruction
Applicability of Single Responsibility Principle
Go Pregnant or Go Home
What is the opposite of 'gravitas'?
apt-get update is failing in debian
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Understanding "audieritis" in Psalm 94
Failed to fetch jessie backports repository
Your magic is very sketchy
voltage of sounds of mp3files
Products and sum of cubes in Fibonacci
Why is `const int& k = i; ++i; ` possible?
Confused about a passage in Harry Potter y la piedra filosofal
Time travel short story where a man arrives in the late 19th century in a time machine and then sends the machine back into the past
when is out of tune ok?
Will it be accepted, if there is no ''Main Character" stereotype?
Dot above capital letter not centred
Greatest common substring
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Student evaluations of teaching assistants
Can a monster with multiattack use this ability if they are missing a limb?
Tiptoe or tiphoof? Adjusting words to better fit fantasy races
Lay out the Carpet
The plural of 'stomach"
If you attempt to grapple an opponent that you are hidden from, do they roll at disadvantage?
How to extract 32bit numbers in assembly
How does the stack work in assembly language?How to view the assembly behind the code using Visual C++?How do I achieve the theoretical maximum of 4 FLOPs per cycle?cmp assembly language instruction - gas formatWhy does GCC generate 15-20% faster code if I optimize for size instead of speed?How assembly accesses/stores variables on the stackReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsAssembling 32bit Assembly on 64bit MachineC++ code for testing the Collatz conjecture faster than hand-written assembly - why?Local variables in assembly — assembler not emitting `sub esp, X` instruction
I have a 32bit number stored on the top of the stack. And I would like to compare it with another number, something like:
cmp [rsp], 234
But I want both rsp and 234 to be treated as 32bit numbers, how can I do that (I am new to assembly)?
assembly x86-64
add a comment |
I have a 32bit number stored on the top of the stack. And I would like to compare it with another number, something like:
cmp [rsp], 234
But I want both rsp and 234 to be treated as 32bit numbers, how can I do that (I am new to assembly)?
assembly x86-64
6
Depends on your assembler butcmp dword [rsp], 234
orcmp dword ptr [rsp], 234
will usually do it.
– Jester
Mar 7 at 11:51
You don't actually wantrsp
to be treated as a 32-bit pointer. If you did want that, you'd write[esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory[rsp]
to be 32-bit, then do what Jester said.
– Peter Cordes
Mar 7 at 23:26
add a comment |
I have a 32bit number stored on the top of the stack. And I would like to compare it with another number, something like:
cmp [rsp], 234
But I want both rsp and 234 to be treated as 32bit numbers, how can I do that (I am new to assembly)?
assembly x86-64
I have a 32bit number stored on the top of the stack. And I would like to compare it with another number, something like:
cmp [rsp], 234
But I want both rsp and 234 to be treated as 32bit numbers, how can I do that (I am new to assembly)?
assembly x86-64
assembly x86-64
asked Mar 7 at 11:51
mikolmikol
245
245
6
Depends on your assembler butcmp dword [rsp], 234
orcmp dword ptr [rsp], 234
will usually do it.
– Jester
Mar 7 at 11:51
You don't actually wantrsp
to be treated as a 32-bit pointer. If you did want that, you'd write[esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory[rsp]
to be 32-bit, then do what Jester said.
– Peter Cordes
Mar 7 at 23:26
add a comment |
6
Depends on your assembler butcmp dword [rsp], 234
orcmp dword ptr [rsp], 234
will usually do it.
– Jester
Mar 7 at 11:51
You don't actually wantrsp
to be treated as a 32-bit pointer. If you did want that, you'd write[esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory[rsp]
to be 32-bit, then do what Jester said.
– Peter Cordes
Mar 7 at 23:26
6
6
Depends on your assembler but
cmp dword [rsp], 234
or cmp dword ptr [rsp], 234
will usually do it.– Jester
Mar 7 at 11:51
Depends on your assembler but
cmp dword [rsp], 234
or cmp dword ptr [rsp], 234
will usually do it.– Jester
Mar 7 at 11:51
You don't actually want
rsp
to be treated as a 32-bit pointer. If you did want that, you'd write [esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory [rsp]
to be 32-bit, then do what Jester said.– Peter Cordes
Mar 7 at 23:26
You don't actually want
rsp
to be treated as a 32-bit pointer. If you did want that, you'd write [esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory [rsp]
to be 32-bit, then do what Jester said.– Peter Cordes
Mar 7 at 23:26
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043119%2fhow-to-extract-32bit-numbers-in-assembly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043119%2fhow-to-extract-32bit-numbers-in-assembly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
Depends on your assembler but
cmp dword [rsp], 234
orcmp dword ptr [rsp], 234
will usually do it.– Jester
Mar 7 at 11:51
You don't actually want
rsp
to be treated as a 32-bit pointer. If you did want that, you'd write[esp]
to get 32-bit address-size (and probably segfault because RSP normally has some high bits set, so truncating it to 32-bit doesn't produce a valid address. If you want the pointed-to memory[rsp]
to be 32-bit, then do what Jester said.– Peter Cordes
Mar 7 at 23:26