0

I'm beginner in asm (mips) and I would like to import a large string into my program in order to displaying it (this has to be done before compilation).
For simplicity reasons, I don't like to put the whole string on the program source code.

How is it possible to accomplish this?
Is there any keyword or macro which I can use?

user6039980
  • 3,108
  • 8
  • 31
  • 57
  • Why would you want to use asm? Where do you want to put the string? – Marc Glisse Sep 28 '17 at 16:25
  • 1
    @MarcGlisse Why does this matter? – user6039980 Sep 28 '17 at 16:27
  • Import from outside the code is an OS operation. You need to call the proper function from some lib like stdio. – Ripi2 Sep 28 '17 at 16:29
  • @Ripi2 What I need is to be done before compilation. – user6039980 Sep 28 '17 at 16:31
  • @Ripi2 I need to import a string (part of the program) but using the text file as a named resource. – user6039980 Sep 28 '17 at 16:32
  • 1
    You can use preprocessor directives (#include) in an asm file, if your compilation process preprocesses the file before assembling it (for instance if the file is named something.S and compiled with gcc). – Marc Glisse Sep 28 '17 at 18:13
  • 1
    This question and the answer seem to be closely related including getting it into an RODATA section. https://stackoverflow.com/questions/42235175/how-do-i-add-contents-of-text-file-as-a-section-in-an-elf-file Acouple samples of using the data from both _C_ and NASM is provided. – Michael Petch Sep 28 '17 at 19:27
  • Is it ok if the file holding the string starts with `.asciz "` instead of just the string contents as the first byte? If not, then maybe you can play some macro tricks to get the expansion of `#include "string.txt"`stringified. – Peter Cordes Sep 28 '17 at 20:23

0 Answers0