hey yall
i cant seem to get this converting a string to go into the single digit ,,i mean instead of pick a number (1) (2) etc i have to use higher numbers like (71) (72) etc ..
is there a way to do this without converting it ?
thanks
[ORG 0x100]
mov ah, 9 ; Print "something"
mov dx, strchoose ;
int 0x21 ;
MainLoop:
mov ah, 9 ; Print "something"
mov dx, strinput ;
int 0x21 ;
mov ah, 0xA ; Input String
mov dx, buf ;
int 0x21 ;
call StrToDec ; This function Converts the input string into a number, AL=Result
cmp al, 71 ; Compare AL with the number you choose
je Lblwinxp
cmp al, 72
je Lbldos
cmp al, 73
je Lblrestore
cmp al, 74
je Lblreboot
jmp MainLoop
Lblwinxp:
mov ah, 9 ;
mov dx, strone ;
int 0x21 ;
jmp MainLoop ;
Lbldos:
mov ah, 9 ;
mov dx, strtwo ;
int 0x21 ;
jmp MainLoop ;
Lblrestore:
mov ah, 9 ;
mov dx, strthree ;
int 0x21 ;
jmp MainLoop ;
Lblreboot:
mov ah, 9
mov dx, strfour ;
int 0x21 ;
mov ax, 0x4C00 ; Terminate program
int 0x21 ;
strchoose db 10,13
db ' PLEASE CHOOSE ONE',10,13
db '(71)WINDOWS XP',10,13
db '(72)DOS',10,13
db '(73)RESTORE WINDOWS XP',10,13
db '(74)REBOOT $',10,13
strinput db 10,13,'TYPE THE NUMBER: $'
strone db 13,10,' 71 $'
strtwo db 13,10,' 72 $'
strthree db 13,10,' 73 $'
strfour db 13,10,' 74 $'
; The keyboard input buffer
buf:
max db 3
count db 0
inpdata db 0,0,0
; Convert the string inpdata to a number and store the result in AL
; Input parameters: None
; Return value: AL = Number
StrToDec:
mov dl, [inpdata] ; Get the first character and
sub dl, '0' ; convert it into a value
mov al, dl ; AL = 10 * value
mov bl, 10 ;
mul bl ;
mov dl, [inpdata+1] ; Get the second character and
sub dl, '0' ; convert it into a value
add al, dl ; AL = AL + value
retn