Assembly. Fun fun fun.

So I am taking the plunge in to 64 bit assembly programming in Linux and coming from a previous understanding of 32 bit (x86) assembly, some of the immediate differences are interesting.

System Calls use syscall where in x86, it was int 0x80.

32 bit Hello World:

    section .data
    hello: db 'Hello world!',10
    helloLen: equ $-hello

    section .text
    global _start

    _start:
    mov eax,4 
    mov ebx,1 
    mov ecx,hello 
    mov edx,helloLen 
    int 80h

    mov eax,1
    mov ebx,0
    int 80h

64 bit Hello World:

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

section .text
    global _start

   _start:
   mov     rdi, dword string1
   mov     rcx, dword -1
   xor     al,al
   cld
   repnz scasb

   mov     rdx, dword -2
   sub     rdx, rcx

   mov     rsi, dword string1
   push    0x1
   pop     rax
   mov     rdi,rax
   syscall

   xor     rdi,rdi
   push    0x3c
   pop     rax
   syscall

I figured it might be relevant to learn considering that most (home based) systems will be running on 64 bit processors. And the money I dished out on assembly books back in the early 90’s should be put to use. :smiley:

Any assembly programmers here that haven’t had to have a hip replacement care to comment on some of the other differences or your experiences?

LOL, I haven’t touched assembly since the days of DOS. System calls in DOS were made through INT 19h, and the AH register selected the function you wanted to call. And of course there weren’t any exx or rxx registers to speak of. FS and GS wouldn’t come in nearly a decade, and you could only use SI and DI as indexes.

I had a brief affair with Windows assembly. Not enough to produce any actually useful program (though I’m still tempted to do that evolving nebula system and to use some asm {…} to speed up gravity calculations). API calls where usually done with macros – which boiled down to getting a pointer to the function table and then a CALL DWORD PTR [whatever] to get the function. The Linux approach seems more protected. Is the memory model a flat one here as well?

Heh, I haven’t touched any Assembler since my C64 and one class on System 370. And I haven’t had a hip replacement yet :stuck_out_tongue:
Be interesting to see what you turn up!

… lol - this was once upon a time the only key programming language every cool dude wanted to clock.