【发布时间】:2014-10-21 12:05:18
【问题描述】:
我似乎碰壁了,找不到任何关于这个的例子。我需要将 ascii 字符转换为数字,即用户键入150 + 123,所以我必须读取 ascii 中的第一个数字,然后通过从每个数字中减去 0 将其转换为 dec,但问题就在这里。我不知道如何从这些数字中实际创建一个数字,因为用户可以输入 1 位或 5 位。请忽略代码中的外国 cmets。谢谢
.model small
.stack 100h
.data
prompt1 db "Please enter an action: ", 10, 13, "$"
prompt2 db "Answer: ", 10, 13, "$"
newline db 10, 13, '$'
buffer db 255 ; Denotes the number of maximal symbols hope
sizeread db 0 ; It will be available on how many characters scanned
buffer_data db 255 dup (?) ; It will be hosted on-line scanned data to fill 255 characters $
.code
start:
mov dx, @data ;
mov ds, dx ;
print_prompt:
mov ah, 9
mov dx, offset prompt1 ; Messages placed in the DX register address
int 21h ; welcome petraukimą
ret
input:
mov ah, 0Ah
mov dx, offset buffer
int 21h
ret
number:
xor bx,bx
xor ax,ax
mov al, 10 ;set al to 0 so i can MUL
mov cx, 5
loopstart: ;start the cycle
cmp [buffer_data+bx], ' ' ;check if I reached a space
je space ; jump to space (the space func will read the + or - sign later on)
mov bx, [bx+1] ; bx++
;Now i got no idea how to go about this....
space:
end start
【问题讨论】: