Author Topic: writefile with NASM  (Read 12136 times)

Offline assistech

  • Jr. Member
  • *
  • Posts: 27
writefile with NASM
« on: May 15, 2020, 08:50:38 PM »
How to write string in a  file ("mystring_inside.txt") with NASM ?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: writefile with NASM
« Reply #1 on: May 15, 2020, 09:28:03 PM »
What have you tried? Foolish question, I suppose...

https://stackoverflow.com/questions/40003885/win32-assembly-writefile-to-console-dont-s

You might be better off linking with GoLink or some other(?)...

Best,
Frank


Offline assistech

  • Jr. Member
  • *
  • Posts: 27
Re: writefile with NASM
« Reply #2 on: May 15, 2020, 09:47:42 PM »

Offline assistech

  • Jr. Member
  • *
  • Posts: 27
Re: writefile with NASM
« Reply #3 on: May 16, 2020, 11:59:27 AM »
Hi,

 I would like to write a string after "_scanf" at my MS-DOS screen and write this string on a file ".txt", i could recovery this information and use it with another langage like C.

Because i don't know how to insert assembler code in a C program with CODELITE, but i find a method to call my assembler code file ".exe", by calling the executable file with system("c:/.......");


Thanks,



Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: writefile with NASM
« Reply #4 on: May 16, 2020, 08:23:27 PM »
Why do you want to involve assembly language at all?

Best,
Frank


Offline assistech

  • Jr. Member
  • *
  • Posts: 27
Re: writefile with NASM
« Reply #5 on: May 16, 2020, 08:43:20 PM »
Hi,

Because like it. And want to write hard code, not easy for someone would like copy my code for my futur software.

Offline assistech

  • Jr. Member
  • *
  • Posts: 27
Re: writefile with NASM
« Reply #6 on: June 06, 2020, 09:53:13 PM »

Hey, have you ever read this :


https://www.tutorialspoint.com/assembly_programming/assembly_file_management.htm


I will try it on Windows

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: writefile with NASM
« Reply #7 on: June 06, 2020, 10:41:41 PM »
Okay. That's for Linux. Windows will be different, but same general idea. First, you'll have to open the file. to get a file "descriptor" or "handle". This will want a pointer to a filename (obviously), whether it's read/write or both, maybe some "permissions"... ownership... etc. MicroSoft has a;; this pretty well documented. Search for "OpenFile", "WriteFile", etc. It will not be in assembly language. Where they do "foo", we have to do "call foo". You'll figure it out. If you have trouble, post what you've got... You might even get someone running Windows to help...

Best,
Frank