flat assembler
Message board for the users of flat assembler.

Index > DOS > noob questions

Author
Thread Post new topic Reply to topic
xddxogm3



Joined: 09 Nov 2005
Posts: 12
xddxogm3
I'm new to FASM.
I'm taking an Assembly class based on the book.
Assembly Language and Computer Architecture Using C++ and Java
FASM and the book syntax is similar in some ways, but disimilar in a lot of ways.
For instance the book has automatic input, ouput, and convertions.
example.
dout ;decimal output to screen
aout ;ascii output to screen
din ;decimal input
sin ;string input
from what i have read on FASM, you need to read in each character pressed by the keyboard, then make convertions later.
(1) How do you make a call and ret work in FASM
(2) Can anyone provide a modular example for the following:
(a) read input from keyboard (string, decimal,etc.)
(b) output to display device (string, decimal,etc.)
(c) string conversions to decimal, hex, etc.
This is my attempt to get a module to work, but unsuccessful.

Code:
        org     100h
Main:

        call    display

        int     20h

display:
        mov     ah,9                    ;move instruction 9 (print characters) into ah register
        mov     dx,@m0                  ;move address of string into dx register
        int     21h                     ;executes interupt (print up to 24h)
ret

@m0  db      "Module Test",24h     ;always have a banner               
Post 09 Nov 2005, 21:53
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you must specify more for those funcs. how is the string ended (0 or $)? where it is stored? how is it with buffer size for sin?

To your example: "display" is assembler directive, so you can't use it as label
Post 09 Nov 2005, 22:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
xddxogm3



Joined: 09 Nov 2005
Posts: 12
xddxogm3
Thanks for the fixing the issue with my module.
Is there a list of all reserved words in FASM? I would love to know what I can and can not use. I have the compiler manual and tutorial, but is there anything beyond what is in that documentation?
I'm not sure what you mean with the questions.
I do not have the internal workings of the
dout ;decimal output to screen
aout ;ascii output to screen
din ;decimal input
sin ;string input
These are just given as directives for an Assembly simulator called H1.
As for my strings when they are used I'm usually using a null termination, except it looks like you have to use 24h to terminate the strings in FASM
Another question I have is how would you use prebuilt assembly files in another assembly program? I'm looking for the capability of hacking up someones code, so I can store a specific procedure into one module, then save this module or perhaps a collection of modules on one assembly file, then include it into my file for easy access. similar to header usage in c++

when getting a character from the keyboard, is the input always concidered the ascii value of the key?
i.e.
I wan the person to input a number.
will fasm read it in 25 as the keys pressed '2' and '5' or to be exact ascii hex values of 32 and 35? so would it not also be accurate to say that it would store 32 at one memory address and 35 at another, hopefully sequential or at least mapped together.
I hope that made since to someone. Twisted Evil
Post 09 Nov 2005, 22:06
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
please place empty line between parts, it is easier it read Smile

xddxogm3 wrote:
Is there a list of all reserved words in FASM?

hmmm... you can use documentation (strip all ""ed words from there), or look at sources end of files format.inc, parser.inc, preproce.inc, x86.inc. Problem is that reserved words include instructions, operators, etc. I suggest reading fasm documentation by time.

Quote:

I would love to know what I can and can not use. I have the compiler manual and tutorial, but is there anything beyond what is in that documentation?

hmmm... nothing up-to-date i think. but you have this forum where you can always ask, it's quicker than finding out by yourself Smile

Quote:
..These are just given as directives for an Assembly simulator called H1.

what is that? does it simulate x86 assembly?

Quote:
As for my strings when they are used I'm usually using a null termination, except it looks like you have to use 24h to terminate the strings in FASM.

FASM doesn't know a thing about strings, FASM is assembler and assembler is just another syntax for machine language (opcodes, binary). String convention depends on routine which operates with strings, and for some reason microsoft decided to use string terminated with '$' (24h i think) for their DOS service int 21h / ah=9. They also use null-terminated (ASCIIZ) string elsewhere. So this is matter of DOS.

Quote:

Another question I have is how would you use prebuilt assembly files in another assembly program? I'm looking for the capability of hacking up someones code, so I can store a specific procedure into one module, then save this module or perhaps a collection of modules on one assembly file, then include it into my file for easy access. similar to header usage in c++.

code has to be written to allow this. In fasm, whole source is just one big text file (well, it can be divided into more files and merged with "include" directive). So your routine can access some variable defined elsewhere. But if you know code is written in this way then you can use copy-paste Smile. assembly language doesn't have any restrictions to your code (like forced modularity in object-oriented language like C++), so you can't always do things like that.

Quote:

when getting a character from the keyboard, is the input always concidered the ascii value of the key?...

again, as with string output, it depends on method you use to read input. there is bios service which reads one key, dos service which reads one char from stream (eg. from stdin, eg. from keyboard), dos service which reads data into buffer, etc.
Post 09 Nov 2005, 22:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
xddxogm3



Joined: 09 Nov 2005
Posts: 12
xddxogm3
Quote:
it depends on method you use to read input.

What are the different methods, and were can I find more details on this?

Quote:
what is that? does it simulate x86 assembly?

It is similar in some ways, but alot of the procedures are automated and less involved then what I have seen of real assembly.
This is basically all I know about the version of assembler.
Machine-level Assembler Version 5.0 Copyright (c) 2005 A. J. Dos Reis
Post 09 Nov 2005, 23:15
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
Quote:
I do not have the internal workings of the
dout ;decimal output to screen
aout ;ascii output to screen
din ;decimal input
sin ;string input

you can use debugger to unassemble and see wat they really did.
Post 12 Nov 2005, 07:51
View user's profile Send private message Visit poster's website Reply with quote
xddxogm3



Joined: 09 Nov 2005
Posts: 12
xddxogm3
good point.
i think i will do that then.
thanks.
Post 12 Nov 2005, 20:22
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
What are the different methods, and were can I find more details on this?

you can use DOS service 10 (int 21h / ah=0Ah) http://spike.scu.edu.au/~barry/interrupts.html#ah0a for example, or use any of zounds character input routines and write your own string input handler
Post 14 Nov 2005, 16:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
peter_rk



Joined: 17 Apr 2005
Posts: 13
Location: somewhere in the world?
peter_rk
The reason your program did not work was because one of the variables you tried to use, "display", is a FASM-specific and reserved. In changing the program, I just substituted "display2" for "display." FASM was happy Rolling Eyes , and it let program execution.

Code:
        org     100h
Main:

        call    display2

        mov     AH,8    ;My code, so program
        int     21h     ; stays on screen until keypress

        int     20h

display2:
        mov     ah,9                    ;move instruction 9 (print characters) into ah register
        mov     dx,@m0                  ;move address of string into dx register
        int     21h                     ;executes interupt (print up to 24h)
ret

@m0  db      "Module Test",24h     ;always have a banner
    


Also... I do n't know what you mean by "pre-built" assembly files. But it sounds like you want to include another file. It's pretty easy to do. Go to the part of your pogram where you want to include another file. Then type:

Code:
include 'whatever'
    


Replacing 'whatever' with the file you want to include.
Post 27 Nov 2005, 08:19
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.