Author Topic: Raw writting in text editor  (Read 22463 times)

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Raw writting in text editor
« on: February 28, 2015, 12:35:06 PM »
Hello, anyone know how to write in raw format in any text editor (I use notepad++).
I tried to do alt + {nbr}, but it don't work, it didn't work for what I want to write, it's about number between 0 - 32 (Unprintable characters)(decimal) in ascii table: http://www.asciitable.com/ .

What I want to do exactly is simulate the new line, without do it for real (real new line), when we press enter key, text editor write (hexa) 0D 0A in binary format.

Ex:
Code: [Select]
Hex Editor (use HxD):
74 65 73 74 0D 0A 74 65 73 74         ->           test..test                  # t(74) e(65) s(73) t(74) .(0D) .(0A) t(74) e(65) s(3) t(74) #

Text Editor:
test
test

I search how to do that cause I want to write multiple instructions in single line, I have written a macro for that, but it's begin to be too much binding:

Original: http://forum.nasm.us/index.php?topic=2020.msg9050#msg9050
Wish: remove the double underscore and brackets { } and comma , and have:

Code: [Select]
mov      rax, 0xdeadbeef       0D 0A (raw format hex)           add       rax, rcx




Thanks
« Last Edit: February 28, 2015, 05:39:59 PM by shaynox »

Offline logowriter_asm

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
  • Keep learning!
Re: Raw writting in text editor
« Reply #1 on: October 07, 2015, 05:58:48 AM »
You can write a program that takes a text file as input and generates the same file as output but with the ENTER rendered as "0D 0A".

I recommend C for this task as it's flexible and can read text files character by character.  ;) Something like this:

Code: [Select]
#include <stdio.h>

int main() {
    FILE *infile = fopen("myFile.txt", "r");
    FILE *outfile = fopen("out.txt", "w");
    if ( infile == NULL || outfile == NULL ) return -1;
    char c;
    while( !feof(infile) ) {
        c = fgetc(infile);
        if ( c == '\n' ) {
            fprintf(outfile, "0D 0A");
        } else {
            fputc(outfile, c);
        }
    }
    fclose(infile);
    fclose(outfile);
    return 0;
}

With this solution you don't have to use macros or alter the way you normally write such a file.

Regards! :D
Regards!

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Re: Raw writting in text editor
« Reply #2 on: October 07, 2015, 07:19:59 AM »
An external macro ?

Well, thanks for this proposition, but it's too long, I mean need another program in my compilation chain.

After the only solution is maybe to contact dev of npp for giving this idea ^^

Offline logowriter_asm

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
  • Keep learning!
Re: Raw writting in text editor
« Reply #3 on: October 07, 2015, 08:20:29 PM »
I understand. Adding a "pre-parser" makes things more difficult - except if you use an automated script.  :P

But hold on... Do you mean writing "0D 0A" in binary or text? Because if it's in binary, you don't have to do anything else: pressing ENTER puts "0D 0A" already in the file (as you're using Windows and N++ has that endline by default).

Regards! :D

EDIT: I've seen your original post, and if I'm not wrong, you want to have multiple ASM instructions within one line. You can use another separator if you like for this. I don't know, a pipe ( | ) instead of an ENTER. Then you can write a program that interprets the line by changing pipes with ENTERs.

EDIT 2: If you want to have such a file without editing NASM to handle it, it's very likely you'll need to use a pre-parser to handle it nicely and present the expected format to the assembler. The C program I put above is a very crude example of one (as it doesn't output the file directly into standard output).
« Last Edit: October 07, 2015, 08:32:23 PM by logowriter_asm »
Regards!

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Re: Raw writting in text editor
« Reply #4 on: October 07, 2015, 08:44:24 PM »
I mean give the possibility to write "0D 0A" in binary format while typing in text format, without executing this Ascii command :D

After maybe you are right to use that own program for being able to make a more involved macro system, but honestly, I am a totally noob at parsing text and transform it.

After the problem of the pipe symbol is that it represents an OR logic for Nasm ^^

Well, yeah I can invent another symbol(s), but honestly, I want to wait that are Nasm devs for invented that :p


Hmm as you see, I am very lazy :D
« Last Edit: October 07, 2015, 08:47:44 PM by shaynox »

Offline logowriter_asm

  • Jr. Member
  • *
  • Posts: 4
  • Country: 00
  • Keep learning!
Re: Raw writting in text editor
« Reply #5 on: October 07, 2015, 09:46:11 PM »
Oh, I understand now. You want to write the hexadecimal values "0D" and "0A" into the file, but without letting N++ interpret them as an ENTER.  :o

Honestly, I haven't heard about such thing before, but it's really interesting!

Let's see if the devs of N++ implement such a thing! :D

Regards!
Regards!

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Re: Raw writting in text editor
« Reply #6 on: October 08, 2015, 12:25:32 PM »
Thanks ^-^

I ask it there: https://notepad-plus-plus.org/community/topic/10640/raw-writting-in-text-editor-for-programmer-users-essentialy :o

We will see if the other peoples found that feature a original one too :p
« Last Edit: October 14, 2015, 12:34:56 PM by shaynox »