flat assembler
Message board for the users of flat assembler.

Index > DOS > Newbie information on com programming

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 13 Sep 2005, 07:25
Heya, i am new to fasm asm, i played with hla, and win32 masm, but decided that i wanted to cover real asm, well 100% not lots of macros etc.

so i went to the most talked about multi os assembler (fasm)
unfortunatly i cannot find any tutorials for fasm com programming.

me and a friend are learning together, and are currently lost, i have found some tutorials, but they don't work,(A86 tutorials).

so i was wondering if you could give me some information

the skeleton of a com project, ie. how does it layout with data etc

in masm, on the win32 side it was .data etc

what i intend to end up with is a simple program that works like so:

1: asks the user for input
2: compares that input to a predefined value
3: if the value matches, send exit message (congratulations) then hit exit code
4: if the user doesn't enter the correct character, jump back and start again, after displaying a error message stating try again.

if anyone has a good source of tutorials, for fasm/com programming. please inform me!

thank you
Damnation
Post 13 Sep 2005, 07:25
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Sep 2005, 10:03
if you mean dos com executable, a fasm package of dos version has such example. com format is extremelly easy: it has to start from 100h, and will start also from 100h after loading. some dos function needed to be known to provide input/output.
-- ---------
here is a (stupidiest?) example - maybe will be helpful Wink


Description:
Download
Filename: doscom1.1.zip
Filesize: 1.6 KB
Downloaded: 616 Time(s)


_________________
UNICODE forever!


Last edited by shoorick on 13 Sep 2005, 14:03; edited 1 time in total
Post 13 Sep 2005, 10:03
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 13 Sep 2005, 13:29
Code:

; fasm example of writing 16-bit COM program

        org     100h                    ; code starts at offset 100h
        use16                           ; use 16-bit code

    call printz
    db 'Guess a number: ',0
    mov ah,1
    int 21h
    cmp al,[tt]
    je  @F
    call printz
    db 13,10
    db 'Wrong! Number was '
tt  db '5 !',0
    xor ah,ah
    int 16h
        int     20h
@@:
    call printz
    db 13,10,'Right!',0
    xor ah,ah
    int 16h
        int     20h
    
printz:
    pop si
    mov ah,0Eh
@@:    
    lodsb
    or al,al
    jz  @F
    int 10h
    jmp @B
@@:
    jmp si    
    


omg, please explain it all, i am a ultra newbie. i have no idea what it doesm i understand stuff like jmp etc. but jmp @b wheres B ?
jmp si? wheres si.

please comment it to hell IF you want.

thanx adam.

_________________
Regards
Damnation
Post 13 Sep 2005, 13:29
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Sep 2005, 14:07
example upward is already commented - download new version. you have to read fasm manual about labels. also you have to read basics about cpu, addressing modes, dos/bios, etc. - a lot of all. si - 16-bit register in cpu. (as well as esi - si, extended to 32-bits) regards!
Post 13 Sep 2005, 14:07
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Sep 2005, 14:24
i would strongly recommended that you will run this program under 16-bit debugger and check each step, esp. attention to al and si registers and to flags. it will not run to long Wink regards!
Post 13 Sep 2005, 14:24
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 13 Sep 2005, 14:46
fasm manuals? are they in with the assembler or do i need to download them off the site?

basics on the cpu ? p4 manuals will they do?
omg i forgot about esi, lol what a twonk i am.

p.s. my fingers hurt, i stabbed them at work, whilst i was cutting up meat, (butcher) damn those knives are sharp, i swear i hit the bone.
Post 13 Sep 2005, 14:46
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Sep 2005, 14:52
sleep a little, then start tomorrow - cpu made by men, so other man can understand everything, just not whole at once Wink
each fasm package has pdf or txt - this is exactly that manual i told.
Post 13 Sep 2005, 14:52
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 13 Sep 2005, 16:18
i'll give the docs a start later, bloody gf wanted somthing, and knocked the cuts on my fingers, gits started to bleed again, i swear i have thin blood, as they seem to refuse to stop bleeding.
but thank you all so far, for all this help ok, so in reality, its only smal pointers. but damn is it helpful.

thank you once again.

_________________
Regards
Damnation
Post 13 Sep 2005, 16:18
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 14 Sep 2005, 05:29
let your hand heal first, just read a while! i'm not a programmer by job, so, most progs i'm 'writing' in the head while going to work or back by bus. regards!

ps. i like slow buses Wink
Post 14 Sep 2005, 05:29
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 15 Sep 2005, 05:03
Lol, well my hands partially healed, one of the cuts is on the knuckle below the knuckly u hit people with, (large one middle one) i keep knocking it, and it keeps bleeding so far this morning it hasn't.
but the other cut omfg it hurts, i took a layer of skin off, like when u doo an horrid graze. so when i put my hands in water, or i pick up bacon to cut up, or i get blood on my hands from cutting live/kidney, it stings like hell.

but thanx for all the advice, gf worked me like mual yesterday, so hopefully tonight i'll get the peace to read.

but once again thanx
Post 15 Sep 2005, 05:03
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 23 Sep 2005, 15:30
well decard sent me to his site and i've looked at that and learnt a lil, i've looked at your code got stumped on lodsb, but i took a look at my "The art of assembly language", and found the lods function and found out what it does.

also just toying with the code, i tore it apart, and finally its asking for character input, it wasn't before even though i was putting the correct bios interupts etc.

i messed up somewhere, i am wondering, how do i type, but the character that the person wrote isn't shown?

so i write for example : a
but in the consol is shows : _
still waiting for a character or so the user thinks?

_________________
Regards
Damnation
Post 23 Sep 2005, 15:30
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 23 Sep 2005, 16:09
thank you shoorick for your example, all commented and all. i took it apon myself to try to code my own today, as i am a newbie, i am not ready for the level of simple complexity that your example contained.

fortunatly, due to posts on this forum. reading decards tutorials etc. i've been about to just about manage to code this all by myself : o).

ok its not really anything spectacular, but for a beginner i feel its ok.

Code:
; My first attempt at a text input code.

org 100h
start:

mov ah,9
mov dx, entry_message
int 21h

mov ah,1
int 21h

cmp al, '5'

je correct_answer
   mov dx, wrong_answer_txt
   mov ah, 9
   int 21h
   jmp start

correct_answer:
   mov dx, correct_answer_txt
   mov ah, 9
   int 21h
   int 20h

entry_message db 'Please enter a value: $ '
correct_answer_txt db 13,10,'That Answer was correct', 13, 10, '$'
wrong_answer_txt db 13, 10, 'That answer was incorrect', 13, 10, '$'  
    


any pointers on improvement. or what to attempt next, would be great.

_________________
Regards
Damnation
Post 23 Sep 2005, 16:09
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 24 Sep 2005, 09:05
hi, man!
i'm currently busy - just made "outlook" - i'll answer you later - mb at monday.
send empty email - i'll send you some help. regards!

_________________
UNICODE forever!
Post 24 Sep 2005, 09:05
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 25 Sep 2005, 01:48
int 21,8 will not print the key pressed to the screen.

See HelpPC (no Pentium stuff, though):

ftp://garbo.uwasa.fi/pc/programming/helppc21.zip)


Damnation wrote:


so i write for example : a
but in the consol is shows : _
still waiting for a character or so the user thinks?
Post 25 Sep 2005, 01:48
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 25 Sep 2005, 08:14
thanx man, i will read that doc later as my gf wants on my comp.

_________________
Regards
Damnation
Post 25 Sep 2005, 08:14
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 25 Sep 2005, 13:40
i tried what u posted, and i feel the issue may be the fact u pointed out no pentium stuff, as i use a pentium 4. but then again fresh assembler won't compile it. meh. to the docs.

_________________
Regards
Damnation
Post 25 Sep 2005, 13:40
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 25 Sep 2005, 14:45
ah, after a search on a different subject, well to do with enter key. i found what u meant about int 21h,8

_________________
Regards
Damnation
Post 25 Sep 2005, 14:45
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 26 Sep 2005, 06:07
so, is there success?
Post 26 Sep 2005, 06:07
View user's profile Send private message Visit poster's website Reply with quote
Damnation



Joined: 08 Sep 2005
Posts: 45
Location: England
Damnation 26 Sep 2005, 12:17
yup, i got it to not show the character.
and i got it to exit when the enter key is struck.
next thing to tackle, is to get colour in the dos window, i have no idea how to do this yet. so i guess alot of googling will have to happen.

but so far thank you to all for the help, esp shoorick.

p.s. i didn't cut my hands today at work, they stung when i was preparing lion's of pork for cureing (bacon).
and i came home all stinky, gf is running me a bath because i smell so bad.

_________________
Regards
Damnation
Post 26 Sep 2005, 12:17
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
casey



Joined: 18 Aug 2005
Posts: 35
casey 27 Sep 2005, 04:46
Butchering and programming asm seem a strange combination?

Although I have returned to asm after a six year absence I was
more interested in win32 programming. However I had thought
of translating my old DOS NASM .com programs written with the
IDE NASMIDE into FASM source code.

However unlike fasmw, which downloaded with a nice IDE I could
use to write, assembler and run programs, fasm appears to need
to be run from the DOS command line.

It only works if fasm and the source code are in the same folder.
I guess I have to change the pathways somehow with WindowXP.
Usually this is explained. I did it with NASM and WindowsMe and
then promptly forgot how ...

Also you need some kind of editor that you can enter to write
the source code and than exit to DOS prompt to assembler
and run and then enter again to edit the source again.... a
real pain which is why I liked using NASMIDE.

There should be minimal need to google. I would certainly
explain how to get color text etc. The other common DOS
mode was mode 13h for games. I even have code for a
high res vesa version of mode 13h.

You need to start writing functions that are common to
other programs so you can call them again and again:

call GetNumber
mov bx,ax
call GetNumber
add ax,bx
call Printax

And if the graphics mode 13h things like,

mov [penColor],RED
mov [xpos], 10
mov [ypos],20
mov [width],100
mov [height],50
call DrawLine

and so on... thus building yourself a nice library of useful
functions while you learn asm.

An interesting program might be one to translate NASM DOS .com
source files to their FASM equivalent.

Regards,
John Casey

email: jgkjcasey at yahoo dot com dot au
Post 27 Sep 2005, 04:46
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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.