News for hackers. Stuff that matters.
Re:Learn x86-64 assembly by writing a GUI from scratch by nerpderp82 on Thursday June 01, 2023 @03:11PM (#36155934)
Becoming skilled at GDB and knowing how to generate assembly listing from your tooling is a key skill that really helps with understanding.

I learned assembly by reading the assembly listings from the C compiler. It is extremely interesting to be able internalize how high level constructs are compiled and optimized.

Re:Learn x86-64 assembly by writing a GUI from scratch by BlackLotus89 on Thursday June 01, 2023 @05:26PM (#36157566)
There was a reverse engineering guide that I quite liked that introduced you to assembly by first writing c examples, compiling them and then analyzing the disassembled output.

It was quite a long guide, but I would recommend it to anyone starting out. I don't have it in my bookmarks it seems, but I will try to update my comment tomorrow when/if I find it.

Re:Learn x86-64 assembly by writing a GUI from scratch by circuit10 on Thursday June 01, 2023 @06:40PM (#36158418)
https://godbolt.org/ is great for this
Re:Learn x86-64 assembly by writing a GUI from scratch by harry8 on Friday June 02, 2023 @03:28AM (#36162161)
Doing it locally is better, for mine.

eg

  https://gitlab.com/hal88/junkcode/-/blob/master/c_template.c
single file, chmod +x, compiles itself and executes the binary, can easily give the -S flag to gcc or clang (uncomment one line) or better yet run objdump on the binary.

The great thing is it still works if you include a bunch of local headers that are a hassle to supply to godbolt. Latency locally is a win.

The #if 0 trick for the compiler lines and #else for the code is a good one. Got it from Rusty Russell of iptables fame iirc. Write your script in C, why not?

Re:Learn x86-64 assembly by writing a GUI from scratch by ykonstant on Friday June 02, 2023 @06:28AM (#36163374)
Damn, I have to sign up to see the code?
Re:Learn x86-64 assembly by writing a GUI from scratch by no_news_is on Friday June 02, 2023 @09:31AM (#36164809)
Do you have that set as private? Even logged in, I get:

  Page Not Found

  Make sure the address is correct and the page hasn't moved.

  Please contact your GitLab administrator if you think this is a mistake.
Re:Learn x86-64 assembly by writing a GUI from scratch by claytonaalves on Friday June 02, 2023 @01:25PM (#36168104)
This repo is private. Can u make it public ?
Re:Learn x86-64 assembly by writing a GUI from scratch by harry8 on Sunday June 04, 2023 @08:55PM (#36191062)
I'm sorry, I thought it was public. Can't work out how to change it. Nuts.

  #if 0 //instructions to build and run
  THIS_FILE=$0
  BIN_FILE=/tmp/$(basename $0)
  gcc -std=c11  -O0 -g -march=native $THIS_FILE -Wall -Wextra -o $BIN_FILE
  if [ $? -ne 0 ]; then
      echo "Bug in your C code or there is something wrong with your operating system's c compiler..."
      exit 1
  fi

  # run it
  $BIN_FILE "$@"
  retval=$?

  # uncomment below to examine the generated machine code
  #
  # objdump -DC $BIN_FILE | less -p '<main>'

  # uncomment below to examine the assembly language the compier
  # thinks it is generating
  #
  # gcc -S -std=c11 -O0 -g -march=native $THIS_FILE -Wall -Wextra -o ${BIN_FILE}.s
  # vim ${BIN_FILE}.s
  
  # clean up
  rm $BIN_FILE
  exit $retval

  #else // c program

  #include <stdio.h>
  #include <stdint.h>
  
  
  
  int main(int argc, char **argv)
  {
      for(int i = 0; i != argc; ++i) {
          printf("argv[%d] = %s\n", i, argv[i]);
      }
  
  }
  
  #endif //end c program