0

I have a text file called dna.txt which contains ACGGTGCTGTATCCATATCCGTTAACTCTCTTGTGTCACC. I want to count the occurrences of characters C and G in the text file, and the length of the original string.

I want the program to read the input from a text file in the same folder as it is saved (on Windows).

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
lowrain
  • 21
  • 4
  • 2
    Under what OS? e.g. Linux, or a simulator like RARS which provides its own set of toy system calls? RISC-V is just a CPU architecture, it doesn't define system calls because that's something other software provides. If you're using a real OS that a C compiler can target, a program using `open(O_RDONLY)` and `read` system calls should compile to asm you can look at. (And you can inline the system calls if you want.) Or use libc stdio functions. POSIX `read` returns a length in bytes. – Peter Cordes Feb 20 '23 at 06:08
  • If you're writing in asm for performance reasons, I'm not sure if an SWAR bithack can be effective here to process 4 bytes at once. If you're targeting a RISC-V with vector extensions, that should well, comparing bytes and adding in elements where there was a match. Horizontally adding at least every 255 vectors to avoid overflow of byte accumulators. – Peter Cordes Feb 20 '23 at 06:12
  • @PeterCordes im using a RARS simulator in Windows – lowrain Feb 20 '23 at 06:28
  • 1
    Then use RARS system calls. https://github.com/TheThirdOne/rars/wiki/Environment-Calls – Peter Cordes Feb 20 '23 at 06:29
  • will read into this. thanks @PeterCordes ! – lowrain Feb 20 '23 at 06:32

0 Answers0