flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > interesting tweak

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8406
Location: Kraków, Poland
Tomasz Grysztar 29 Jul 2004, 18:37
Very soon, there is already a pre-release in the "IDE development" forum.
Post 29 Jul 2004, 18:37
View user's profile Send private message Visit poster's website Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9 29 Jul 2004, 19:27
some_kind_of_form:(mov eax,0 inc ebx mov eax,[ebx] org 700h mov eax,$)

Hi, Admin how about this?
i am serious.

--
Post 29 Jul 2004, 19:27
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 29 Jul 2004, 19:52
IMO good suggestion, but:
s/some_kind_of_form\:/online_fasm/

(thus replace 'some_kind_of_form:' with 'online_fasm'):
online_fasm(mov eax,0 inc ebx mov eax,[ebx] org 700h mov eax,$)

maybe chaning () to {} too. IMO that's a nice solution - it would enable use of "online" asm where approperiate and dissallow it elsewhere - so one knows where to look for "online errors/typos" Wink
Post 29 Jul 2004, 19:52
View user's profile Send private message Visit poster's website Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9 30 Jul 2004, 00:19
s/form/mechanism

In assembly language, is there some equivalent to C language's function?

i mean something like this
int function_1(int i){
...
return j;}
Post 30 Jul 2004, 00:19
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 30 Jul 2004, 00:42
Quote:
some_kind_of_form:(mov eax,0 inc ebx mov eax,[ebx] org 700h mov eax,$)



Looks too high-level in my opinion. This isn't C! If you want procedures, use the macros to set them up.
Post 30 Jul 2004, 00:42
View user's profile Send private message Visit poster's website Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 30 Jul 2004, 23:06
Privalov wrote:
Very simple to do, just open ASSEMBLE.INC file and find the "instruction_assembler" label (around the line 324), and then instruction
Code:
        jnz     extra_characters_on_line    

5 lines below that label.
By changing this instruction to:
Code:
        jnz     assemble_line    

you will get tweaked fasm version, which will accept such an awful multi-instruction lines like this:
Code:
mov eax,0 inc ebx mov eax,[ebx] org 700h mov eax,$    


I think that there could be a problem with combinations like this:
mov ebx,5 xor eax,6

is fasm able to know if xor is a instruction or a operator?
Post 30 Jul 2004, 23:06
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8406
Location: Kraków, Poland
Tomasz Grysztar 31 Jul 2004, 10:13
For the same reason fasm supports the optional colon charactrer after the "times" directive, because in case of:
Code:
times 4 shl al,1    

the "shl" would be treated as operator, not instruction, so you have to do:
Code:
times 4: shl al,1    


Note that this tweak replaces the error jump, so the added feature works only where that error is applied by standard version.
Post 31 Jul 2004, 10:13
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 11 Sep 2004, 16:59
Octavio wrote:
Privalov wrote:
Very simple to do, just open ASSEMBLE.INC file and find the "instruction_assembler" label (around the line 324), and then instruction
Code:
        jnz     extra_characters_on_line    

5 lines below that label.
By changing this instruction to:
Code:
        jnz     assemble_line    

you will get tweaked fasm version, which will accept such an awful multi-instruction lines like this:
Code:
mov eax,0 inc ebx mov eax,[ebx] org 700h mov eax,$    


I think that there could be a problem with combinations like this:
mov ebx,5 xor eax,6

is fasm able to know if xor is a instruction or a operator?


nice Smile now we have many ways to assemble your code:
- let the crosslinked elements have a copy of the overlapping area - like in scandisk Smile and assemble the instruction xor eax,6 then xor it with 5 and then put it in ebx
- mov ebx,5
xor eax,6
in my opinion it is not a big problem to make a difference in the two,
because xor has 2 parameters as you see it in your code, so if xor has parameters it cannot be a logical operation to mov ebx,5
and by the way, why whould you do such a thing?
just evaluate your constants and you won't have problems like this.

see my code:

Code:
mov ax,$1 ; this puts in 1


