News:

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

Main Menu

so many questions, so many troubles

Started by Sam, November 04, 2013, 02:24:21 PM

Previous topic - Next topic

Sam

Quote from: hutch-- on November 04, 2013, 11:45:45 PM
What the EXE is missing is a program termination, vaguely it was int 21h function 4Ch but I don't think I have 16 bit reference material floating around and don't want it anyway.

This seems to be it.


    mov ah, 4Ch
    int 21h

yeah but isn't the .exit directive supposed to do that????

jj2007

Quote from: dedndave on November 06, 2013, 02:18:42 AM
i am going to update my EXE template
        mov     dx,@data
        mov     ds,dx

that way, the contents of AX are not destroyed
Jochen may want to make the same change in his Init macro

One byte shorter, and it keeps all regs (why is trashing dx better than trashing ax?):
  push @data
  pop ds
  push ds
  pop es

dedndave

because AX has information in it
AL = 0 if first FCB empty, FF if first FCB has a parsed filename
AH = 0 if second FCB empty, FF if second FCB has a parsed filename

the contents of DX seem to be undefined
but - nothing wrong with push/pop, really - a couple cycles slower, maybe   :P

as for setting the ES register - better to leave that alone
or - set DS, save ES to a wPspSeg variable, then set it
DS and ES contain the PSP segment - and i don't remember a way to retrieve it afterwards

Sam

Quote from: hutch-- on November 05, 2013, 12:43:42 AM
Here is a small test piece that uses the simplified segment directives. Build it with the same batch file as above.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    .model small
    .dosseg
    .stack 1024

  ; -----------------
  ; terminate the app
  ; -----------------
    bye_bye MACRO
      mov ah, 4Ch
      int 21h
    ENDM

  .data
    txt db "Howdy Sam, this is a",13,10, \
    "small memory model DOS exe file$"    ; the "$" terminates the string for DOS function 09h

  .code
  .startup

  ; ----------------------
  ; display a text message
  ; ----------------------
    mov ah, 09h
    mov dx, OFFSET txt
    int 21h

    bye_bye

  ;; .exit 0

  end

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

thanks hutch when I tries to run that the following error happened:
A2006: undefined symbol:DGROUP

Sam

Quote from: dedndave on November 04, 2013, 09:12:11 PM
on the link16 command line, you can place the switches before the file list
then provide the asm and exe names, seperated by commas
then, use a semicolon to tell the linker to use default responses for the rest of the required fields

if you recall, the old linker would prompt for inputs if the command line didn't provide them   :P
the semicolon turns that off - useful in batch files

you are running 32-bit windows 7, so you should be able to run the program
the problem is - why is the instructor teaching 16-bit code ? - lol

the io.mac file is a macro file that you had on a previous exercise
perhaps provided by the instructor
make sure it is in the same folder as the asm file - or set the include path to where it does exist
i suspect you are going to want it, at some point

as for any courses to follow - i take it you mean tutorials
i am sure they exist - just don't know of too many for 16-bit, offhand
if you google around a little, you might find an old copy of Randall Hyde's Art Of Assembly online
not really a tutorial - it's a book that is presented in html form
http://cs.smith.edu/~thiebaut/ArtOfAssembly/artofasm.html

for old 16-bit code, you can use DEBUG or SYMDEB
again, google is your friend
thanks for the course buddy, I think it's amazing

dedndave


MichaelW

Sam,

Assembling and linking a 16-bit DOS app from within the MASM32 Quick Editor is no problem. You simply create a makeit.bat file, and you can readily do this to from within the editor, store it in your working directory, and with your ASM source loaded into the editor select Makeit.bat from the Project menu. And in case it's not clear, "working directory" here means the directory where your ASM source is stored and where the object module, executable, etc will be stored.

For the ML 6.14 in the MASM32 package, or the later ML 6.15, the batch file to create a 16-bit EXE can be as simple as:

\masm32\bin\ml /c %1.asm
pause
\masm32\bin\link16 %1.obj;
pause


Note that the Create EXE makeit.bat command on the Script menu is for 32-bit executables.

Well Microsoft, here's another nice mess you've gotten us into.

jj2007

Quote from: dedndave on November 06, 2013, 02:54:03 AM
DS and ES contain the PSP segment - and i don't remember a way to retrieve it afterwards

QuoteAnother way to obtain the PSP address, in DOS 5.0 and later, is to make a DOS call. If you load ah with 51h and execute an int 21h instruction, MS-DOS will return the segment address of the current PSP in the bx register.
(AoA)

