汇编程序拒绝接受更多的程序 [英] Assembly program refuses to accept a larger number
问题描述
我正在尝试编写一个将Ulam的猜想应用于数字的程序.我的程序正在运行,但是它拒绝接受数字38836和38838.输入这些数字后,出现错误:再次尝试超出范围.堆栈为256,使用的变量为DW类型.我是组装的新手,所以如果我没有提供适当的信息,或者忽略了一些简单的内容,我深表歉意,但是我非常困惑.我认为这可能与我的问题有关.
I am trying to write a program that applies Ulam's conjecture to a number. I have the program working, however it refuses to accept the numbers 38836 and 38838. When these numbers are entered, it gives me the error: NUMBER OUT OF RANGE TRY AGAIN. The stack is at 256, and the variable used is a DW type. I am brand new to assembly and so I apologize if I did not include proper information, or am overlooking something simple, but I am very stuck. Here is what I think may be relevant to my problem.
DOSSEG
.MODEL SMALL, BASIC, FARSTACK
EXTRN GETDEC:FAR
EXTRN NEWLINE:FAR
EXTRN PUTDEC:FAR
EXTRN PUTSTRNG:FAR
.STACK 256
.DATA
NUM DW ?
CNT DW 0
PROMPT DB 'Enter an integer: '
TOTAL DB 'Number Total: '
FLOWMSG DB 'OVERFLOW '
.CODE
ULAMS:
MOV AX,SEG DGROUP
MOV ES,AX
LEA DI,PROMPT
MOV CX,18
CALL PUTSTRNG
CALL GETDEC
MOV NUM,AX
MOV CNT,0
--->Rest of program cut for brevity<-----
推荐答案
如果GETDEC将输入的值放入16位寄存器AX中,则您无能为力,无法使GETDEC接受一个不包含该数字的数字.不适合16位寄存器.
If GETDEC puts the entered value in register AX, which is a 16-bit register, then there is nothing you can do to make GETDEC accept a number that doesn't fit in a 16-bit register.
您将不得不以其他方式输入如此大量的数字;例如,读取一个字符串并计算它代表的数字.
You'll have to fashion some other way of entering such large numbers; for example, reading in a string and computing the number it represents.
这篇关于汇编程序拒绝接受更多的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!