flat assembler
Message board for the users of flat assembler.

Index > Main > function get_number

Author
Thread Post new topic Reply to topic
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu
hello,

i wrote a function to input a number with max. 2 chars like 99 but with one char, too... I didn't translate the comments in english yet, but I'll say you, what it does:

It write "Number:" on the screen and then you may input your number...
If you press ENTER the input ends... then it gives the number in decimal in CX... On this way you may examply get the number of sectors to read in an OS or so on... Here it is:


Code:
;*********************************
;get_number
;input: ---
;output: cx enthällt die zahl
;Diese Funktion ließt eine Zahl in CX von der Tastatur
;*********************************
get_number:
push bx
push axx
push dx
mov al,0x4E
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x75
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x6D
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x62
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x65
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x72
mov bl,0x07
mov ah,0x0E
int 10h
mov al,0x3A
mov bl,0x07
mov ah,0x0E
int 10h
xor cx,cx
;einerstelle abfragen
mov ax,0x0000
int 0x16
cmp ah,0x1C
jz end_get_number
dec ah
call change_to_0
add cl,ah
mov bl,0x07
mov ah,0x0E
int 10h
;zehnerstelle machen
mov ax,0x0000
int 0x16
cmp ah,0x1C
jz end_get_number
dec ah
call change_to_0
mov bl,0x0A
mov dx,ax
mov ax,cx
mul bl
mov cx,ax
mov ax,dx
add cl,ah
mov bl,0x07
mov ah,0x0E
int 10h
end_get_number:
mov si,break
call putstr
pop dx
pop ax
pop bx
ret
change_to_0:
cmp ah,0x0A
jz change
change_back:
ret
change:
mov ah,0x00
jmp change_back    
    


much luck and fun with it...

JOACHIM NEU
Post 02 Apr 2004, 17:13
View user's profile Send private message Visit poster's website Reply with quote
The dead



Joined: 27 Jan 2004
Posts: 13
The dead
This works
Post 03 Apr 2004, 11:42
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.