목차
mov al, 'A'
mov reg32 imm8
mov eax, number1
mov reg32, memory
mov eax, ebx
mov reg32, reg32
mov [eax], 10 :: [eax] = *eax 동일한 형식
number2 = 10;
number1 = number2;
mov number1, eax
mov direct, EAX
EX) 어셈블리로 바꾸어 코딩할 C소스
#include <stdio.h>
int main()
{
int sum = 0;
int temp = 0;
printf("Enter the x: ");
scanf("%d", &sum);
printf("Enter the y: ");
scanf("%d", &temp);
sum = temp + sum;
printf("Enter the z: ");
scanf("%d", &temp);
temp = temp * 2;
sum =sum - temp;
++sum;
-sum;
printf("(x + y - 2z + 1) is %d\n", sum);
return 0;
}
EX) first.asm
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
cr EQU 0Dh
Lf EQU 0Ah
.STACK 4096
.DATA
number1 DWORD ?
number2 DWORD ?
prompt1 BYTE "Enter First Number : ", 0
prompt2 BYTE "Enter Second Number : ", 0
prompt3 BYTE "Enter Third Number : ", 0
string BYTE 40 DUP (?)
label1 BYTE cr, Lf, "(x + y - 2z + 1) is"
sum BYTE 11 DUP (?)
BYTE cr, Lf, 0
.CODE
_start:
output prompt1
; printf("Enter First Number : ");
input string, 40
; scanf("%d", &sum);
atod string
mov number1, eax
output prompt2
; printf("Enter Second Number : ");
input string, 40
; scanf("%d", &temp);
atod string
mov number2, eax
mov eax, number1
add eax, number2
mov number1, eax
; sum = temp + sum;
output prompt3
; printf("Enter Third Number : ");
input string, 40
; scanf("%d", &temp);
atod string
mov number2, eax
mov eax, number2
add eax, eax
mov number2, eax
; temp = temp * 2;
mov eax, number1
sub eax, number2
mov number1, eax
; sum =sum - temp;
mov eax, number1
inc eax
mov number1, eax
; ++sum;
mov eax, number1
neg eax
; -sum;
mov eax, number1
dtoa sum, eax
output label1
INVOKE ExitProcess, 0
PUBLIC _start
END
실행 결과
Assembly (어셈블리/함수호출규약 cdecl, stdcall, pascal /MSAM /ml 컴파일/디버깅) (0) | 2017.07.18 |
---|---|
ASSEMBLY 기초/문법 (0) | 2017.07.18 |
어셈블리 기초 (0) | 2017.07.18 |