and this is a working program

org 100h
mov ax,msg call DOSWRITESTR mov ax,$4c00 int $21
set320x200: mov ax,$13 int $10 ret
set80x25t: mov ax,$07 int $10 ret
DOSWRITESTR: mov DX,AX mov AH,0x9 INT 0x21 ret
msg db 'Is anybody out there?$';

    


hy Privalov,
i think it is not a bad thing, you should also add a switch and/or an option for this in the menu

and there is something about the editor itself, have you seen totalcommander's and norton commander's brief function?
with assembly codes you can write at least 4 times more code onto screen by brief displaying. <= so you should add it to your features list Smile
you know in the menu/options/display/brief: enabled/disabled, define brief width
so you have many ideas now, you can decide which is better / and or more important/useful

MATRIX
Post 11 Sep 2004, 16:59
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 11 Sep 2004, 17:01
ps.: if you really need these in one line : mov ebx,5 xor eax,6
use this piece of code : mov ebx,5 nop xor eax,6

MATRIX
Post 11 Sep 2004, 17:01
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8406
Location: Kraków, Poland
Tomasz Grysztar 11 Sep 2004, 17:12
Even
Code:
mov ebx,5 some_label: xor eax,6    
would be better. Or, as it goes with "times" (my post above), with only a colon separating the instructions.

PS. In fasm you don't have any switches that would affect the result of compilation, that is: the same source should compile always in the same way, no matter which OS port of fasm is compiling it and with what settings (the switches can decide only, whether fasm can actually manage to compile the given source, as they can control memory allocation or passes limit). That's why, for instance, fasm has the directive for choosing output format, instead of command line switch.This is one of the substantial attributes of fasm, and I'm not going to change it.


Last edited by Tomasz Grysztar on 12 Sep 2004, 11:13; edited 1 time in total
Post 11 Sep 2004, 17:12
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 12 Sep 2004, 08:19
>This is one of the substantial attributes of fasm, and I'm not going to change it.
Very Happy great Very Happy
Post 12 Sep 2004, 08:19
View user's profile Send private message Visit poster's website Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx 25 Oct 2004, 20:21
Hello.
Theres a way to use macros in the same line?
I want to use some kind of basic declaration...
Ex:
DECLARE ExitProcess LIB "KERNEL32" ALIAS Exit

Wheres DECLARE is one macro, LIB is other and ALIAS is another one.
Is this possible?

Thanks!

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 25 Oct 2004, 20:21
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 25 Oct 2004, 20:47
No, this won't work with macros Sad
Post 25 Oct 2004, 20:47
View user's profile Send private message Visit poster's website Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx 26 Oct 2004, 12:32
Crying or Very sad
Why, why god why this happen to me .....

Smile

Thanks crc for your answer.

_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 26 Oct 2004, 12:32
View user's profile Send private message Visit poster's website Reply with quote
Zetus



Joined: 03 Jun 2004
Posts: 37
Zetus 15 Sep 2006, 06:44
Thanks))
Post 15 Sep 2006, 06:44
View user's profile Send private message ICQ Number Reply with quote
hidden



Joined: 14 Feb 2007
Posts: 49
hidden 13 Mar 2007, 06:32
Quote:

If bad programmers start abusing the powers you add to FASM, you can just remove the changes from the next version of FASM. Very Happy

Ugh, I can't imagine the horror of wading through a FASM program written on one line. I've done it with a C program that had been reverse compiled and posted on a site (the guy's program wasn't programmed to add white space) and that was miserable, but at least then I had semicolons to tell me where the statements ended.

I like FASM the way it is. There's no point adding stuff that no good programmer will ever use. But it's like I said, if it becomes a problem you can always take it out.

