flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Im a noob at fasm and need help - keypress detection

Author
Thread Post new topic Reply to topic
computertrick



Joined: 08 Aug 2010
Posts: 1
computertrick 08 Aug 2010, 11:56
Hi, I am new to fasm and i can just about execute a char in boot mode

So i use fasm because i want to make applications that run on boot


I really dont understand how fasm works

i dont think it works like visual basic or c# or c ++ since the code if i do another line of code under one of the lines it does not execute this :S

is fasm's code read backwards or something

i dont understand, and i need help on jump functions and help making a simple press any key to continue app

please note the app i make has to be bootable

also please tell me if windows programming in fasm is just like any other fasm programming Smile

EDIT by DOS386 : enhanced subject and moved from Main to OS Construction

_________________
Da programmer Wink
Post 08 Aug 2010, 11:56
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 08 Aug 2010, 11:59
Code:
;wait for a key
        mov     ah,$10
        int     $16
;e.. i'm weak in this sphere
    
Post 08 Aug 2010, 11:59
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 08 Aug 2010, 13:42
Hello computertrick, welcome to fasm forum.
There are many "Hello World" bootsectors in the OS construction area.
I have recently posted a FAT12 compliant one here...
http://board.flatassembler.net/topic.php?t=11774
There are also many good topics in the DOS section.
Also, use the "Search" button to help find topics...
Post 08 Aug 2010, 13:42
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 08 Aug 2010, 14:20
I just made this for the fun of it:
Code:
format binary as 'img'
org 0x7c00
use16

start:
   cli
   mov       ax,0
   mov       ds,ax
   mov       es,ax
   mov       fs,ax
   mov       gs,ax
   mov       ss,ax
   ; [Edit] Added stack setup
   mov       sp,0x7c00 ; How's that, bitshifter?
   ; [/Edit]
   sti

   mov       si,didnt_do_hw
   call      print_ascii

   .again:
   mov       si,nl
   call      print_ascii
   mov       di,0x500
   call      scan_ascii
   cmp       ax,0
   je        .done
   mov       si,nl
   call      print_ascii
   mov       si,ax
   call      print_ascii
   jmp       .again

   .done:

   cli
   hlt

; al = char
; No output.
; No regs trashed.
print_char:
   push      ax bx
   mov       ah,0xe
   mov       bx,0x7
   int       0x10
   pop       bx ax
   ret

; No input.
; al = ascii char
; ah
get_char:
   mov       ah,0
   int       0x16
   ret

; si = char* buffer
; No output.
; No regs trashed.
print_ascii:
   push      si ax
   .next:
   lodsb
   cmp       al,0
   je        .end
   call      print_char
   jmp       .next
   .end:
   pop       ax si
   ret

; di = char* buffer
; ax = char* buffer
; No regs trashed.
scan_ascii:
   mov       ax,di
   push      ax
   .next:
   call      get_char
   cmp       al,0xd
   je        .end
   stosb
   call      print_char
   jmp       .next
   .end:
   mov       al,0
   stosb
   pop       ax
   sub       di,ax
   cmp       di,1
   je        .null
   ret
   .null:
   mov       ax,0
   ret

; I was going to use this, but turns out, I don't need it.  Oh well...
cmp_ascii:
   push      di si
   lodsb
   mov       ah,byte[di]
   sub       al,ah
   jne       .end
   cmp       ah,0
   jne       cmp_ascii
   .end:
   mov       ah,0
   pop       si di
   ret


didnt_do_hw db 'I didn',"'",'t do my homework.  I went to some random forum and prayed on innocent forummers and had them slave for me, to do my homework... Razz lolzzz',0xd,0xa,0xd,0xa,'Enter a string and I',"'",'ll echo it:',0
nl db 0xa,0xd,0

times 510 - ($ - $$) db 0
dw 0xaa55
    


It's bootable as a boot sector. To test it(the image below), set it as a floppy disk for a VM and boot the VM from the floppy.


Description: Rename to img and boot.

About the message it prints: Hehe, just kidding :p.

Download
Filename: MiniOS.txt
Filesize: 512 Bytes
Downloaded: 293 Time(s)



Last edited by Tyler on 08 Aug 2010, 22:58; edited 1 time in total
Post 08 Aug 2010, 14:20
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 08 Aug 2010, 16:22
Quote:

It's bootable as a boot sector. To test it(the image below), set it as a floppy disk for a VM and boot the VM from the floppy.

or look here(read the four posts - not all the topic):
http://board.flatassembler.net/topic.php?t=11576
http://board.flatassembler.net/topic.php?t=11576&start=15
http://board.flatassembler.net/topic.php?t=11576&start=16
http://board.flatassembler.net/topic.php?t=11576&start=19
Post 08 Aug 2010, 16:22
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 08 Aug 2010, 16:25
You should set the stack pointer to a valid place...
Code:
...
cli
mov ss,ax
mov sp,0fffch ; 0ffffh, minus 2 = last word, minus 1 for alignment
sti
...    
Post 08 Aug 2010, 16:25
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 08 Aug 2010, 20:43
You arent just making an os to show off to your youtube buddies right?
If you are new to fasm please read the entire document on the main page, print it, download it, even read it twice. Then you should have it down. IF you really read it. It should cover a good part of the needed to know knowedge for fasm/os development. After that, The information given to you now will be more clear. Trust me, Im not stupid when i say "It WILL help to read ALL of it, TWICE" because then half of what u want to know, ull already know half of, but this is all coming from a guy who has been in osdevelopment and fasm for 2 years. But u will have a great start if you do what ive recommended.

P.S this is only if you decide you want to make an os and continue making it. Dont know the little things that will get you through, learn it all, you might make somethign better then you thought you were going to make Wink

And im sure you know, that only programs u make will run on boot, remember, dependencies, you have to make your own everything

im sure you knew that tho
Post 08 Aug 2010, 20:43
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.