Author Topic: Is there examples about 64-bit coding?  (Read 24032 times)

nobody

  • Guest
Is there examples about 64-bit coding?
« on: June 21, 2008, 02:40:25 PM »
I'm a newbie in assembly programming, i have read intel 64 and ia-32 software developers manual, and think 64-bit mode is a much better environment for assembly programming, so i wonder is there any example programs to help me start 64-bit assembly coding with nasm? thanks!

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Is there examples about 64-bit coding?
« Reply #1 on: June 21, 2008, 05:27:23 PM »
I have no experience with 64-bit programming. Seems like needless overkill, unless you're programming database apps for the Human Genome Project, or so. In fact, it seems like "another nail in the coffin" of assembly language to me. So I'm curious why you think it's a better environment for assembly language?

This is for 64-bit Linux (thanks to Chuck Crayne!). Only one I've got. I suppose MS has got an example for 64-bit Windows (if they've got it working). Completely different ABI, I understand.  Keith, you got anything for that? Or anybody?

Let us know how this works out for ya (especially if it doesn't!).

Best,
Frank


section .data
    string1 db  "Hello World!",10,0

section .text
    global _start

_start:
        ; calculate the length of string
        mov     rdi, string1
        mov     rcx, -1
        xor     al,al
        cld
        repnz scasb

; place the length of the string in RDX
        mov     rdx, -2
        sub     rdx, rcx

; print the string using write() system call
        mov     rsi, string1
        push    0x1
        pop     rax
        mov     rdi,rax
        syscall

; exit from the application here
        xor     rdi,rdi
        push    0x3c
        pop     rax
        syscall

nobody

  • Guest
Re: Is there examples about 64-bit coding?
« Reply #2 on: June 21, 2008, 11:06:02 PM »
> I have no experience with 64-bit programming.

Me neither ;-)

> Seems like needless overkill, unless you're programming database
> apps for the Human Genome Project, or so.

Funny ... why did you add it into NASM then ? Only because FASM, YASM, GAS, and MASM have it, and without it NASM would be "obsolete" ?

> seems like "another nail in the coffin" of assembly language to me.

To me also :-|

> So I'm curious why you think it's a better environment for assembly language?

IMHO NO ... DOS (16-bit and 32-bit) is better ;-)

> example for 64-bit Windows (if they've got it working). Completely

useless ... nevertheless, Vista most likely will be the last one still supplying a 32-bit version ... in 20 years, some freaks will run obsolete 32-bit Vista on single-core P4 CPU's ... while mainstream will have 256-bit Windows and 256-bit Linuxes and 256-core CPU's ... hogging several 100 TiB's :-D

nobody

  • Guest
Re: Is there examples about 64-bit coding?
« Reply #3 on: June 25, 2008, 06:11:19 AM »
Well, you still need assembly on 64-bit machines, but typically only for selected routines.

However, if you're processing that Human Genome Project database, you may very well want a hand-optimized search code using the latest AVX or SSE5 instructions.