8086汇编 键盘输出

实验题目一

写一个完整的8086汇编语言程序,从键盘输入姓名,屏幕上输出“hello,姓名”,如若从键盘输入的是“Sam”,则从屏幕上显示“hello,Sam”。

源码

;Program:
;Author:Nonoas
;Date:20191009

.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

prmpt byte "输入你的姓名: ", 0
str1 byte "hello,"
str2 byte 10 dup(?)

.CODE                           ; start of main program code
_start:

	output prmpt
	input str2,10

	output str1

        INVOKE  ExitProcess, 0  ; exit with return code 0
PUBLIC _start                   ; make entry point public

END                             ; end of source code

实验题目二

写一个完整的8086汇编语言程序,满足一下要求:
A. 数据段申请一个存储数据的字长数据number1,该数据存储的值12。
B. 数据段申请一个存储数据的字长数据number2,该数据从键盘输入。(提示从键盘键入该数据的ASCII值,转换成数值后存入number2中)
C. 交换number1和number2的值,并且显示交换后的值在屏幕上(提示数值需要转化为ASCII值才能进行输出)。
假设从键盘输入的值为“20”,则显示的信息为:
The value of number1 is 20,the value of number2 is 12。

源码

;Program:
;Author:Nonoas
;Date:20191009

.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 12
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
	xchg eax,number1
	mov number2,eax

	mov ebx,number1
	dtoa str1,ebx

	mov ecx,number2
	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

发布了18 篇原创文章 · 获赞 16 · 访问量 1417

猜你喜欢

转载自blog.csdn.net/weixin_44155115/article/details/103866430