实验1
- 写一个完整的8086汇编语言程序,满足一下要求:
- 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据存储的值20。
- 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据的值从键盘输入。
- 将上述两个值自加1后显示在屏幕上。
(代码清单,注意添加注释,养成良好习惯)
;Program:
;Author:
;Date:
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h ; header file for input/output
cr EQU 0dh ; carriage return character
Lf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
number1 DWORD 20
number2 DWORD ?
prompt1 byte "Please enter a ASCII of a data:",0
prompt2 byte cr,lf,"The value of number1:",0
prompt3 byte cr,lf,"The value of number2:",0
string byte 20 dup (?)
str1 byte 20 dup (?)
str2 byte 20 dup (?)
.CODE
; start of main program code
_start:
output prompt1
input string,20
atod string
mov number2,eax
mov ebx,number1
inc ebx
dtoa str1,ebx
mov ecx,number2
inc ecx
dtoa str2,ecx
output prompt2
output str1
output prompt3
output str2
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code
实验2
- 写一个完整的8086汇编语言程序,求解表达式-3x-y+1的值,结果显示在屏幕上。
;Program:
;Author:
;Date:.386
.MODEL FLATExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
cr EQU 0dh ; carriage return character
LF EQU 0ah ; linefeed character.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
Prompt1 BYTE " -3x-y+1 ",cr,Lf,Lf
BYTE "Enter x: ",0
Prompt2 BYTE "Enter y: ",0
Value BYTE 20 DUP (?)
Prompt3 BYTE cr,Lf,"The result is "
Result BYTE 6 DUP (?)
BYTE cr,Lf,0.CODE ; start of main program code
_start:
output Prompt1
input Value,16
atoi Value
mov dx,ax ;x
imul dx,3 ;3xoutput Prompt2
input Value,16
atoi Value
add dx,ax ;3x+y
neg dx ;-(3x+y)
add dx,1 ;-3x-y+1itoa result,dx
output Prompt3INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code