어셈블리 step_3_mov [대충정리 -> 차후 계속 수정]
mov // 메모리나 레지스터의 값을 옮길 때
그림 레지스터, 즉시값
eax => 32bit => 4byte => c언어 [int]
ax => 16bit => 2byte => c언어 [short]
ah => 8bit => 1byte => c언어 [char]
al => 8bit => 1byte => c언어 [char]
1 # include <stdio.h>
2
3 int main(void)
4 {
5 int v1 = 10;
6 return 0;
7 }
(gdb) disassemble main
Dump of assembler code for function main:
0x080483eb <+0>: push ebp
0x080483ec <+1>: mov ebp,esp
0x080483ee <+3>: sub esp,0x4
0x080483f1 <+6>: mov DWORD PTR [ebp-0x4],0xa
0x080483f8 <+13>: mov eax,0x0
0x080483fd <+18>: leave
0x080483fe <+19>: ret
End of assembler dump.
====================================================================================================
mov 로 스왑을 만들어 보았다.
# include <stdio.h>
void main(void)
{
char v1 = 10;
char v2 = 20;
char v3 = 0;
printf("before v1=>%d v2=>%d\n", v1, v2);
__asm
{
mov al, v1;
mov bl, v2;
mov ah, al;
mov al, bl;
mov v1, al;
mov v2, ah;
}
printf("before v1=>%d v2=>%d\n", v1, v2);
}
'어셈블리' 카테고리의 다른 글
nasm (0) | 2017.07.01 |
---|---|
어셈블리어_TEST (0) | 2017.06.23 |
어셈블리어 STEP_1 (0) | 2017.06.23 |
어셈블리 + irvine + 문자 출력 (0) | 2017.06.22 |
irvine 어셈블리 계산기 (0) | 2017.06.18 |