Exercises 4.2.2 Write a complete 80x86 assembly language program to prompt for values of x, y, and z and display the value of the expression 2(-x + y - 1) +z Allow for 32-bit integer values. |
.386 .MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dxExitCode:DWORD
INCLUDE io.h
cr EQU 0dh Lf EQU 0ah
.STACK 4096
.DATA prompt1BYTE"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 prompt2BYTE"Enter value for y: ", 0 prompt3BYTE"Enter value for z: ", 0 ValueBYTE16 DUP (?) AnswerBYTEcr, Lf, "The result is "
ResultBYTE6DUP (?) BYTEcr, LF, 0
.CODE _start:
outputPrompt1 input Value, 16 atoiValue negax movdx, ax
outputPrompt2 inputValue, 16 atoiValue adddx, ax
decdx adddx, dx
outputPrompt3 inputValue, 16 atoiValue adddx, ax
itoaResult, dx
outputAnswer
INVOKE ExitProcess, 0 PUBLIC _start
END
|
Exercises 4.3.2 Write a complete 80x86 assembly language program to prompt for the length, width, and height of a box and to display its surface area 2*(length*width + length*height + width*height). |
.386 .MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dxExitCode:DWORD
INCLUDE io.h
cr EQU 0dh Lf EQU 0ah
.STACK 4096
.DATA
prompt1BYTE"This program will evaluate the expression", cr, Lf, Lf BYTE"2*(length*width + length*height + width*height)", cr, Lf, Lf BYTE"for your choice of integer values.", cr, LF, Lf BYTE"Enter value for length of a box: ", 0 prompt2BYTE"Enter value for width of a box: ", 0 prompt3BYTE"Enter value for height of a box: ", 0 ValueBYTE16 DUP (?) AnswerBYTEcr, Lf, "The result is "
ResultBYTE6DUP (?) BYTEcr, LF, 0
.CODE _start:
outputprompt1 inputValue, 16 atodValue movebx, eax;ebx = Length
outputprompt2 inputValue, 16 atodValue movecx, eax;ecx = Width movedx, eax imuledx, ebx;edx = Length * Width
outputprompt3 inputValue, 16 atodValue imulebx, eax;ebx = Length * Height, eax = Height imuleax, ecx;eax = Width * Height
addeax, ebx addeax, edx
shleax, 1
dtoaResult, eax outputAnswer ;2*(length*width + length*height + width*height)
INVOKEExitProcess, 0 PUBLIC_start END
|
'코스웨어 > 13년 스마트컨트롤러' 카테고리의 다른 글
130902 - 월요일 정리 문예진 (0) | 2013.09.02 |
---|---|
130830 금 정리 조유진 (0) | 2013.08.30 |
옵티머스 드라군(중간프로젝트) (0) | 2013.08.30 |
apue.h (0) | 2013.08.29 |
어셈블리 과제 - 문남경 (0) | 2013.08.29 |
어셈블리 숙제 0828 - 임기준 (0) | 2013.08.28 |
어셈블리 과제 - 손초롱 (0) | 2013.08.28 |
어셈블리 과제 - 이수현 (0) | 2013.08.28 |