flat assembler
Message board for the users of flat assembler.

Index > Windows > You guys have been a great help.

Author
Thread Post new topic Reply to topic
2



Joined: 26 Sep 2006
Posts: 92
2 19 Nov 2006, 23:50
Windows isn't as hard as I thought. I looked at examples on this forum
and figured out how to write to files! WIth that info,I pretty much could do
my binary counting the way I did it in DOS.

Code:
n=8
include 'win32ax.inc'
IO:
invoke CreateFile,f,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov [h],eax
p0:

invoke WriteFile,[h],b,n+2,r,0
mov cl,1
mov ebx,n

p1:
dec ebx
mov ch,cl
and cl,[b+ebx]
xor [b+ebx],ch
cmp ebx,0
ja p1

cmp cl,0
je p0

invoke CloseHandle,[h]
invoke MessageBox,HWND_DESKTOP,"binary is written to file","binary",MB_OK
invoke ExitProcess,0
.end IO;
f db 'bin.txt',0
b db n dup 48,13,10,0
h rd 1
r rd 1
    


Seriously,the EXE is small. 1536 bytes! That's smaller than any EXE I even
compiled in C. The Windows version is a bit faster in my system than the DOS. I think this is because NTVDM isn't as good as real DOS. COM files
run better in DOSBOX than that.

_________________
There are 10 kinds of people in the world.
Those who know binary and those who haven't met me.
Post 19 Nov 2006, 23:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20416
Location: In your JS exploiting you and your system
revolution 20 Nov 2006, 12:50
2 wrote:
The Windows version is a bit faster in my system than the DOS
I expect the native 32 bit code is giving you the speedup. NTVDM will impose a slowdown if you are using ports and other such "forbidden" things in the DOS code. But otherwise it is running at natve 16-bit code speed the same as real DOS. Unless of course you count the occasional Win32 interrupts and other background housekeeping things (<1% usually).
Post 20 Nov 2006, 12:50
View user's profile Send private message Visit poster's website Reply with quote
Filter



Joined: 08 Oct 2006
Posts: 67
Filter 20 Nov 2006, 17:14
revolution wrote:
2 wrote:
The Windows version is a bit faster in my system than the DOS
I expect the native 32 bit code is giving you the speedup. NTVDM will impose a slowdown if you are using ports and other such "forbidden" things in the DOS code. But otherwise it is running at natve 16-bit code speed the same as real DOS. Unless of course you count the occasional Win32 interrupts and other background housekeeping things (<1% usually).


Writes to the console screen can even be faster than in dos as long as you don't have the dos box full screen. I noticed this with some C++ programs I compiled with DJGPP a few years ago.
Post 20 Nov 2006, 17:14
View user's profile Send private message Reply with quote
2



Joined: 26 Sep 2006
Posts: 92
2 20 Nov 2006, 18:48
I figured that is was faster because it writes to the file without even opening a console. I can pretty much measure it's speed because the MessageBox
doesn't appear till the file is already closed. I have never had any compiled
C program run that fast.
Post 20 Nov 2006, 18:48
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 21 Nov 2006, 00:03
you caught on quick to the api, nice going
Post 21 Nov 2006, 00:03
View user's profile Send private message Reply with quote
2



Joined: 26 Sep 2006
Posts: 92
2 21 Nov 2006, 10:03
Yep,it's really kinda cool.
Post 21 Nov 2006, 10:03
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.