xop -- Echo highlighted unparsed 'nop' instruction in standard output.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2KB

  1. /*
  2. * Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
  3. *
  4. * Xop is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
  5. * And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
  6. * It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
  7. */
  8. #include <xolatile/xtandard.h>
  9. #include <xolatile/xtandard.c>
  10. int main (int argc, char * * argv) {
  11. int file = -1;
  12. int size = 0;
  13. int offset = 0;
  14. unsigned char * buffer = NULL;
  15. if (argc != 2) {
  16. fatal_failure (1, "xop: xop input");
  17. }
  18. file = file_open (argv [1], O_RDONLY);
  19. size = file_size (file);
  20. buffer = allocate (size);
  21. file_read (file, buffer, size);
  22. file = file_close (file);
  23. do {
  24. int byte = (int) buffer [offset];
  25. if (byte == 0X90) {
  26. echo_new_line ();
  27. terminal_style (EFFECT_NORMAL, COLOUR_YELLOW);
  28. echo_byte ((int) buffer [offset]);
  29. terminal_style (-1, -1);
  30. } else {
  31. echo_byte (buffer [offset]);
  32. }
  33. ++offset;
  34. } while (offset != size);
  35. echo_new_line ();
  36. buffer = deallocate (buffer);
  37. return (EXIT_SUCCESS);
  38. }