From: Frank K. <fbk...@zy...> - 2010-12-18 14:32:48
|
Shucks! I replied to this, but forgot: you've gotta click on "reply all", just "reply" goes just to the sender! Didn't mean to send it to just you, Jakob. Sorry 'bout that. Jakob Bohm wrote: > On 17-12-2010 07:27, Littlefield, Tyler wrote: >> hello all, Hi Tyler, Hi Jakob, >> I have a quick question. >> I have the following: >> section .data >> ptr dd 0 >> array times 100 db 0 >> >> Now, when I want to assign array to p, What's "p"? >> I can't mov it--how can I assign >> the pointer to point there? Last, is there a way to get the type of >> processor? >> (32-64), as that will make a difference on the code in some places? >> > > ; For 32 bits, I think this should assemble just fine: > > ptr dd 0 > array times 100 db 0 > > mov [ptr], array I think Nasm's going to whine "operation size not specified" unless we tell it: mov dword [ptr], array > ; For 64 bits, The code should become > > ptr dq 0 > array times 100 db 0 > > lea rax,[array] ; Add some notation here to make this rip relative! > mov [ptr], rax > > I don't know how to test if nasm is compiling for 16, 32 or 64 bits with > assembler directives, Nasm knows both "__BITS__" and "__OUTPUT_FORMAT__", whichever is most useful... To find what CPU, "cpuid"? It is also possible to write code that will distinguish at runtime what mode the CPU is actually in, using the fact that "dec"->"REX prefix". See news:comp.lang.asm.x86 "Standard idiom for prologue to ambivalent code" for details. > sorry I don't do that much nasm coding these days. Well, *that's* easy to fix! :) Best, Frank |