i have a file max.asm. i want to remove all comments and blank lines from file.
i wrote this code,i removed the blank lines and comments that are at starting position but how can i remove comments that are in mid of the line.
// This file is part of the materials accompanying the book
// "The Elements of Computing Systems" by Nisan and Schocken,
// MIT Press. Book site: www.idc.ac.il/tecs
// File name: projects/06/max/Max.asm
// Computes M[2] = max(M[0], M[1]) where M stands for RAM
@0
D=M // D=first number
@1
D=D-M // D=first number - second number
@OUTPUT_FIRST
D;JGT // if D>0 (first is greater) goto output_first
@1
D=M // D=second number
@OUTPUT_D
0;JMP // goto output_d
(OUTPUT_FIRST)
@0
D=M // D=first number
(OUTPUT_D)
@2
M=D // M[2]=D (greatest number)
(INFINITE_LOOP)
@INFINITE_LOOP
0;JMP // infinite loop
Sorry you need to use and embedded loop so that your program keeps reading the file. Once you see the "//" characters use the "ignore(...)" function to discard everything up until the new line: http://www.cplusplus.com/reference/iostream/istream/ignore/