News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hello and a question

Started by Rogare, September 30, 2009, 08:45:56 PM

Previous topic - Next topic

Rogare

Hey all,

I am pretty new to ASM. I am originally a higher-level programmer (PHP, .NET etc.) but as I was forced to learn C in one of the computers' science courses I decided to try going even lower.
I got few books on online tutorials, but when I tried assembling the programs I found and wrote I found out it is more complicated than I thought.
I posted some topic on the general forum and then I found out about the huge difference between 16-bit and 32-bit.
I am now trying to run my programs with 16-bit. I downloaded and installed Masm32 (earlier) and was told that link16 might help me.

This is GOTO.ASM:
.MODEL SMALL
.STACK 100h
.data
x DB 2Ah
.CODE

start:
mov ax,@data
mov ds,ax

mov ah,02h
mov dl,x
int 21h

mov ah,08h
int 21h
mov x,al

mov ax,4C00h
int 21h
END start


This is command line output:
D:\masm32\bin>ml /Bl link16.exe D:\GOTO.ASM
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: D:\GOTO.ASM

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Object Modules [.obj]: GOTO.obj
Run File [GOTO.exe]: "GOTO.exe"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:


When double-clicking on the GOTO.exe the black command line windows appears and disappears without waiting for anything.

Thanks in advance,
Rogare

dedndave

it probably works fine
you can either open a console window and run it from the command line
or
put a "press any key" at the end of the program so it does not exit until you press a key

Rogare

Ran it via command line - the asterisk isn't there and it isn't waiting for my key (as far as I know 21h-02 is print and 21h-08 is read key).

dedndave

it ran fine here
here is a 16-bit assembly batch file, as well as goto16.asm and exe

Rogare

The .exe really works. The code is same.
How do I work with the .bat file?

dedndave

place a16.bat in the masm32\bin folder
(that folder should be listed in the PATH environment variable)
then, at the command prompt type:
a16 goto16

if the x:\masm32\bin folder is not in the PATH
open My Computer - Properties - Advanced tab - Environment Variables button
and add it to the system environment PATH list (with a semicolon)

Rogare

Did all that (even changed the script to work with d:\masm32\bin instead of c:\...).
That is command line output:
D:\>a16 goto
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: goto.asm

PKSFX (R)   FAST!   Self Extract Utility   Version 2.04g  02-01-93
Copr. 1989-1993 PKWARE Inc. All Rights Reserved. Shareware version
PKSFX Reg. U.S. Pat. and Tm. Off.

Searching EXE: D:/MASM32/BIN/LINK563.EXE
Volume in drive D has no label.
Volume Serial Number is 00B2-CF12

Directory of D:\

09/30/2009  10:32 PM               200 GOTO.ASM
               1 File(s)            200 bytes
               0 Dir(s)  58,181,939,200 bytes free


I didn't see any thing in there (except the interesting fact that when it lists files in D:\ it shows only GOTO.ASM and not other files (there are other .ASM files in there).
I looked in D:\ and in D:\masm32\bin but the goto.exe isn't there.

dedndave

make sure that the 16-bit linker exe filename in the batch file matches the one you have in the masm32\bin folder

Rogare

Same. I tried removing from the batch the line that deletes the .obj file and seen it is there.

Here is the batch file I have:
@echo off
if "x%1"=="x" goto ascusage
if exist %1.asm goto ascasm
:ascusage
echo Usage: asc asmfile
echo "asmfile" = asmfile.asm
goto batchexit
:ascasm
if exist %1.obj del %1.obj
d:\masm32\bin\ml /c %1.asm >d:\masm32\bin\asmbl.txt
if errorlevel 1 goto showtxt
if exist %1.exe del %1.exe
d:\masm32\bin\Link563 %1.obj; >>d:\masm32\bin\asmbl.txt
:showtxt
if exist %1.obj del %1.obj
type d:\masm32\bin\asmbl.txt
:batchexit
dir %1.*


Here is the result of dir function in masm32/bin:
D:\masm32\bin>dir
Volume in drive D has no label.
Volume Serial Number is 00B2-CF12

Directory of D:\masm32\bin

