flat assembler
Message board for the users of flat assembler.

Index > DOS > reduce COM

Author
Thread Post new topic Reply to topic
Perseus



Joined: 18 Dec 2003
Posts: 22
Location: Czech republic
Perseus 18 Dec 2003, 11:51
Hi,
I need reduce this code COM have been less than 141B. Is it posible? I don't know how.
Do you help me?
Thanks


Description:
Download
Filename: ul4prelozenaDoAJ.asm
Filesize: 1.46 KB
Downloaded: 915 Time(s)

Post 18 Dec 2003, 11:51
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 18 Dec 2003, 12:19
Perseus wrote:
Hi,
I need reduce this code COM have been less than 141B. Is it posible? I don't know how.
Do you help me?
Thanks


As long as the .com file is actually 140bytes long, it is possible. Wink
Maybe you can reach some size optimization, but IMHO only a few bytes, because the program is small enough and at first glance is written fairly optimal.

Regards
Post 18 Dec 2003, 12:19
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 18 Dec 2003, 13:52
Perhaps he was assembling it usign NASM - because "step" and "part" labels are not followed by colon, and this has to be fixed for FASM. And when assembled with NASM, it is truly 141 bytes long (anyway in this case the difference you get thanks for FASM's multi-pass optimization is not much).
Post 18 Dec 2003, 13:52
View user's profile Send private message Visit poster's website Reply with quote
Perseus



Joined: 18 Dec 2003
Posts: 22
Location: Czech republic
Perseus 19 Dec 2003, 07:32
only a few bytes(1B or 2B) would be adequate
Post 19 Dec 2003, 07:32
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 19 Dec 2003, 09:19
Perseus wrote:
only a few bytes(1B or 2B) would be adequate


OK, this will reduce the size to 138 bytes:
Code:
;        push cx                         ; test even
;        shr cl,1
;        pop cx
;        jnc even

        test cx, di  ; di is always 1 here
        jz   even
    


Regards.
Post 19 Dec 2003, 09:19
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 19 Dec 2003, 20:14
and this too
mov cx,0ffffh

xor cx,cx
dec cx

maybe i'll post some more later.
Post 19 Dec 2003, 20:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Perseus



Joined: 18 Dec 2003
Posts: 22
Location: Czech republic
Perseus 24 Dec 2003, 13:37
this don´t reduce COM or yes?
Post 24 Dec 2003, 13:37
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Dec 2003, 21:20
oh yes, you are right Embarassed . I was fooled from using 32bit code with 32bit constants. Sorry
Post 24 Dec 2003, 21:20
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Perseus



Joined: 18 Dec 2003
Posts: 22
Location: Czech republic
Perseus 25 Dec 2003, 09:06
Question It is said it is posible next optimalization.
Post 25 Dec 2003, 09:06
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 25 Dec 2003, 16:44
Perseus wrote:
Question It is said it is posible next optimalization.


Hm, if you ask isn't it possible to make another optimizations, I think that you have to optimise algorithms, not instructions. You can try to make some diferent setting of the palette without this data table at the end. And to try to optimize the algorithm for line drawing. But this is work that should be made by you.

Regards.
Post 25 Dec 2003, 16:44
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 25 Dec 2003, 18:03
JohnFound is right, this is usualy best way with that you can refuce size by cca 80% on instruction - optimized code.
Post 25 Dec 2003, 18:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog 15 Feb 2004, 06:41
My computer always starts a .com in video mode 3
and I've seen lots of demo's that assume Vmode3 on startup.
You could eliminate all the get/save Vmode stuff at the start,
and end with MOV AX,3 INT 10h which saves 4 bytes or something...?

Then, my computer always starts with CL=0xFF & CH=0 so
DEC CH
makes CX=0xFFFF and saves a byte from your
MOV CX,-1
stuff.

That's kinda a cool example.....
Is it a free bee that I can include in my
free ware example Fasm help package thingie ?
Post 15 Feb 2004, 06:41
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 23 Oct 2004, 16:29
Code:
; i could do something with it, its now 127 bytes MATRIX
org 256
;        mov ah,0fh
;        int 10h
;        cbw
;        push ax
        mov al,13h
        int 10h

        les di,[bx]
        std
;        cwd
;        xor bx,bx
        mov cx,0ffffh
        mov si,diff+8
        ;mov es,[si]
step:   add dh,[si]
        add cx,[si-2]
part:   mov ax,1010h
        int 10h
        inc bx
        test bl,03fh
        jnz step
;       lodsb
        lodsw
        and bh,bh
        jz part

        xor cx,cx
draw:   mov dx,320                      ; main move
        mov di,1                        ; accidental move
        mov ax,cx                       ; ax=abs(x0-x1)..
        mov bl,199                      ; bx=D

        test cl,1
;        push cx                         ; test even
;        shr cl,1
;        pop cx
        jnc even

        mov si,256                      ; odd: down, hp=320, vp=1,-1, K=abs(x0-x1), D=199
        sub ax,192                      ; abs(x0-x1)=abs(256-(64+color))=abs(192-color)
        jnc line                        ; jump for x0>x1 - set
        neg di                          ; else is x0<x1 and  accidental is -1
        neg ax                          ; ax=abs(x0-x1)
        jmp line
even:                                   ; up, hp=-320,1, vp=1,-320, K=x1,199, D=199,x1
        not al                          ; ax=255-cl=K
        neg dx                          ; dx=-320
        mov si,63681                    ; point left below
        cmp al,bl
        jc line                         ; jump for (x1-x0)<199 - set
        xchg dx,di                      ; else exchange hp with vp and K with D
        xchg ax,bx
line:
        mov bp,ax                       ; bp=K, ax=longitudinaly
        mov ch,bl                       ; ch=D+1
        inc ch
cycle:
        mov [es:si],cl
        add si,dx                       ; point=point+hp

;        test bx,1
;        push bx                         ; bx/2
;        shr bl,1
        cmp ax,bx                       ; ? ax>D/2
;        pop bx
        jl continuation
        add si,di                       ; point=point+vp
        sub ax,bx                       ; contin=contin-D
continuation:
        add ax,bp
        dec ch
        jnz cycle

        inc cl
        jnz draw                        ; color from 0 to 255, end at 256(=0)

       mov ah,8
       int 21h

        mov ax,3
        int 10h

        ret

diff    db 0,0,1,1,-1,-1,1,0,0 ;,0a0h
    
Post 23 Oct 2004, 16:29
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.