본문 바로가기

전체 글

(177)
5-1강 - Trees 1. Trees 1) 정의 1> 1개 이상의 node로 이루어진 finite set 2> root 3> root을 제외한 나머지 node들은 disjoint set(subtree) T_1, ... , T_n으로 분할(partition)할 수 있다. (위의 그림에서도 맨 위의 root와 그 아래 3개의 subtree가 존재한다.) 2) tree의 용어 (뿌리가 위부터 자라서 아래는 잎이 있는 나무의 구조를 연상한다.) 1> node : 정보를 가지며 다른 node와 연결된 branch를 가지는 tree의 기본 단위 2> degree of node : 해당 node의 subtree 개수 3> degree of tree : 해당 tree의 node 개수 4> leaf : degree가 0인 node (=ter..
6-1강 - Conditional Processing 1 (bool과 비교 명령어) (AND, OR, XPR, NOT, TEST, CMP) 1. Boolean and Comparison Instructions 1) AND (Instruction) 1> 사용 AND destination, source 2> 규칙 (MOV와 규칙이 같다.) - source나 destination 중 하나에만 메모리가 올 수 있다. (메모리에서 메모리로 이동 불가) - destination에 CS, EIP, IP가 올 수 없다. - immediate로 이동시킬 수 없다. 3> 예시 1 4> 예시 2 mov al,'a‘ ; AL = 01100001b and al,11011111b ; AL = 01000001b 2) OR (Instruction) 1> 사용 OR destination, source 2> 규칙 (MOV와 규칙이 같다.) - source나 destinat..
5-3강 - Procedure 3 (Link Library) 3. Link Library 1) Link Library Machine code로 assemble된 procedure를 포함하고 있는 파일 2) Link Library 목록 1> Clrscr - Clears the console and locates the cursor at the upper left corner. 2> Crlf - Writes an end of line sequence to standard output. 3> Delay - Pauses the program execution for a specified n millisecond interval. 4> DumpMem - Writes a block of memory to standard output in hexadecimal. 5> Dump..
5-2강 - Procedure 2 (Procedure) 2. Defining and Using Procedures 1) Creating Procedures 1> 다른 language의 함수와 유사한 개념이다. (큰 문제를 작은 문제로 쪼개어 다룬다.) 2> 사용 func_name PROC . ret func_name ENDP 2) Documenting Procedure (procedure 만들 때 적어주면 좋은 것들) 1> procedure가 수행하는 작업에 대한 설명 2> Receives : Input parameters에 대한 설명 (their usage and requirements) 3> Returns : procedure가 return하는 값들에 대한 설명 4> Requires : procedure가 호출되기 전에 만족되어야 하는 조건들(precon..
5-1강 - Procedure 1 (Stack Operation) cf> 메모리를 그릴 때 1> 보통 위 = 낮은 주소 (00000000) 아래 = 높은 주소 (FFFFFFFF) 로 그린다. 2> stack 하지만 stack은 decrement의 느낌을 주기 위해 반대로 그림을 그린다. 1. Stack Operations 1) Runtime Stack 1> stack - LIFO (Last In First Out) - 한 쪽 끝(top)에서만 삽입과 삭제가 일어나는 구조 (Stack을 그릴 때는 평소(위 = 낮은 주소, 아래 높은 주소)와 반대로 그린다.) 2> Stack Pointer - stack을 가리키는 pointer (TOP) - stack frame에서 stack의 가장 마지막 주소가 저장된다. - SS register가 가리키는 stack segment의 ..
4-4강 - Data Transfer, Addressing and Arithmetic 4 (Indirect Addressing, JMP & LOOP) 4. Indirect Addressing 1) Indirect Operands 1> pointer처럼 변수의 주소를 이용해서 접근이 가능하다. - OFFSET을 이용해서 주소를 찾고 - []를 이용해서 저장된 값을 MOV에 의해 레지스터로 전달된다. 2> 예시 1 (OFFSET val1이 8000이라면) 10h 20h 30h 8000 8001 8002 val1 val1+1 val1+2 .data val1 BYTE 10h, 20h, 30h .code mov esi, OFFSET val1 mov al, [esi] ; AL = 10h inc esi mov al, [esi] ; AL = 20h inc esi mov al, [esi] ; AL = 30h - line 1 OFFSET을 이용해서 val1의 맨 앞 주..
4-3강 - Data Transfer, Addressing and Arithmetic 3 (Data-Related Operators and Directives) 3. Data-Related Operators and Directives 1) OFFSET (Operator) 1> byte나 label이 data segment로부터 떨어진 byte 수를 알려준다. 2> 특징 - Protected mode: 32bit / Real mode: 16bits - Protected mode 프로그램은 하나의 세그먼트만 사용함 (flat memory model) 3> 예시 .data bVal BYTE ?; 1byte wVal WORD ?; 2byte dVal DWORD ?; 4byte dVal2 DWORD ?; 4byte ; Assume that the data segment begins at 00404000h. .code mov esi,OFFSET bVal ; ESI = 00..
4-2강 - Data Transfer, Addressing and Arithmetic 2 (Addition and Subtraction) 2. Addition and Subtraction 1) INC, DEC Instruction 1> 증감 연산자를 의미한다. 2> 사용 inc destination : destination = destination + 1 dec destination : destination = destination - 1 3> 규칙 4> 예시 1 .data myWord WORD 1000h myDword DWORD 10000000h .code inc myWord ; 1001h dec myWord ; 1000h inc myDword ; 10000001h mov ax,00FFh inc ax ; AX = 0100h mov ax,00FFh inc al ; AX = 0000h - 마지막 line : (ax가 00FFh) al에 대해..