However, I can't get that DOS call to work.

dedndave

i remember having problems with that, back in the DOS 3.3 era
that's why i suggest storing the value from ES into a variable   :P

along the lines of what Jochen was working with....
    push    @data
    pop     ds
    mov     wPspSeg,es
    push    ds
    pop     es

would seem simple enough

FORTRANS

Quote from: dedndave on November 06, 2013, 02:54:03 AM
as for setting the ES register - better to leave that alone
or - set DS, save ES to a wPspSeg variable, then set it
DS and ES contain the PSP segment - and i don't remember a way to retrieve it afterwards

Hi Dave,

   I see jj2007 beat me to it.  Oh well.

   There are MS-DOS functions 51H and 62H, "Get PSP Address".
62H was introduced with DOS 3.0.  51H was in earlier versions,
but undocumented until DOS 5.0.  The address is returned in the
BX register.  They call the same code.  And I have used them,
usually 62H, and it worked for me.

Regards,

Steve N.

dedndave

i see what my problem may have been
i tried it just now with SymDeb
and the value in BX does not jive with the current code segment
well, duh - it's probably the PSP segment for the SymDeb executable - not my little program   :biggrin:
C:\DOCUME~1\Dave\Desktop => symdeb
Microsoft (R) Symbolic Debug Utility  Version 4.00
Copyright (C) Microsoft Corp 1984, 1985.  All rights reserved.

Processor is [80286]
-a
0EEF:0100 mov ah,51
0EEF:0102 int 21
0EEF:0104 int 20
0EEF:0106
-bp0 104
-g
AX=5100  BX=05E4  CX=0000  DX=0000  SP=F000  BP=0000  SI=0000  DI=0000
DS=0EEF  ES=0EEF  SS=0EEF  CS=0EEF  IP=0104   NV UP EI PL NZ NA PO NC
0EEF:0104 CD20           INT    20                            ;BR0
-q

C:\DOCUME~1\Dave\Desktop =>


which is ok.....
but, if you want code that you can debug, use the value from ES   :t

FORTRANS

Quote from: dedndave on November 06, 2013, 04:48:31 AM
i see what my problem may have been
i tried it just now with SymDeb
and the value in BX does not jive with the current code segment
well, duh - it's probably the PSP segment for the SymDeb executable - not my little program

Hi Dave,

   Ouch.  Yeah, "Undocumented DOS" says that function just
returns the last value set.  I guess the DOS loader does set it.
And SymDeb didn't bother.

Regards,

Steve

Magnum

It was interesting that 16 bit programs will run on Win 7.

I had read that they would not.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

they won't run on 64-bit windows, at least not without some help (like DosBox, etc)

FORTRANS

#44
Hi Dave,

   I was trying to reproduce your failure in Reply #40.  And failed.
I was using a program I wrote a while back, so it is an EXE, not
your COM.  And there is some cruft from what I was doing from
back then.  But the general idea should be the same, give or take.
Any idea what is going on?  I hate it when things are not reproducible.

D:\MASM\WORK>..\symdeb test-reg.exe
Microsoft Symbolic Debug Utility
Version 3.00
(C)Copyright Microsoft Corp 1984
Processor is [80286]
-g1a
This program will display the initial register values on program start up.
Version 0.1 α
  DS:   ES:   PSP  Cmd#
0D8C: 0D8C

:AX=023A  BX=0000  CX=01F1  DX=003A  SP=0100  BP=0000  SI=0D00  DI=0000
DS=0DAC  ES=0D8C  SS=0D9C  CS=0DB4  IP=001A   NV UP EI PL NZ NA PO NC
0DB4:001A B462           MOV    AH,62                         ;'b'
-p
AX=623A  BX=0000  CX=01F1  DX=003A  SP=0100  BP=0000  SI=0D00  DI=0000
DS=0DAC  ES=0D8C  SS=0D9C  CS=0DB4  IP=001C   NV UP EI PL NZ NA PO NC
0DB4:001C CD21           INT    21
-p
AX=623A  BX=0D8C  CX=01F1  DX=003A  SP=0100  BP=0000  SI=0D00  DI=0000
DS=0DAC  ES=0D8C  SS=0D9C  CS=0DB4  IP=001E   NV UP EI PL NZ NA PO NC
0DB4:001E 8BC3           MOV    AX,BX
-


   Tested in and out of DEBUG and SymDeb in a VDM, and in
and out of SymDeb in an NTVDM on Win2000.

Regards,

Steve N.

Edit 38 -> 40.