10/01/2009  10:06 AM    <DIR>          .
10/01/2009  10:06 AM    <DIR>          ..
10/01/2009  12:09 PM               444 a16.bat
10/01/2009  12:08 PM               240 asmbl.txt
08/01/2007  10:49 AM               193 assmbl.bat
01/01/2007  02:01 PM               643 bldall.bat
01/01/2007  02:01 PM               643 bldallc.bat
01/01/2007  02:01 PM                88 bres.bat
01/01/2007  02:01 PM               542 build.bat
01/01/2007  02:01 PM               530 buildc.bat
01/20/1998  09:15 PM            15,632 cvtres.exe
01/01/2007  02:01 PM               408 dasm.bat
01/01/2007  02:01 PM               408 dasmd.bat
09/15/2002  11:58 PM            13,312 dbgwin.exe
03/29/2002  05:43 PM             2,048 dumpbin.exe
02/07/1999  08:24 AM           163,840 dumppe.exe
02/07/1999  08:24 AM             9,510 dumppe.txt
03/29/2002  05:43 PM             2,048 editbin.exe
09/27/2006  04:17 PM            44,984 imagedit.exe
10/17/1994  03:29 PM            82,134 imagedit.hlp
03/29/2002  05:43 PM             2,048 lib.exe
03/19/1998  08:28 AM           462,899 link.exe
01/13/1995  06:10 AM           364,544 link16.exe
09/30/2009  11:29 PM           281,082 Link563.exe
08/01/2007  10:50 AM               341 lnk.bat
08/01/2007  10:50 AM               341 lnkc.bat
07/21/2001  09:31 PM             9,687 ml.err
03/29/1999  09:45 AM           372,736 ml.exe
09/19/1998  01:30 PM           117,520 msdis100.dll
03/19/1998  05:50 PM           164,112 msdis109.dll
06/09/1998  10:50 PM           157,456 mspdb50.dll
06/12/2007  04:01 AM             4,633 pelle.txt
05/31/2008  01:09 AM           653,488 poasm.exe
03/24/2008  05:30 PM            88,240 polib.exe
03/24/2008  05:30 PM           164,528 polink.exe
03/24/2008  06:41 PM           146,096 porc.dll
03/24/2008  06:41 PM            30,208 porc.exe
06/09/1998  10:50 PM             4,880 rc.exe
06/27/1995  08:03 AM           136,161 rc.hlp
06/09/1998  10:50 PM           105,744 rcdll.dll
09/27/2006  04:18 PM            19,188 zoomin.exe
              39 File(s)      3,623,579 bytes
               2 Dir(s)  58,189,529,088 bytes free

MichaelW

I'm guessing here, but the file LNK563.EXE, from the MASM32 Forum Web Site under Microsoft Tools \ 16-bit Microsoft Linker, is not a 16-bit linker, it is a self-extracting archive that contains the files CVPACK.EXE, LINK.EXE, and README.TXT. When it is executed it displays this header:
Quote
PKSFX (R) FAST! Self Extract Utility Version 2.04g 02-01-93
Copr. 1989-1993 PKWARE Inc. All Rights Reserved. Shareware version
PKSFX Reg. U.S. Pat. and Tm. Off.

The LINK.EXE from the archive (364544 bytes, modified Thursday, January 12, 1995, 10:10:00 PM) is the 16-bit linker, and since it has the same name as the 32-bit linker, to allow it to coexist with the 32-bit linker and to prevent confusion it is frequently renamed to LINK16.EXE. For MASM32 v10, the LINK16.EXE in the \bin directory is this file.

eschew obfuscation

Rogare

Great guess!
Now I got the real Link563.
Here is the output of the batch:
D:\>a16 goto
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: goto.asm

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Volume in drive D has no label.
Volume Serial Number is 00B2-CF12

Directory of D:\

09/30/2009  10:32 PM               200 GOTO.ASM
10/01/2009  12:56 PM               539 goto.exe
               2 File(s)            739 bytes
               0 Dir(s)  58,188,984,320 bytes free

D:\>goto

D:\>


I tried also double-clicking goto.exe - just disappears. I also noticed it is the same size as the EXE you made (yours works).
Got another great guess?

MichaelW

The EXE disappears because it is coded to run and exit. To see the output you can run it from a command prompt, or do what I normally do and add a call to the BIOS Get Keystroke function. When the function is called it will wait for a keystroke to be placed in the keyboard buffer before it returns to the caller.

. . .
mov ah,08h
int 21h
mov x,al

mov ah,0
int 16h

mov ax,4C00h
int 21h
. . .

eschew obfuscation

Rogare

.MODEL SMALL
.STACK 100h
.data
x DB 2Ah
.CODE

start:
mov ax,@data
mov ds,ax

mov ah,02h
mov dl,x
int 21h

mov ah,08h
int 21h
mov x,al

mov ax,4C00h
int 21h
END start


int 21h-08 reads a character.
And I did open via command line (you can see at my last post in command line output) and nothing was seen.
Could you upload a .zip file with the real Link563, maybe I did something wrong?

dedndave

can't believe you caught Michael off-guard - hard to do - lol
find out which of these files you have in the masm32\bin folder:
link16.exe
lnk563.exe
link563.exe
edit the a16.bat file to match that linker name and it should work for you

Rogare

Well, I got Link563.exe and link16.exe. Tried working with both - always the same emptiness of the .exe.