Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: Writing sma...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 4573 of 4729
Post > Topic >>

Re: Writing small .COM executables

by Frank Kotler <spamtrap@[EMAIL PROTECTED] > Mar 15, 2008 at 10:02 PM

Alex Buell wrote:
> I've just noticed that when I use buffers in my COM executables, they
> take up space, leading to wasted space when stored. From what I
> remember years ago that there were ways of reducing the footprint the
> executables takes up on storage media by allocating from elsewhere. How?

Well... assuming we're talking about "dos .com" and not Common Object 
Module "COM" (thanks a pantload, Microsoft!), and assuming we're talking 
about  Nasm, put your uninitialized data in "section .bss", and use 
"resb/w/d/q/t/o". Fasm uses "rb", etc. but I don't know how to tell it 
"section .bss" - just put it at the end, I guess - that's all Nasm does 
with it. (there are no "segments" in a .com file, it's all just laid out 
flat - Nasm puts ".data" after ".text" and ".bss" at the end - it 
doesn't really "exist", Nasm just defines labels in .bss).

For example, "buf" and "handle" don't take up any space in this file.

Best,
Frank

;------------
org 100h

section .bss
     buf resb 512
     handle resw 1

section .text
     mov si, 80h
     movzx bx, byte [si]
     inc si
     mov byte [si + bx], 0
     inc si

     mov dx, si
     xor cx, cx
     mov ax, 3D02h
     int 21h
     jc exit
     mov [handle], ax

     mov bx, ax
     mov cx, 511
     mov dx, buf
     mov ah, 3Fh
     int 21h
     jc exit
     cmp ax, 511
     jnz exit

     cld
     mov si, buf
     mov dl, 0
     mov cx, 511
top:
     lodsb
     add dl, al
     loop top
     neg dl
     mov [si], dl

     mov dx, si
     mov cx, 1
     mov bx, [handle]
     mov ah, 40h
     int 21h

     mov ah, 3Eh
     int 21h

exit:
     ret
;-----------------
 




 8 Posts in Topic:
Writing small .COM executables
Alex Buell <spamtrap@  2008-03-15 14:03:24 
Re: Writing small .COM executables
Frank Kotler <spamtra  2008-03-15 22:02:10 
Re: Writing small .COM executables
Terence <spamtrap@[EM  2008-03-15 19:21:06 
Re: Writing small .COM executables
Alex Buell <spamtrap@  2008-03-16 07:59:38 
Re: Writing small .COM executables
NoSpam@[EMAIL PROTECTED]   2008-03-16 14:13:35 
Re: Writing small .COM executables
Alex Buell <spamtrap@  2008-03-16 23:18:41 
Re: Writing small .COM executables
NoSpam@[EMAIL PROTECTED]   2008-03-17 13:19:50 
Re: [Clax86list] Writing small .COM executables
Charles Crayne <spamt  2008-03-16 20:53:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:07:56 CDT 2008.