Image Map Image Map
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: ibm pc-dos assembler programming question

  1. #1

    Default ibm pc-dos assembler programming question

    So I'm using PC-DOS 1.10 on an emulator to write some assembly code. For a test of my environment, I wrote a "hello" program. I'm using MASM and LINK to create the .exe.

    Code:
    CSEG SEGMENT
    ASSUME CS:CSEG, DS:DSEG
    START:
      MOV AX, DSEG
      MOV DS, AX
      MOV DX, OFFSET MSG
      MOV AH, 09H
      INT 21H
      MOV AH, 0
      INT 21H
    CSEG ENDS
    
    DSEG SEGMENT
      MSG DB 'HELLO$'
    DSEG ENDS
    
    SSEG SEGMENT STACK
      DB 512 DUP (?)
    SSEG ENDS
    END START
    When running the code however, it prints HELLO and then hangs. If I change the "INT 21h" to an "INT 20h", it prints HELLO then a bunch of spaces.

    I've also tried making the program into a .COM program, with no luck. I know that the code can only have one segment, and no stack segment, but I still get the "File cannot be converted" error when running EXE2BIN.
    Code for the .COM version:

    Code:
    CSEG SEGMENT
    ASSUME CS:CSEG, DS:CSEG
    ORG 100H
    START:
      MOV AX, DSEG
      MOV DS, AX
      MOV DX, OFFSET MSG
      MOV AH, 09H
      INT 21H
      MOV AH, 0
      INT 21H
      MSG DB 'HELLO$'
    CSEG ENDS
    END START
    I have no idea what is causing the .exe version to not terminate properly, and I have no idea why the .com version won't convert. When I use LINK, I just use the default response for all the prompts, so I don't think there should be any issues? From what I can tell from DEBUG is that the PSP isn't in the same segment as CS, and I'm not sure how to ensure that it is. If, using DEBUG, I change CS to point to the PSP segment, I get "Program terminated normally", so I think that may be where the issue is.

  2. #2

    Default

    Quote Originally Posted by sudo459 View Post
    I've also tried making the program into a .COM program, with no luck. I know that the code can only have one segment, and no stack segment, but I still get the "File cannot be converted" error when running EXE2BIN.
    Code for the .COM version:

    Code:
    CSEG SEGMENT
    ASSUME CS:CSEG, DS:CSEG
    ORG 100H
    START:
      MOV AX, DSEG
      MOV DS, AX
      MOV DX, OFFSET MSG
      MOV AH, 09H
      INT 21H
      MOV AH, 0
      INT 21H
      MSG DB 'HELLO$'
    CSEG ENDS
    END START
    I have no idea what is causing the .exe version to not terminate properly, and I have no idea why the .com version won't convert. When I use LINK, I just use the default response for all the prompts, so I don't think there should be any issues? From what I can tell from DEBUG is that the PSP isn't in the same segment as CS, and I'm not sure how to ensure that it is. If, using DEBUG, I change CS to point to the PSP segment, I get "Program terminated normally", so I think that may be where the issue is.

    For the .COM version, leave off

    Code:
      MOV AX, DSEG
      MOV DS, AX
    the system automatically loads DS with the code segment.

    I am using DOSBOX,, not DOS 1.1 though.

  3. #3

    Default

    Oh, haha, I just added that while I was editing the post. The actual code I used doesn't have that. That would indeed make it not work, as far as I know. Without that though it still won't convert.

  4. #4

    Default

    Wikipedia has a little info on programming for DOS 1.x, especially when it comes to a different way to terminate: https://en.wikipedia.org/wiki/Program_Segment_Prefix

  5. #5
    Join Date
    Aug 2006
    Location
    Chicagoland, Illinois, USA
    Posts
    6,537
    Blog Entries
    1

    Default

    DOS 1.x doesn't honor int 21,4c for exiting programs. For .EXE programs, you must use INT 20h, for .COM programs you can simply use RET.

    I see that INT 21,0 is supposed to work, but try just INT 20h and see what happens.
    Offering a bounty for:
    - A working Sanyo MBC-775, Olivetti M24, or Logabax 1600
    - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)

  6. #6

    Default

    You didn't specify which version of MASM you're using, but I don't think the versions that were any good actually run on DOS 1.10. The earlier ones are known for the rich biodiversity of their bugs.

    There are other assemblers that can directly output .COM executables, but again, I'm not sure whether any of them would run on DOS 1.x...
    int10h.org :: :: :: blog

  7. #7
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,339
    Blog Entries
    18

    Default

    If you're truly perverse and run it as a .COM program, you can also terminate with CL = 0 and jump to cs:0005 (location 5 in the PSP).

    The reason for int 21h, ah=0 is related to CP/M 2.2, which PCDOS is modeled on, has only an API of 0 = "Reset system". Most programs jump to 0, which you can also do (CS:0 if .COM or PSP:0 if .EXE), which contains an INT 20h.

    (See how I dodged the question of PCODS "copying" CP/M?)

  8. #8

    Default

    Does the fact that there's always a zero value at the top of the stack also stem from CP/M? If so, I guess sizecoders these days have yet another reason to thank Gary Kildall.
    int10h.org :: :: :: blog

  9. #9
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,339
    Blog Entries
    18

    Default

    Probably, but it's only valid if CS: = PSP segment (i.e. .COM program).

    Makes a lot of sense if you look at the early 5150 Guide to Operations--that back section lists a bunch of programs that were probably directly converted from CP/M 2.x into 8086 code. I know that was the case with much of Sorcim's offerings. You can actually use the manual from CP/M Wordstar 3.x to devise patches for the MS-DOS version 3.x (user area patches).

  10. #10
    Join Date
    Feb 2010
    Location
    Russia, St.Petersburg
    Posts
    224

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •