News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

The smallest executable

Started by frktons, January 17, 2013, 09:29:34 AM

Previous topic - Next topic

nidud

#15
deleted

hutch--

 :biggrin:

> Hutch barks at me every time - but, he probably likes you more than me

Yeah yeah, teach people bad habits so they write garbage.  :P (But HAY, it was really host stuff on an i386SX under MS-DOS)

frktons

Quote from: nidud on January 17, 2013, 12:10:02 PM
/MERGE:.data=.text
the AV scanners will love this one   :lol:

QuoteRegarding the Text File Compressor and Scanner I'm collecting
the one thousand PROC I need,

hence the library then

Quote
if it is considered an impossible task it has to mean something

not impossible, but difficult -- if there is a will there is usually a way

Quotethe project is quite complex to manage in Assembly

true

QuoteI'm quite slow

perfection takes time  :P


1] Yes
2] Yes
3] Yes
4] Yes
5] Yes

well I can say I couldn't agree more  :lol:
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

frktons

Well, I tried Dave's suggestion, but something went wrong.

.data
    windowSize SMALL_RECT <0,79,0,24>
    bufferSize COORD      <80,25>
    startPoint COORD      <0,0>


so I got rid of these code:


    mov windowSize.Left, 0
    mov windowSize.Right, 79
    mov windowSize.Top, 0
    mov windowSize.Bottom, 24

   

    mov bufferSize.x, 80
    mov bufferSize.y, 25


    mov startPoint.x, 0
    mov startPoint.y, 0


But the console is displayed black, with nothing inside.  :icon_rolleyes:
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

from the movie "Mission Impossible II"
QuoteThis isn't Mission Difficult, it's Mission Impossible. "Difficult" should be a walk in the park for you.

the order for SMALL_RECT members is Left, Top, Right, Bottom   :P
windowSize SMALL_RECT <0,0,79,24>

put this one in uninitialized data - it will be filled with 0's
startPoint COORD      <>

frktons

Quote from: dedndave on January 17, 2013, 12:51:56 PM
from the movie "Mission Impossible II"
QuoteThis isn't Mission Difficult, it's Mission Impossible. "Difficult" should be a walk in the park for you.

the order for SMALL_RECT members is Left, Top, Right, Bottom   :P
windowSize SMALL_RECT <0,0,79,24>

put this one in uninitialized data - it will be filled with 0's
startPoint COORD      <>

I suspected it, about the walk in the park I mean  :lol:

Yes Master Dave, that's the correct order. Anyway, and I suspected it
as well, no gain at all in the exe size: still 2,560 bytes.
But at least it works again  :P
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

#21
well - each section is allocated in 512 byte chunks, as i recall
so, you have to get down to the next 512-byte step to notice an improvement

that line was from the character played by Anthony Hopkins
it wasn't the greatest movie, but he's always good
not as great of an actor as everyone may say - he's a bit one-dimensional, actually
i still like him
he made a good Hannibal - lol

frktons

Quote from: dedndave on January 17, 2013, 01:13:14 PM
well - you each section is allocated in 512 byte chunks, as i recall
so, you have to get down to the next 512-byte step to notice an improvement

that line was from the character played by Anthony Hopkins
it wasn't the greatest movie, but he's always good
not as great of an actor as everyone may say - he's a bit one-dimensional, actually
i still like him
he made a good Hannibal - lol

That was my suspect  ;)
I like Anthony Hopkins as well, a nice English styled actor  :t
and yes He is a bit one-dimensional
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

jj2007

.data?
windowSize SMALL_RECT <>
windowRSize RECT <>
.code
   mov windowSize.Left, 127   ; 9
   m2m windowSize.Left, 127   ; 11
   add windowSize.Left, 127   ; 8

   mov windowRSize.left, 127   ; 10
   m2m windowRSize.left, 127   ; 8
   add windowRSize.left, 127   ; 7
;)

dedndave

    .data
windowSize SMALL_RECT <0,0,79,24>  ;8
bufferSize COORD      <80,25>      ;4


total clock cycles = 0

;)

sinsi

Quote from: dedndave on January 17, 2013, 05:32:10 PM
    .data
windowSize SMALL_RECT <0,0,79,24>  ;8
bufferSize COORD      <80,25>      ;4


total clock cycles = 0

;)
If they don't change then put them in .code
Of course, some APIs will expect to write to it...
🍺🍺🍺

frktons

Quote from: jj2007 on January 17, 2013, 05:17:23 PM
.data?
windowSize SMALL_RECT <>
windowRSize RECT <>
.code
   mov windowSize.Left, 127   ; 9
   m2m windowSize.Left, 127   ; 11
   add windowSize.Left, 127   ; 8

   mov windowRSize.left, 127   ; 10
   m2m windowRSize.left, 127   ; 8
   add windowRSize.left, 127   ; 7
;)

Thanks Jochen, good to know :t

Quote from: dedndave on January 17, 2013, 05:32:10 PM
    .data
windowSize SMALL_RECT <0,0,79,24>  ;8
bufferSize COORD      <80,25>      ;4


total clock cycles = 0

;)

Yes Dave, the most compact and fast should be like that.  :biggrin:

Quote from: sinsi on January 17, 2013, 05:52:27 PM

If they don't change then put them in .code
Of course, some APIs will expect to write to it...

Don't understand why to put them in .code.  ::)
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

if you merge sections at link-time, the advantage of putting it in the code section is gone
but, the idea is to reduce one section so that the 512-byte step is met

if you spend time on the code, you can probably get the EXE down to 1.5 kb   :P

almost everything you had in the .DATA section (except for the string) could be an EQUate
.data

ConTitle  db " -----------   **  Extended ASCII chart displayable characters  **  ----------", 0
PtrConTitle DWORD ConTitle + 17  ; Points to "  Extended..." part of ConTitle

NewProcSize DWORD FromPoint - ToPoint

inpbyte   DWORD  1

;----------------------------------------------------------------------
; ASCII chars to draw a simple box
;----------------------------------------------------------------------

    TopLeft      db   218
    TopRight     db   191
    BottomLeft   db   192
    BottomRight  db   217
    HorizLine    db   196
    VerticLine   db   179

;----------------------------------------------------------------------

    Unit     BYTE One
    Ten      BYTE Space
    Hundred  BYTE Space
    EndOfTask  BYTE 0

    AsciiCode  DWORD 205F2000H  ; 4 bytes = 1 CHAR_INFO
                                ; char 1 White on Magenta Attribute


your string is not modified, as it exists in .DATA
so, you could take sinsi's suggestion....
put the string and the structures we mentioned in the .CODE section
that would eliminate the .DATA section, altogether
you cannot modify data that you place in the .CODE section
at least, not without changing the section attribute - probably not a good practice

the .DATA? section consumes no space in the EXE, other than the entries to create the section   :P

after that, there are several little things, here and there
look at the disassembled code to see how many bytes things use
    lea  eax, ConsoleScreen
    add  eax, TitleStartPoint

    mov     eax,offset ConsoleScreen+TitleStartPoint

frktons

We are moving aside and far away from my first intention,
that was to know something about switches and parameters
used by assemblers/linkers to reduce the size of an executable.

When I created this small program a couple of years ago, it was
a challenge to reduce 12k size of a prog and its file, to something
less, and the result was a prog that can be assembled and linked
in 2.5K, which means about 80% less than the original.

But we are now in the compressor time so let's move forward and see
if we can shrink it from 2.5K to 2K or less.

Another nice deviation that stays inside the "compressing matter"
anyway.  :lol:
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

still, these should be made into EQUates - no need for all that data
PtrConTitle DWORD ConTitle + 17  ; Points to "  Extended..." part of ConTitle

NewProcSize DWORD FromPoint - ToPoint

inpbyte   DWORD  1

;----------------------------------------------------------------------
; ASCII chars to draw a simple box
;----------------------------------------------------------------------

    TopLeft      db   218
    TopRight     db   191
    BottomLeft   db   192
    BottomRight  db   217
    HorizLine    db   196
    VerticLine   db   179

;----------------------------------------------------------------------

    Unit     BYTE One
    Ten      BYTE Space
    Hundred  BYTE Space
    EndOfTask  BYTE 0

    AsciiCode  DWORD 205F2000H  ; 4 bytes = 1 CHAR_INFO
                                ; char 1 White on Magenta Attribute

the first one, you have already done - you can probably get rid of it

it's also likely to reduce the code size
    mov     al,TopLeft
    mov     [edx],al

as an EQUate...
    mov byte ptr [edx],TopLeft