First ever x86_64 program.
I feel like a rocket scientist lol

  • 6
    tell me more
  • 8
    I’d like to learn. How are you compiling that? It looks like VS Code on Windows.
  • 4
    I'm listening?
  • 6
    Seems like it's tagged as "story", but I reckon it's "to be continued" too :p *subscribe for MOAR and hit the bell.. wait...*
  • 5
    @GMR516 vs code on linux, look at the programbar (the one with the "X" in the top right)
  • 4
    Man, assembly is fun, so long as there's not much code to write. But some of the logic can be mindbending at times :S
  • 0
    @GMR516 its arch linux with kde de i am using nasm as a compiler for x86_64
  • 0
    This is a very basic program and its not to complicated. Basically what ive learn till now is that every assembly program is split in 3 sections.
    The .data section is used to declare variables which will be used after compile and have a defined value. The .bss section is like .data section but for variables that will take the value after something happens on the program. The .text is where the code goes and it only tells the nasm compiler that the executon start at _start function.The start function calls 4 other functions that print the strings i have declared in .data section. The first instraction of the function tells that i am trying to use a x64 cpu registry called rax and the number setting the value of this registry after " , ". The 1 value is an instruction for x86_64 cpu`s using linux kernel which is tellin the cpu to write on this. Different cpu architectures and different kernels have different instruction numbers. Example on mac instruction for write is 0x2000004.
  • 1
    You should try at&t syntax
  • 1
    @ewpratten will do. i am on the first steps still
  • 7
    @netctl please don't, AT&T syntax is retarded and should die already (sorry @ewpratten)
  • 4
    Create 512 byte file, use bios interrupts to print string, add 55AAh signature to the end. dd it to flash card's first sector and plug to computer and see your OS.
  • 0
    @netctl @RememberMe

    At&t might look ugly, but the ordering of things actually makes sense, and it allows you to get even lower level with its mnemonic suffixes

    For example:

    These allow even more precise data handling.
  • 0
    Also, I'm pretty sure it's cross-compatible with Intel syntax.
  • 2
    @ewpratten doesn't Intel syntax infer the size of the mov using the register/pointer sizes? At least, I've never come across this as a problem.

    I agree that being explicit about it is nice in this case, but AT&T just looks so damn ugly. Pretty sure all the extra noise is because it makes it easier to parse, which should be a non-issue for modern parsers.

    Also, I feel the intel syntax operand order (destination-first) is more intuitive because it's similar to an assignment (dest = source kind of thing).

    Also, complex addresses are waaay cleaner in Intel than in AT&T (look at the attached image for a comparison). Intel makes perfect sense even if you don't know it, while AT&T is an absolute horror.

    Besides, most resources I've used prefer the intel syntax.
  • 0
    @jschmold or use yasm, nasm, or gas.
  • 1
    @ewpratten One thing I never managed to find out in AT&T that made me not want to convert was `jmp somelabel:thecodetoberan`, but I'd love to try again
  • 1
    I'm making a "game" for the nes in 6502 assembly, same feeling
  • 0
    You should turn your screen 90° 😉
  • 0
    And when I thought that I was cool using Assembly to program Cortex CPU I see this...
Add Comment