pdf p.118 예제
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
include io.h
cr equ 0dh
Lf equ 0ah
.STACK 4096
.DATA
Prompt1 BYTE "This program will evaluate the expression", cr, Lf, Lf
BYTE " - ( x + y ) - 2z + 1)", cr, Lf, Lf
BYTE "for your choice of integer values.", cr, Lf, Lf
BYTE "Enter value for x: ", 0
Prompt2 BYTE "Enter value for y: ", 0
Prompt3 BYTE "Enter value for z: ", 0
Value BYTE 16 DUP (?)
Answer BYTE cr, Lf, "The result is "
Result BYTE 6 DUP (?)
BYTE cr, Lf, 0
.CODE
_start:
output Prompt1
input Value, 16
atoi Value
mov dx, ax
output Prompt2
input Value, 16
atoi Value
add dx, ax
output Prompt3
input Value, 16
atoi Value
add ax, ax
sub dx, ax
inc dx
neg dx
itoa Result, dx
output Answer
INVOKE ExitProcess, 0
PUBLIC _start
END
pdf p.120 연습문제 4.2 2번
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
include io.h
cr equ 0dh
Lf equ 0ah
.STACK 4096
.DATA
Prompt1 BYTE "This program will evaluate the expression", cr, Lf, Lf
BYTE " 2( -x + y - 1) + z", cr, Lf, Lf
BYTE "for your choice of integer values.", cr, Lf, Lf
BYTE "Enter value for x: ", 0
Prompt2 BYTE "Enter value for y: ", 0
Prompt3 BYTE "Enter value for z: ", 0
Value BYTE 16 DUP (?)
Answer BYTE cr, Lf, "The result is "
Result BYTE 6 DUP (?)
BYTE cr, Lf, 0
.CODE
_start:
output Prompt1
input Value, 16
atoi Value
neg ax
mov dx, ax
output Prompt2
input Value, 16
atoi Value
add dx, ax
dec dx
add dx, dx
output Prompt3
input Value, 16
atoi Value
add dx, ax
itoa Result, dx
output Answer
INVOKE ExitProcess, 0
PUBLIC _start
END
pdf p.127 예제
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
cr equ 0dh
Lf equ 0ah
.STACK 4096
.DATA
prompt1 BYTE "This program will find the area of a rectangle", cr, Lf, Lf
BYTE "Width of rectangle? ", 0
prompt2 BYTE "Length of rectangle? ", 0
value BYTE 16 DUP (?)
answer BYTE cr, Lf, "The area of the rectangle is "
area BYTE 11 DUP (?)
BYTE cr, Lf, 0
.CODE
_start:
Prompt: output prompt1
input value, 16
atod value
mov ebx, eax
output prompt2
input value, 16
atod value
mul ebx
dtoa area, eax
output answer
INVOKE ExitProcess, 0
PUBLIC _start
END
pdf p.130 연습문제 4.3 2번
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
cr equ 0dh
Lf equ 0ah
.STACK 4096
.DATA
prompt1 BYTE "This program will find the area of a box", cr, Lf, Lf
BYTE "Width of the box? ", 0
prompt2 BYTE "Length of the box? ", 0
prompt3 BYTE "Height of the box? ", 0
value BYTE 16 DUP (?)
answer BYTE cr, Lf, "The surface area of the box is "
area BYTE 11 DUP (?)
temp DWORD 32 DUP (?)
height DWORD 32 DUP (?)
sum DWORD 32 DUP (?)
BYTE cr, Lf, 0
.CODE
_start:
Prompt: output prompt1
input value, 16
atod value
mov ebx, eax ; ebx: width
output prompt2
input value, 16
atod value
mov ecx, eax ; ecx: length
output prompt3
input value, 16
atod value
mov height, eax ; height = height
mov temp, ecx
mov eax, ebx
imul eax, temp ; width*length
mov sum, eax ; sum = width*length
imul ebx, height ; width*height
mov eax, ebx
add eax, sum ; sum += length*height
mov sum, eax
imul ecx, height ; ecx = length*height
mov eax, ecx
add eax, sum
add eax, eax ; * 2
dtoa area, eax
output answer
INVOKE ExitProcess, 0
PUBLIC _start
END
'코스웨어 > 13년 스마트컨트롤러' 카테고리의 다른 글
어셈블리 과제 - 문남경 (0) | 2013.08.29 |
---|---|
어셈블리 숙제 0828 - 임기준 (0) | 2013.08.28 |
어셈블리 과제 - 손초롱 (0) | 2013.08.28 |
어셈블리 과제 - 이수현 (0) | 2013.08.28 |
어셈블리 과제 - 전영기 (0) | 2013.08.28 |
어셈블리 과제 _ 김성엽 (0) | 2013.08.28 |
어셈블리 과제 -문예진 (0) | 2013.08.28 |
어셈블리 숙제 - 조유진 (0) | 2013.08.28 |