본문 바로가기

컴퓨터 공학 자료(학부)/Assembly

C언어에서 인라인으로 어셈코드 이용


#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main() {

char container[20];
char result[20];
int count=0;

ifstream fin;
ofstream fout;
fin.open("input.txt");
fout.open("output.txt");

fin.read(container,20);
count=fin.gcount();

__asm{
 cld
 MOV ecx, count
 LEA esi, container
 LEA edi, result
 REP MOVSB
}


for(int i =0 ; i<count ; i++){
 if(result[i]=='\n')
  fout<<result[++i];
 else
  fout<<result[i];
}

fin.close();
fout.close();

 return 0;
}

인풋파일에 있는 문자열을 쭉 붙여서 출력하는 간단한 함수.

'컴퓨터 공학 자료(학부) > Assembly' 카테고리의 다른 글

ASSUME 디렉티브의 정의(MASM)  (0) 2010.07.11
Segment란?  (0) 2010.07.11
어셈블리어 과제  (0) 2010.05.08
간단한 대소문자 변환  (0) 2010.04.28
MASM과 비쥬얼스튜디오 2008연동  (1) 2010.03.10