谁会8086汇编语言设计啊?

来源:百度知道 编辑:UC知道 时间:2024/07/07 15:55:06
Question 1

Write an assembly language program that allows entry of a decimal number via the keyboard. Note that the number should be accumulated as a bit word in register eax. The program terminates when a space is entered.
Hint: Each ASCII character you read in needs to be converted into a binary number and then added to the previous result multiplied by ten (10). The initial result will need to be set to 0 to make this work properly. Multiplication is sometimes tricky to get working properly in Intel assembly language. You may need to use lots of 8 and 16 bit registers in your program. Please read the sections on division and multiplication in 'Practical notes/8086 tutorial' and in 'Practical notes/Yasm documentation' (on the unit website).

Question 2

Modify the program developed in Question 1 to recognize any overflow conditions that may occur (that is, a number that will not fit into sixteen bits) and to send a message to th

楼主够狠。既考我们英语,又考我们汇编,差一个都答不上啊。

下面这个程序通过编译、运行正确。

Data segment
PromptStr DB 'Please enter a decimal number:$'
overflow DB 13,10,13,10,'The number is too big to fit into sixteen bits.$'
overflow0 DB 13,10,13,10,'press a any key to terminate...$'
overflow1 DB 13,10,13,10,'press a any key to enter another number...$'
Product DW ?
Cursor DW 0 ;光标位置
Data Ends

Code segment
assume cs:Code,ds:Data

; ----------------------------------------------------------------------------
; 功能:显示指定地址(Str_Addr)的字符串
; 入口:
; Str_Addr=字符串地址(要求在数据段)

; 用法: Output Str_Addr
; 用法举例:Output PromptStr

Output MACRO Str_Addr
lea dx,Str_Addr
mov ah,9
int 21h
EndM
; ----------------------------------------------------------------------------

start: mov ax,Data
mov ds,ax