Hacker News new | past | comments | ask | show | jobs | submit login

global _start

section .text

_start:

  mov rax, 1        ; write(
  mov rdi, 1        ;   STDOUT,
  mov rsi, msg      ;   msg,
  mov rdx, len   ;      sizeof(msg)
  syscall           ; );

  mov rax, 60       ; exit(
  mov rdi, 0        ;   EXIT_SUCCESS
  syscall           ; );
section .rodata

  msg: db "RIP Tony, Father of Assembly Language", 10
  len: equ $ - msg%



Always stayed away from Intel assembly, but thought I'd have a go at running this. First issue was this is I think, Intel format, whereas I was using GNU as, so I had to make a few changes:

  .global _start

  .text
  _start:
    mov $1,%rax        # write(
    mov $1,%rdi        #   STDOUT,
    mov $msg,%rsi       #   msg,
    mov $len,%rdx      #      sizeof(msg)
    syscall            # );

    mov $60,%rax       # exit(
    mov $0,%rdi        #   EXIT_SUCCESS
    syscall           # );

  .data
    msg: .ascii "RIP Tony, Father of Assembly Language\n"
    len = . - msg
Then you can run with:

  gcc -c src.s && ld src.o && ./a.out


I think you can use ".intel_syntax noprefix" with GNU as to assemble Intel assembly.


Any chance you can elaborate the reasons for staying away from Intel syntax?


Not OP, but I think it is like indentation styles: you learn it one way, then everything else feels weird and ugly.


Mainly because the assembler I knew I had on my computer was the GNU assembler and it uses that syntax. I did quickly try the .intel_syntax directive but it was just easier to change it around as the code was so short.

Most of my assembler experience is with 6502 or ARM.


Thanks for correcting code :3


A couple online places to try this and where you can play around with this code. The "%" after msg on the last line seems to cause an error, at least for when I tried it with my version of nasm, so I removed it in the below links.

A small website with a few dozen compilers/assemblers, just press F8 or click "Run it" to try the sample above:

https://rextester.com/SBEL3962

Hundreds of compilers and assemblers are offered online and configurable with tio.run in a bit of a more complex website, just hit the play button:

https://tio.run/##fZAxT8MwFIT3/IpTxdBKKQoLQzKhUqRKSCCSSmzVS@...


title is wrong it was autocode (precursor of high level languages) not assembly and Brooker not Booker




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: