flat assembler
Message board for the users of flat assembler.

Index > DOS > Done correctly?

Author
Thread Post new topic Reply to topic
Steve



Joined: 10 Sep 2005
Posts: 10
Steve
Hi, I decided to take a stab at a 'Get Keystroke' type program. Right now, it seems like it is completed.

Here is the code:

Code:
org 100h
use16

Main:

mov ah, 9h ; AH = 9h / INT = 21h : Print Text
mov dx, mText ; Move mText into the data register.

int 21h ; Execute 'Print Text' interrupt.

InputCheck:

mov ah, 00h  ; AH = 00h / INT = 16h : Get Keystroke

int 16h ; Get keystroke.

cli ; Disable interrupts.

cmp al, 'y' ; Check if AL holds 'y'.

je Main ; AL holds 'y', time to loop.

cmp al, 'n' ; Check if AL holds 'n'.

jne InputCheck ; AL doesn't hold 'n' so we check again.

jmp Exit ; AL holds 'n' so we jump to Exit.

Exit:

sti ; Enable intterupts again.

int 20h ; Exit interrupt.

mText db 'Press Y(es) to loop or N(o) to exit.$'
    


What can I improve?

I added 'cli' because at the moment I think that it will not wait to check without it. Necessary or should I remove that line?

(Also, if you read this Dex, thanks for that link to the tutorial.)

Thank you,

- Steve
Post 01 Apr 2006, 22:55
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
I would remove it, also i would put a upper and lower case check, just in case of cap lock etc.
Next i would do a program to get users name, age etc and then print it back with a message including there name etc ),
Then try a password input, that asks for password, stores it and loops until they give you the password.
Nice work, just keep writing a simple program a day and before you know it, you will be coding your own OS Wink .
Post 02 Apr 2006, 08:12
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
Steve wrote:
Hi, I decided to take a stab at a 'Get Keystroke' type program. Right now, it seems like it is completed.

Here is the code:

Code:
org 100h
use16

Main:

mov ah, 9h ; AH = 9h / INT = 21h : Print Text
mov dx, mText ; Move mText into the data register.

int 21h ; Execute 'Print Text' interrupt.

InputCheck:

mov ah, 00h  ; AH = 00h / INT = 16h : Get Keystroke

int 16h ; Get keystroke.

cli ; Disable interrupts.

cmp al, 'y' ; Check if AL holds 'y'.

je Main ; AL holds 'y', time to loop.

cmp al, 'n' ; Check if AL holds 'n'.

jne InputCheck ; AL doesn't hold 'n' so we check again.

jmp Exit ; AL holds 'n' so we jump to Exit.

Exit:

sti ; Enable intterupts again.

int 20h ; Exit interrupt.

mText db 'Press Y(es) to loop or N(o) to exit.$'
    


What can I improve?

I added 'cli' because at the moment I think that it will not wait to check without it. Necessary or should I remove that line?

(Also, if you read this Dex, thanks for that link to the tutorial.)

Thank you,

- Steve


hi,

Code:
mov ah, 00h  ; AH = 00h / INT = 16h : Get Keystroke

int 16h ; Get keystroke.

cli ; Disable interrupts.

cmp al, 'y' ; Check if AL ho
    


this is what we say, inconsistent, you disable the interrupts, then call interrupt 16h to read the keyboard.
Post 02 Apr 2006, 12:42
View user's profile Send private message Visit poster's website Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca
i use int 16h ah=0 alot and i never use cli,it has allways work for me.
i think you can remove the jmp Exit to unlese you put more code or data
between the jmp Exit and Exit:
and you can modify the data to:
Code:
mText db 'Press Y(es) to loop or N(o) to exit.',13,10,'$' 
    

to show the text in a new line every time.
and i think use16 is not necesary since fasm default format is 16bit
binary flat.the org 100h directive makes fasm save the output file
with com extension....although use16 dos not affect the code in this
program.
Post 02 Apr 2006, 20:04
View user's profile Send private message 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 YouTube, Twitter.

Website powered by rwasa.