1 / 23

Seoul National University

Seoul National University. IA32 Assembly Programming Assignment. AnSu Na ( asna@archi.snu.ac.kr ) Memory & Storage Architecture Lab. School of Computer Science and Engineering Seoul National University. Seoul National University. 목차. Introduction Assignment program Grading criteria

cortez
Download Presentation

Seoul National University

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Seoul National University IA32 Assembly Programming Assignment AnSu Na (asna@archi.snu.ac.kr) Memory & Storage Architecture Lab. School of Computer Science and Engineering Seoul National University

  2. Seoul National University 목차 • Introduction • Assignment program • Grading criteria • Example codes • Development environment & tolls • Submission

  3. Seoul National University Assembly Language C program (p1.c p2.c) text Compiler (gcc -S) text Asm program (p1.s p2.s) Assembly language Assembler (gcc or as) binary Object program (p1.o p2.o) Static libraries (.a) Linker (gcc orld) binary Executable program (p)

  4. Seoul National University IA32 Assembly Language • Intel Architecture 32bit • CISC • From intel 80386 microprocessor

  5. Seoul National University Assignment • 과제 목적 • Assembly Programing을 경험 • 과제내용 • n-queen problem을 해결하는 프로그램 구현 • IA32 assembly language 사용 • File I/O 구현 • System call

  6. Seoul National University N-Queen Problem • n행 n열의 체스 보드에 n개의 퀸을 다음과 같은 규칙을 따라 배치하는 문제 1) 어떠한 서로 다른 두 퀸도 같은 나라에 속하지 않음 2) 어떠한 서로 다른 두 퀸도 서로 공격할 수 없어야 함

  7. Seoul National University N-Queen Problem • n행 n열의 체스 보드에 n개의 퀸을 다음과 같은 규칙을 따라 배치하는 문제 1) 어떠한 서로 다른 두 퀸도 같은 나라에 속하지 않음 2) 어떠한 서로 다른 두 퀸도 서로 공격할 수 없어야 함

  8. Seoul National University DFS • Depth-first search • Algorithm for traversing or searching tree or graph

  9. Seoul National University Assignment Program • 주어진 n에 대한 n-queen problem의 모든 해를 찾고 퀸의 배치와 해의 개수를 출력 • 입출력 ㅡFile I/O 로 구현 • 입력 : input.txt • 출력 : output.txt • Input.txt와 output.txt는 모두 프로그램과 같은 디렉토리에 존재

  10. Seoul National University Input Format 2 # n의값이 2개 주어짐 2 # n = 2 8 # n = 8 • input.txt • 첫 번째 줄 : n의개수 • 나머지 줄 : n의 값 • Line-by-line input.txt의 예 k# n의값이 k개 주어짐 n1# n = n1 n2 # n = n2 … nk-1 # n = nk-1 nk# n = nk input.txt의 일반적 표현

  11. Seoul National University Output Format number_of_n = 2 ======================= n = 2 number_of_solutions = 0 ======================= n = 8 ---q---- ------q- -------q -q------ ----q--- q------- -----q-- # 빈 줄로 구분 ---q---- . . . . . . #총 92개 표시 number_of_solutions = 92 ======================= number_of_n = 2 ======================= n = 2 number_of_solutions = 0 ======================= n = 8 ---q---- ------q- -------q -q------ ----q--- q------- -----q-- # 빈 줄로 구분 ---q---- . . . . . . #총 92개 표시 number_of_solutions = 92 ======================= • output.txt • 첫 번째 줄 : n의 개수 • 나머지 줄 : n-queen problem의 해 • 주어진 모든 n에 대해 다음 값을 반복 출력 • 1) n의 값 • 2) 가능한 모든 퀸의 배치 • 빈칸 : ‘-’ • 퀸 :‘q’ • 각 배치는 빈 줄로 구분 • 3) 해의 개수 ouput.txt의 예

  12. Seoul National University Grading Criteria • 100점 만점 • 각 항목의 점수는 독립적으로 주어짐 • 보고서를 제외한 항목은 컴파일 및 실행이 되지 않을 시 0점

  13. Seoul National University Putty • Telnet program • Host : martini.snu.ac.kr • Port : 22 • Connection Type : SSH • Download • http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

  14. Seoul National University Putty - Login • ID & pass word • 타과 학생들은 홈페이지에 올린 ID와 암호 확인

  15. Seoul National University vi/vim – Text Editor #1 • Visual display editor • 2가지 모드 • 입력 모드 • 명령 모드 • 시작할 때 기본 모드 • 모드 전환 (Common case) • 명령모드 : ‘i’ 혹은 ‘insert’키로 입력모드 전환 • 입력모드 : ‘ESC’키로 명령모드 전환

  16. Seoul National University vi/vim – Text Editor #2 • 기본적인 명령 • 저장 • 명령모드에서 ‘:w’ 입력 • 나가기 • 명령모드에서 ‘:q’ 입력 • 저장하고 나가기 • 명령모드에서 ‘:wq’입력 • 저장하지 않고 나가기 • 명령모드에서 ‘!q’입력 • Reference • http://wiki.kldp.org/KoreanDoc/html/Vim_Guide-KLDP/Vim_Guide-KLDP.html

  17. Seoul National University Compile, Assemble, and Link • Compile • Assembly 파일 형성 • ex ) $ gcc –S filename.c => filename.s • Assemble & Link • Executable 파일 형성 • ex1 ) $ gccfilename.s => a.out • ex2 ) $ gcc –onewnamefilename.s => newname

  18. Seoul National University System call - printf • 줄 바꿈 없는 stdout출력 • Stack을 통해 String이 있는 주소를 넘겨 받아 해당 String을 출력한 후 리턴

  19. Seoul National University System call - puts • 줄 바꿈 있는 stdout출력 • Stack을 통해 String이 있는 주소를 넘겨 받아 해당 String을 출력한 후 줄바꿈을 출력하고 리턴

  20. Seoul National University System call - getf • stdin입력 • %ebx에 저장되어 있는 pstr의 시작 주소를 스택을통해 넘겨 받음 • 리턴 값 • 해당 시작 주소를 반환 • 정상 동작 • Null (0x0) • 입력 끝이거나 오류 발생 $ gcc –O1 –S getf.c

  21. Seoul National University Debugging • Tool • gdb • gdb실행 • gdb [프로그램명] • 주의 : -g 옵션 사용하여 컴파일 해야 디버깅 가능 • ex) $ gcc –g –o main main.c $ gdb main

  22. Seoul National University Debugging • 기본적인 명령어 • 디버깅할 프로그램 실행 • (gdb) run • gdb종료 • (gdb)q • 정보보기 • (gdb) info • 레지스터 값 모두 보기 • (gdb) info registers • 브레이크 포인트 잡기 • (gdb) break [line number] • 레지스터 하나만 보기 • (gdb) info register [register name]eax • ex ) (gdb)info register eax

  23. Seoul National University 제출방식 • Due Date • 2013년 10월 27일(일요일) 11:59 PM 까지 • 1일 delay 당5점씩 감점 • 제출 기한 일주일후 까지 제출 가능 • (11월 3일 11:59 PM까지 가능) • 메일로 보고서와 소스코드 제출 • 메일제목 : [컴구조과제]학번_이름 • 첨부파일 : 학번_이름.zip으로 함께 압축하여 제출 • ex) 제목 : [컴구과제]2013-00000_나안수 첨부파일: 2013-00000_나안수.zip • 메일주소: asna@archi.snu.ac.kr

More Related