flat assembler
Message board for the users of flat assembler.
Index
> DOS > Masm Differences |
Author |
|
Matrix 13 Sep 2004, 01:17
Jan van de Poll wrote: As a newcomer to FlasAsm and a user of Masm for 20+ years, I had difficulties The best assembler i ever seen you might wanna look at the included examples, and examples on this forum too, there are also documentations on this site if you prefer. by the way, it is very familiar for me, i could write a working program with it for the first time and it was working all right, and is constantly updated, reported bugs getting fixed really fast, new features are often added. MATRIX |
|||
13 Sep 2004, 01:17 |
|
Jan van de Poll 13 Sep 2004, 05:30
Matrix
I appreciate that you may have looked into different assemblers, but this is a first for me. Then to find that what is perfectly legal MASM code is rejected with a very non descriptive error is even more daunting. The samples seem to have a lot of "Masm" directives missing. (That's a good thing). I often re-compile and assemble old code, so for me to change, I have to know exactly what is or is not allowed. I am sure, whomever wrote the assembler, did it to improve on what was available, so without spending days looking at source code someone knows this,and has hopefully documented it. Regards |
|||
13 Sep 2004, 05:30 |
|
Matrix 13 Sep 2004, 08:03
You can setup your own macros, structures in FASM, but
If you 'd read the documentations and search this forum for these kind of questions, and if you have further questions you can open yourself a thread so that way others can help you. If you have very much to convert then you may want to make a few equ - s , macro - s, or at least try to help yourself translating by writing a program to translate the differences that may have been translated similarly. for example i have converted 10kbytes of C-- code into fasm in 2 hours using wordpad - you know : change all. What couldn't have been translated that way was done in the manual way. if you don't understand something i think you should just ask it, and you'll get help. hope the best MATRIX |
|||
13 Sep 2004, 08:03 |
|
silkodyssey 13 Sep 2004, 12:35
Jan van de Poll,
It seems to me that youv've been coding in masm for way too long and have come to accept masm as a standard as far as assemblers go and think that fasm should accept it's "standard" syntax. However fasm is different from masm in a lot of ways and since you're used to masm you would have to take some time to learn fasm and unlearn some masm by looking at fasm examples and reading it's documentation. So it's really up to you now to decide if you want to invest in fasm or go with what you're familiar with because as far as I know masm is still around. _________________ silkodyssey |
|||
13 Sep 2004, 12:35 |
|
Jan van de Poll 13 Sep 2004, 21:16
Silkodessey
I agree , the comfort zone is hard to leave, but don't jump from the frying pan into the fire. I still see nobody answering as to what the benefits are. Regards |
|||
13 Sep 2004, 21:16 |
|
silkodyssey 13 Sep 2004, 22:49
Jan van de Poll,
About the benefits. I think that would depend on what you want to use it for. For instance one of the features of fasm is that it is available for more OSes than masm but if you code only for windows then that isn't really a benefit for you. I can tell you why I like fasm though. It's because it's a simple language by default but can be extended with its powerful macro system, it's one of the fastest assemblers around, it's under intense development and is supported by the author and I enjoy coding with the fresh IDE which is built around fasm. Although fasm can be characterized as a traditional assembler, it has a modern feel to it because it has features that you won't find in other assemblers. Masm on the other hand, like tasm, feels like a relic from the past. I think fasm has a future. I think you must have seen a benefit to using fasm otherwise you won't have tried it. What is it? _________________ silkodyssey |
|||
13 Sep 2004, 22:49 |
|
Jan van de Poll 13 Sep 2004, 23:34
SilkOddyssy
I haven't "tried" it yet. As soon as I threw one of my programs at it, the errors kept coming. I think the biggest drawback to using Fasm is that I simply cannot look at a list of commands and see the syntax. For example: First error was the way I declare my macro's Name Macro body of macro EndM Discovered by reading the samples { and } were used. Also read somewhere that the alternative (as per my way) was allowed. But { } stopped that error. Next Example: Declaring variables seems to vary. I use: Variable1 DW ? Variable2 DW ? Then in the body of my program Mov DX,Variable1 this creates an error :Invalid Operand Come on guy's, surely if you spend that much time developing a tool the way to use the tool is the next most important document. Please dont take this as criticism, as open source software is a gallant effort by all concerned. However to give your efforts the turbo charge it needs then more people have to use it., and some of us are independant and dont like asking questions all the time. Regards _________________ JvdP |
|||
13 Sep 2004, 23:34 |
|
Ralph 14 Sep 2004, 01:48
The main advantage for me is that it is a "flat assembler". It is not geared towards a specific OS or ABI or anything like that. As such, the following will assemble just fine without "org 100h" or any kind of other directives:
Code:
mov dx,variable1
variable1 dw ?
I'm not sure why you got errors, but try to assemble that. This makes it easy to quickly test things, integrate fasm into other projects, port it, make it produce a different executable format, etc. And it just makes the whole assembler seem less restrictive and more powerful to me. I found the fasm manual (available here http://flatassembler.net/docs.php?article=manual) to be quite sufficient for getting a hang of the basic syntax. The main differences are in the macros. The rest of the syntax is pretty similar to other assemblers. For example, the following are all valid in fasm: Code: mov dx,offset variable1 mov dx,variable1 mov dx,[variable1] mov dx,word [variable1] mov dx,word ptr variable1 etc.. Speaking of macros, there are hundreds available that will make fasm a bit more like other assembles, including invoke and other masmish things. |
|||
14 Sep 2004, 01:48 |
|
JohnFound 14 Sep 2004, 04:13
Hi, Jan van de Poll.
More detailed answer: 1. Documentation: There is manual in every package of FASM. "fasm.pdf" in windows gui version (fasmw) and "fasm.txt" in every other version. This manual explains pretty comprehensive all FASM features. The main lack of this manual is lack of practical examples, but there are a lot of examples in "examples" directory of the package - note, that every package contains diferent examples: linux package contains linux examples, windows package contains windows examples, and so on. Also you can ask here in the message board for help about this or that feature that is not clear enough. 2. The FASM manual is translated in .chm file and appended to the Fresh package ( http://fresh.flatassembler.net ) you can try it if you prefer RAD IDE. (But, my suggestion for beginer is FASMW package.) 3. Main FASM syntax specifics: 3.1. FASM syntax is based partially on TASM IDEAL mode. The main difference from MASM is using of labels in the instructions: (Examples in the above examples of Ralph are possible, but not all of them are "native" FASM - some of them need some macro and constants definitions) Here is the native FASM syntax: Code: mov eax, something ; Will move in eax the address of the symbol, or numeric value of the symbol or numeric constant. In all cases, some immediate number goes to eax. mov eax, [something] ; Moves in eax the memory content from the address in "something". ; it can be number, label, register addressing, etc. In all cases some memory will be readed and loaded in eax. 3.2. Constants: Don't use "EQU" at first. "equ" defines symbolic constants in FASM and its usage is occasional, especially for beginer. Use "=" instead - this is operator that defines numeric constants. 3.3. Macroses: FASM have very simple and very powerfull macro language. Unfortunately, for the one used to MASM syntax, FASM macro language may seems too unusual at the begining. Try to forget for a moment what you know about macroses and things will goes faster. My suggestion: In the begining, simply don't try to write complex macroses. There are already a lot of usefull macroses around. Simply see the standard FASM macroses supplyed in the packages and search the board for more specific things. 3.4. FASM can compile directly to executable formats (for several OSes). It is not mandatory to use linker (but you still can compile to COFF object file and link it, if you prefer so, or if you want to use third party precompiled libraries) The format of the compiled file depends from the "format" directive in the source. 3.5. FASM compiles very quick. Actually it is one of the fastest assemblers in the world. Read the manual ( fasm.pdf or fasm.txt ) for details and enjoy FASM. Regards. |
|||
14 Sep 2004, 04:13 |
|
pelaillo 14 Sep 2004, 04:46
Cut out the red tape and the syntax is not so different. A few hints:
Code: MASM: FASM: st(1) --> st1 tbyte ptr [esi][1] --> tword [esi+1] byte ptr VarName[ebx*8][-12] --> byte [ebx*8+VarName-12] mov esi,offset MyVar --> mov esi,MyVar mov esi,MyVar --> mov esi,[MyVar] invoke MyFunc,addr MyVar --> lea eax,MyVar invoke MyFunc,eax There are also some macros to do the equivalent syntax for proc...uses...endp and for struct...union...ends and so on. |
|||
14 Sep 2004, 04:46 |
|
Jan van de Poll 14 Sep 2004, 06:12
Thanks for all your suggestions so far.
Here goes. Developing software for 16 bit Dos using a Win2000 machine and UltraEdit. Most of my code is called from Basic PDS7.1 I can run and debug the code using Codeview on the Win2000 machine. I call it with the adresses of Arrays, and or variables by value(BYVAL). All works very well and results in powerfull code that runs trouble free. I am not a prolific user of Macro's unless I need to call functions many times.Old habits die hard The reason for looking at other ?ASM is Flat adressing, elimination of all the pre-amble in each ASM routine. Hopefully faster and cleaner executable code. So I simply used the FASM.EXE that was in the Zip file and replaced my Masm statement: ML /c Dostime.asm ML /c CombCalc.asm ML /c DosMsec.asm BC CalcTest.BAS CalcTest.obj CalcTest.lst /A /E /Fpa /G2 /O /Ot /X /Lr LINK /info @C:\Program1\Combo\CalcExe.RSP With: C:\Program1\FlatAsm\Fasm Dostime.asm C:\Program1\FlatAsm\Fasm CombCalc.asm C:\Program1\FlatAsm\Fasm DosMsec.asm BC CalcTest.BAS CalcTest.obj CalcTest.lst /A /E /Fpa /G2 /O /Ot /X /Lr LINK /info @C:\Program1\Combo\CalcExe.RSP So an example is a routine that I call and returns 1/100 sec's in one long integer. This is the Masm code. .MODEL MEDIUM .486 .CODE PUBLIC DOSMSEC SECS DW ? VALUE DD ? ;--------------------------------------- DOSMSEC PROC FAR PUSH BP MOV BP,SP ;------------ MOV AH,2CH ;After this call INT 21H ;ch= hours ;------------ ;cl= minutes MOV SECS,DX ;dh= seconds XOR AX,AX ;dl= deci secs (1/100's) XOR BX,BX ;DX now saved as seconds XOR DX,DX ;------------ MOV AL,CH ;load the hours MOV BL,60 ;and multiply AX MUL BL ;by 60 to get minutes XOR DX,DX MOV DL,CL ;load the minutes ADD AX,DX ;and add to total sofar ;------------ ;max sofar=(23 x 60)+ 59 = 1439 min. MOVZX EAX,AX ;zero extend AX into EAX reg. MOV ECX,60 ;mult EAX by 60 to get seconds MUL ECX ;in EAX MOV CX,SECS ;restore the seconds XOR BX,BX MOV BL,CH ;and get the full secs MOVZX ECX,BX ADD EAX,ECX ;and add. ;------------ ;max sofar= (1439x60) + 59= 86399 sec MOV ECX,100 MUL ECX ;mult x 100 to prepare for 1/100 sec. XOR BX,BX MOV CX,SECS MOV BL,CL ;restore the 1/100 sec from dos. MOVZX ECX,BX ADD EAX,ECX ;and add to total sofar. ;------------ MOV VALUE,EAX ;place EAX into DD MOV AX,WORD PTR VALUE ;then convert to AX:DX MOV DX,WORD PTR VALUE+2 ;and leave there for calling program. ;------------ POP BP RET 2 ; DOSMSEC ENDP ;----------------------------------------------------------------------------- END So after reading the various txt and samples concluded that I should try: secs dw ? value dd ? ;------------ mov AH,2CH ;After this call INT 21H ;ch= hours ;------------ ;cl= minutes MOV secs,dx ;dh= seconds etc,,,,, Falls over here. Am I overlooking something really simple Regards Wagga Wagga Australia. _________________ JvdP |
|||
14 Sep 2004, 06:12 |
|
Matrix 14 Sep 2004, 07:15
Jan van de Poll wrote: Thanks for all your suggestions so far. Code: ;.MODEL MEDIUM ;.486 ;.CODE ;PUBLIC DOSMSEC ;--------------------------------------- org 256 mainloop: call DOSMSEC ;call dosmsec ; my version call bwritedword call bendline call bkeypressed jz mainloop int 20h DOSMSEC: ; PROC FAR PUSH BP MOV BP,SP ;------------ MOV AH,2CH ;After this call INT 21H ;ch= hours ;------------ ;cl= minutes ;MOV [SECS],DX ;dh= seconds MOV [SECS],DH; Seconds is byte MOV [SEC100],DL; Seconds is byte ; XOR AX,AX ;dl= deci secs (1/100's) ; XOR BX,BX ;DX now saved as seconds ; XOR DX,DX ;------------ ;MOV AL,CH ;load the hours MOVZX AX,CH ;load the hours ;MOV BL,60 ;and multiply AX ;MUL BL ;by 60 to get minutes MOV BX,60 ;and multiply AX MUL BX ;by 60 to get minutes ;XOR DX,DX ;MOV DL,CL ;load the minutes MOVZX DX,CL ;load the minutes *- i like this better ADD AX,DX ;and add to total sofar ;------------ ;max sofar=(23 x 60)+ 59 = 1439 min. MOVZX EAX,AX ;zero extend AX into EAX reg. MOV ECX,60 ;mult EAX by 60 to get seconds MUL ECX ;in EAX ; MOV CX,SECS ;restore the seconds ??? ; XOR BX,BX ; ??? this is not clear for me ; MOV BL,CH ;and get the full secs ??? ; MOVZX ECX,BX ??? MOVZX ECX,[SECS] ADD EAX,ECX ;and add. ; ahh, finally we have our seconds - Matrix ;------------ ;max sofar= (1439x60) + 59= 86399 sec MOV ECX,100 MUL ECX ;mult x 100 to prepare for 1/100 sec. ; XOR BX,BX ??? again ; MOV CX,SECS ??? again ; MOV BL,CL ;restore the 1/100 sec from dos. ??? again ; MOVZX ECX,BX ??? MOVZX ECX,[SEC100] ADD EAX,ECX ;and add to total sofar. ;------------ ; i have commented these because i want to demonsdtare by writing EAX to screen ; MOV [VALUE],EAX ;place EAX into DD ; MOV AX,WORD PTR VALUE ;then convert to AX:DX ; MOV DX,WORD PTR VALUE+2 ;and leave there for calling program. ; overall comment: ;--------D-212C------------------------------- ;INT 21 - DOS 1+ - GET SYSTEM TIME ; AH = 2Ch ;Return: CH = hour ; CL = minute ; DH = second ; DL = 1/100 seconds ;Note: on most systems, the resolution of the system clock is about 5/100sec, ; so returned times generally do not increment by 1 ; on some systems, DL may always return 00h ;SeeAlso: AH=2Ah,AH=2Dh,AH=E7h"Novell",INT 1A/AH=00h,INT 1A/AH=02h,INT 1A/AH=FEh ;SeeAlso: INT 2F/AX=120Dh ;i think you meant dl when you say sec100 ;MATRIX ;------------ POP BP ret ;RET 2 ; ;DOSMSEC ENDP ; so here is my version, don't even think of me to optimize it, it uses dos, so its useless dosmsec: ; PROC FAR MOV AH,2CH ;After this call INT 21H ;ch= hours MOV [SECS],DH; Seconds is byte MOV [SEC100],DL; Seconds is byte MOVZX AX,CH ;load the hours MOV BX,60 ;and multiply AX MUL BX ;by 60 to get minutes MOVZX DX,CL ;load the minutes ADD AX,DX ;and add to total sofar MOVZX EAX,AX ;zero extend AX into EAX reg. MOV ECX,60 ;mult EAX by 60 to get seconds MUL ECX ;in EAX MOVZX ECX,[SECS] ADD EAX,ECX ;and add. MOV ECX,100 MUL ECX ;mult x 100 to prepare for 1/100 sec. MOVZX ECX,[SEC100] ADD EAX,ECX ;and add to total sofar. ret bkeypressed: ;Beware! Don't call INT 16h with high transmission rates, it won't work! mov ah,1 ;Return: ZF set if no keystroke available int 16h ;ZF clear if keystroke available, AH = BIOS scan code, AL = ASCII character ret ;note: no extended keys bendline: ; ends the line ( adds y loc = 1 x loc = 0 ) mov bx,7 ; returns: AX = 0xE0A ; BX = 7 mov ax,$E0D int 10h mov al,$A int 10h ret bwritedword: ; writes EAX to screen @ x,y (at cursor) mov bx,7 ; returns: EAX,ECX,EDX = undefined ; BX = 7 mov ecx,1000000000 ; if bx= 0 then writes in graphic mode .sroll1: cmp eax,ecx jae .sskip2 .divide: push eax mov eax,ecx mov ecx,10 xor edx,edx div ecx mov ecx,eax pop eax jecxz .sskip jmp .sroll1 ; remove leading zeroes .rolldivide: push eax mov eax,ecx mov ecx,10 xor edx,edx div ecx mov ecx,eax pop eax jecxz .extroll .sskip2: xor edx,edx div ecx .sskip: add al,48 mov ah,0xE int 10h mov eax,edx jecxz .extroll jmp .rolldivide .extroll: ret SECS DB ? SEC100 DB ? VALUE DD ? here you are MATRIX Last edited by Matrix on 14 Sep 2004, 08:28; edited 1 time in total |
|||
14 Sep 2004, 07:15 |
|
Jan van de Poll 14 Sep 2004, 07:39
Matrix
Thanks, I need to chew this over Regards |
|||
14 Sep 2004, 07:39 |
|
Jan van de Poll 15 Sep 2004, 10:05
Matrix
If there is one thing you have done, it is to alert me to the problem of the update of the Dos int21,2c Discovered that the cpu boards I am using only updates about 1/50 sec. I have about 50 of them in the field. Am spending a lot of time reading about various assemblers including Fasm. Once I make the decision there will be no going back Thanks for your help. Regards _________________ JvdP |
|||
15 Sep 2004, 10:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.