我已经编写了一半的程序。问题是我不知道如何编写数学运算部分的m
代码n (m^n)
。那么,对我这个初学者有什么建议吗?
.MODEL SMALL
.DATA
greet db 13,10, "Welcome to Simple Calculator: Raise m to the power n. $"
msg1 db 13,10, 0AH,0DH,"Please enter integer (m:-99 to 99): $"
m db 3,4 dup(?)
msg2 db 10,13, 0AH,0DH,"Please enter power (n:1 to 9): $"
n db 3,4 dup(?)
total db 10,13, "Answer: $"
.CODE
START:
mov ax, seg greet
mov ds, ax
mov dx, offset greet
mov ah, 09h ;Display message
int 21h
mov ax, seg msg1
mov ds, ax
mov dx, offset msg1
mov ah, 09h
int 21h ;Print a message
mov ah, 0ah
mov dx, offset m
int 21h ;Get 'm' value
n_POWER:
mov ax, seg msg2
mov ds, ax
mov dx, offset msg2
mov ah, 09h
int 21h ;Print a message
mov ah, 0ah
mov dx, offset n ;Get 'n' value
int 21h
mov ax, m
mov n, ax
mul ax, n
mov total, n
finish:
mov ah, 09h ;Display message
int 21h
mov ax,4c00h ;Return control to DOS
int 21h
end start
另外,我怎样才能从用户那里得到负面的输入(例如-99
)?