flat assembler
Message board for the users of flat assembler.
Index
> DOS > reduce COM |
Author |
|
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
|
|||||||||||
18 Dec 2003, 11:51 |
|
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).
|
|||
18 Dec 2003, 13:52 |
|
Perseus 19 Dec 2003, 07:32
only a few bytes(1B or 2B) would be adequate
|
|||
19 Dec 2003, 07:32 |
|
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. |
|||
19 Dec 2003, 09:19 |
|
vid 19 Dec 2003, 20:14
and this too
mov cx,0ffffh xor cx,cx dec cx maybe i'll post some more later. |
|||
19 Dec 2003, 20:14 |
|
Perseus 24 Dec 2003, 13:37
this don´t reduce COM or yes?
|
|||
24 Dec 2003, 13:37 |
|
vid 24 Dec 2003, 21:20
oh yes, you are right . I was fooled from using 32bit code with 32bit constants. Sorry
|
|||
24 Dec 2003, 21:20 |
|
Perseus 25 Dec 2003, 09:06
It is said it is posible next optimalization.
|
|||
25 Dec 2003, 09:06 |
|
JohnFound 25 Dec 2003, 16:44
Perseus wrote: 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. |
|||
25 Dec 2003, 16:44 |
|
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.
|
|||
25 Dec 2003, 18:03 |
|
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 ? |
|||
15 Feb 2004, 06:41 |
|
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 |
|||
23 Oct 2004, 16:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.