Hek... Smile
It's already few ways to make fasm code unreadable Wink
1 hover research and... somebody's bad dream is real Rolling Eyes
Code:
@ fix rept 1 {
mov.eax fix } rept 1 {
xor.esi fix } rept 1 {
not.ebp fix } rept 1 {
xchg.edi fix } rept 1 {
lea.not fix } rept 1 {
test.r fix } rept 1 {
@ format PE GUI 4.0 mov.eax entry start not.ebp include 'win32a.inc' not.ebp IDM_NEW = 101 not.ebp IDM_EXIT = 102 not.ebp IDM_ABOUT = 901 xor.esi section '.data' data readable writeable mov.eax _class TCHAR 'MINIPAD32',0 xor.esi _edit TCHAR 'EDIT',0 mov.eax _title TCHAR 'MiniPad',0 xor.esi _about_title TCHAR 'About MiniPad',0 xor.esi _about_text TCHAR 'This is Win32 example program created with flat assembler.',0 xor.esi _error TCHAR 'Startup failed.',0 not.ebp wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class xor.esi edithwnd dd ? mov.eax editfont dd ? mov.eax msg MSG mov.eax client RECT not.ebp section '.code' code readable executable not.ebp start: xor.esi invoke GetModuleHandle,0 not.ebp mov [wc.hInstance],eax xor.esi invoke LoadIcon,eax,17 not.ebp mov [wc.hIcon],eax xor.esi invoke LoadCursor,0,IDC_ARROW mov.eax mov [wc.hCursor],eax xor.esi invoke RegisterClass,wc not.ebp test eax,eax xor.esi jz error mov.eax invoke LoadMenu,[wc.hInstance],37 not.ebp invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,144,128,256,256,NULL,eax,[wc.hInstance],NULL xor.esi test eax,eax mov.eax jz error not.ebp msg_loop: not.ebp invoke GetMessage,msg,NULL,0,0 xor.esi cmp eax,1 mov.eax jb end_loop xor.esi jne msg_loop xor.esi invoke TranslateMessage,msg mov.eax invoke DispatchMessage,msg not.ebp jmp msg_loop xor.esi error: xor.esi invoke MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK mov.eax end_loop: xor.esi invoke ExitProcess,[msg.wParam] xor.esi proc WindowProc hwnd,wmsg,wparam,lparam not.ebp push ebx esi edi mov.eax cmp [wmsg],WM_CREATE not.ebp je .wmcreate mov.eax cmp [wmsg],WM_SIZE xor.esi je .wmsize xor.esi cmp [wmsg],WM_SETFOCUS xor.esi je .wmsetfocus mov.eax cmp [wmsg],WM_COMMAND not.ebp je .wmcommand not.ebp cmp [wmsg],WM_DESTROY not.ebp je .wmdestroy mov.eax .defwndproc: mov.eax invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] mov.eax jmp .finish xor.esi .wmcreate: mov.eax invoke GetClientRect,[hwnd],client xor.esi invoke CreateWindowEx,WS_EX_CLIENTEDGE,_edit,0,WS_VISIBLE+WS_CHILD+WS_HSCROLL+WS_VSCROLL+ES_AUTOHSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,[client.left],[client.top],[client.right],[client.bottom],[hwnd],0,[wc.hInstance],NULL mov.eax or eax,eax xor.esi jz .failed mov.eax mov [edithwnd],eax xor.esi invoke CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL mov.eax or eax,eax xor.esi jz .failed xor.esi mov [editfont],eax xor.esi invoke SendMessage,[edithwnd],WM_SETFONT,eax,FALSE xor.esi xor eax,eax mov.eax jmp .finish mov.eax .failed: not.ebp or eax,-1 xor.esi jmp .finish mov.eax .wmsize: xor.esi invoke GetClientRect,[hwnd],client xor.esi invoke MoveWindow,[edithwnd],[client.left],[client.top],[client.right],[client.bottom],TRUE xor.esi xor eax,eax not.ebp jmp .finish xor.esi .wmsetfocus: not.ebp invoke SetFocus,[edithwnd] not.ebp xor eax,eax xor.esi jmp .finish mov.eax .wmcommand: not.ebp mov eax,[wparam] not.ebp and eax,0FFFFh xor.esi cmp eax,IDM_NEW xor.esi je .new not.ebp cmp eax,IDM_ABOUT mov.eax je .about xor.esi cmp eax,IDM_EXIT xor.esi je .wmdestroy xor.esi jmp .defwndproc mov.eax .new: xor.esi invoke SendMessage,[edithwnd],WM_SETTEXT,0,0 mov.eax jmp .finish not.ebp .about: xor.esi invoke MessageBox,[hwnd],_about_text,_about_title,MB_OK not.ebp jmp .finish xor.esi .wmdestroy: not.ebp invoke DeleteObject,[editfont] xor.esi invoke PostQuitMessage,0 not.ebp xor eax,eax not.ebp .finish: not.ebp pop edi esi ebx xor.esi ret mov.eax endp mov.eax section '.idata' import data readable writeable mov.eax library kernel,'KERNEL32.DLL', user,'USER32.DLL', gdi,'GDI32.DLL' xor.esi import kernel, GetModuleHandle,'GetModuleHandleA', ExitProcess,'ExitProcess' xor.esi import user, RegisterClass,'RegisterClassA', CreateWindowEx,'CreateWindowExA', DefWindowProc,'DefWindowProcA', SetWindowLong,'SetWindowLongA', RedrawWindow,'RedrawWindow', GetMessage,'GetMessageA', TranslateMessage,'TranslateMessage', DispatchMessage,'DispatchMessageA', SendMessage,'SendMessageA', LoadCursor,'LoadCursorA', LoadIcon,'LoadIconA', LoadMenu,'LoadMenuA', GetClientRect,'GetClientRect', MoveWindow,'MoveWindow', SetFocus,'SetFocus', MessageBox,'MessageBoxA', PostQuitMessage,'PostQuitMessage' xor.esi import gdi, CreateFont,'CreateFontA', DeleteObject,'DeleteObject' mov.eax section '.rsrc' resource data readable xor.esi directory RT_MENU,menus, RT_ICON,icons, RT_GROUP_ICON,group_icons, RT_VERSION,versions not.ebp resource menus, 37,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu not.ebp resource icons, 1,LANG_NEUTRAL,icon_data xor.esi resource group_icons, 17,LANG_NEUTRAL,main_icon xor.esi resource versions, 1,LANG_NEUTRAL,version xor.esi menu main_menu mov.eax menuitem '&File',0,MFR_POPUP xor.esi menuitem '&New',IDM_NEW xor.esi menuseparator xor.esi menuitem 'E&xit',IDM_EXIT,MFR_END not.ebp menuitem '&Help',0,MFR_POPUP + MFR_END not.ebp menuitem '&About...',IDM_ABOUT,MFR_END not.ebp icon main_icon,icon_data,'minipad.ico' not.ebp versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0, 'FileDescription','MiniPad - example program', 'LegalCopyright','No rights reserved.', 'FileVersion','1.0', 'ProductVersion','1.0', 'OriginalFilename','MINIPAD.EXE' not.ebp }    


Exploit:(Protected Very Happy by 1 wrong simbol Wink )
Code:
open(I,'MINIPAD.ASM');open(O,'>MINIPAD1.ASM');@alt=('mov.eax','xor.esi','not.ebp','xchg.edi','lea.not','test.r');$line='';while(<I>){$_.="\n";s/(('.*')*);.*/$1/;s/[\s\t]+/ /g;s/$/${alt[rand(3)]}/ if(!s/(('.*')*)\x5C.*$/$1/&&length()>1);$line.=" $_ ";}$line=~s/[\s\t]+/ /g;print O "@ fix rept 1 {\n";for(@alt){print 0 "$_ fix } rept 1 {\n"}print O "\@$line}";close(O);close(I);    


I think programmer should decide, does he wont his code to be readable or not, and language should get to him alternatives whatever he's decided. Smile

PS sorry for off topic


Description:
Download
Filename: minipad.asm
Filesize: 5.29 KB
Downloaded: 601 Time(s)

Post 13 Mar 2007, 06:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.