Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Aacini
- Expert
- Posts: 1886
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#16
Post
by Aacini » 07 Jun 2012 08:06
foxidrive wrote:Do you mean Win64 bit compatible? 32 bit Windows can run .com files.
I meant Win32 API function calls compatible. Old programs use DOS API function calls, that currently not run in Windows 64-bits versions (even if they are .EXE file format).
The current standard is Win32 API functions, that run in any Windows version.
Antonio
-
Fawers
- Posts: 187
- Joined: 08 Apr 2012 17:11
-
Contact:
#17
Post
by Fawers » 21 Jun 2012 16:20
Aacini wrote:I only use the best: assembly language!
More than 25 years ago I wrote several small programs as auxiliary commands for Batch files. They were really small files, less than 400 bytes the majority. For example, below is my GetKey program that read a key from keyboard and return its Ascii code via ERRORLEVEL. This is the MS-DOS 16-bits version:
Code: Select all
mov ah,8 ;DOS function: Keyboard input without echo
int 21H ;AL = Ascii code of key pressed
mov ah,4CH ;DOS function: Terminate program
int 21H ;Return Ascii code via ERRORLEVEL
This program generate a .COM file 8 (eight) bytes long! This program requires several modifications to make it Windows 32-bits compatible, so the resulting .EXE file is 1,536 bytes long! (although many of these are zero-filled bytes required in .EXE file format).
Antonio
I find Assembly very interesting, yet hard to learn; I just can't understand what all those MOVs and INTs stand for.
-
einstein1969
- Expert
- Posts: 941
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
#18
Post
by einstein1969 » 21 Jun 2012 17:16
Fawers wrote:Aacini wrote:I only use the best: assembly language!
More than 25 years ago I wrote several small programs as auxiliary commands for Batch files. They were really small files, less than 400 bytes the majority. For example, below is my GetKey program that read a key from keyboard and return its Ascii code via ERRORLEVEL. This is the MS-DOS 16-bits version:
Code: Select all
mov ah,8 ;DOS function: Keyboard input without echo
int 21H ;AL = Ascii code of key pressed
mov ah,4CH ;DOS function: Terminate program
int 21H ;Return Ascii code via ERRORLEVEL
This program generate a .COM file 8 (eight) bytes long! This program requires several modifications to make it Windows 32-bits compatible, so the resulting .EXE file is 1,536 bytes long! (although many of these are zero-filled bytes required in .EXE file format).
Antonio
I find Assembly very interesting, yet hard to learn; I just can't understand what all those MOVs and INTs stand for.
Code: Select all
Mov ah,8 Move in the register AH (like a variable) the value 8
int 21H Call the interrupt number 21Hex (like a subroutine in the bios or emulated)
ah=8 is like a parameter/index for the function/subroutine in the bios code
-
Liviu
- Expert
- Posts: 470
- Joined: 13 Jan 2012 21:24
#19
Post
by Liviu » 21 Jun 2012 20:17
Aacini wrote:I only use the best: assembly language!
More than 25 years ago I wrote several small programs as auxiliary commands for Batch files. They were really small files, less than 400 bytes the majority. For example, below is my GetKey program that read a key from keyboard and return its Ascii code via ERRORLEVEL. This is the MS-DOS 16-bits version:
Code: Select all
mov ah,8 ;DOS function: Keyboard input without echo
int 21H ;AL = Ascii code of key pressed
mov ah,4CH ;DOS function: Terminate program
int 21H ;Return Ascii code via ERRORLEVEL
This program generate a .COM file 8 (eight) bytes long! This program requires several modifications to make it Windows 32-bits compatible, so the resulting .EXE file is 1,536 bytes long! (although many of these are zero-filled bytes required in .EXE file format).
In fairness, 16-bit DOS had no notion of character codes wider than 8-bit, no ANSI vs. OEM codepage concerns, no ALT+[0]### keyboard input etc.
As for assembly, it is indeed what every other language translates down to, eventually. But as they say, one can write bad (or good) code in any language. I still have a skeleton C console-mode program somewhere, in perfectly valid 32b PE format, which parses and echoes back its arguments, compiled to an .exe of just 1,024 bytes. Only "hackish" part of it was to trim down the 16b stub - the one which prints "This program cannot be run in DOS mode" if you really tried to run it under 16b DOS - mine simply beeps, instead
The rest was a combination of "libctiny" and frugal compiler/linker switches.
Liviu