【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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章