flat assembler
Message board for the users of flat assembler.
Index
> DOS > Chances to debug a .com file with source (labels/comments/)? Goto page 1, 2 Next |
Author |
|
revolution 12 Sep 2015, 10:45
The old Turbo Assembler had a source code level debugger included. I don't know of any thing for DOS that would work with fasm's debug format.
|
|||
12 Sep 2015, 10:45 |
|
nop 12 Sep 2015, 11:21
if u have assembled the .com file from fasm source you can generate the .fas file and tomasz has provided a utility to create a symbol list from the .fas file i did it some time ago and i can't check right now but it was in the docs with the download for the dos version
|
|||
12 Sep 2015, 11:21 |
|
marste 12 Sep 2015, 20:47
I used all the tools to produce symbols, listing and "prepsrc" (produce just a listing of the instructions).
Tried Turbo Debugger, but it says that symbols have an invalid format and do not load it. It shows just disassembled instructions and dump of memory for data. I tried also to compile an example with Turbo Assembler but it says that for .com the symbolic information are not produced. |
|||
12 Sep 2015, 20:47 |
|
ACP 13 Sep 2015, 08:41
Most DOS debuggers predates FASM hence there is no support for symbols. However if you like to use TASM & TD there is a way to have symbolic debugging in TD for COM files. Here is the trick:
TASM /zi yourfile.asm TLINK /v yourfile.obj TDSTRIP -s -c yourfile.exe yourfile.com This will produce symbol file for com. You may try to generate symbols from obj files if I remember correctly. BTW: I hope you have a good reason for using COM format instead of EXE. |
|||
13 Sep 2015, 08:41 |
|
marste 16 Sep 2015, 21:52
ACP wrote: Most DOS debuggers predates FASM hence there is no support for symbols. However if you like to use TASM & TD there is a way to have symbolic debugging in TD for COM files. Here is the trick: Great ACP, it works!! Just now I should convert all my program syntax to TASM or there is a way to keep FASM one? (that I like very much and I have already used a bit!) PS: the reason to have .com is the final executable size where even few bytes count! |
|||
16 Sep 2015, 21:52 |
|
ACP 17 Sep 2015, 07:10
If you plan to use TASM package than you need to convert source code to TASM or older MASM syntax. If you are converting from FASM syntax this document may provide a bit of help in such task: http://flatassembler.net/docs.php?article=design
Don't know how much sources you have in FASM format but if the number is substantial than maybe it would be worth to write symbols converter instead? Secondly I never liked Turbo Debugger personally. During DOS time there were few debuggers superior to TD, especially when you weren't using TASM. The big question is do you really need symbol debugging? FASM does pretty good job at assembling code according to your source. Unless you are using complex macros and HLL features I would suggest to stick with FASM since it is actively developed contrary to TASM and choose a better debugger. As for COM file format if you can live with its limitation than good for you. |
|||
17 Sep 2015, 07:10 |
|
marste 17 Sep 2015, 17:18
My code is pretty complex but not long at all. Just FASM syntax is for me more direct and clear (even if when I was programming assembler around 1987 I was using MASM one).
For this I'm surely open to change debugger, but should show source lines as TD does (i.e. with names and comments). Then, which debugger to use? If it's useful I should even be able to debug using .exe format and then convert to .com at the end! |
|||
17 Sep 2015, 17:18 |
|
ACP 17 Sep 2015, 19:10
Don't switch debugger because of my personal opinion. If you are fine with TD than use it. My favor debuggers supporting source code debugging are: Periscope 5.x and Soft-ICE 2.x (later versions are targeting Windows). The drawback is that none of them is working under DosBox and while there could a chance to make Periscope working SI is out of question since it is loaded as device driver. However they should work under DOS VM in VMware and VirtualBox.
Debugging EXE and later converting it to COM file format sound to me like a bad idea unless you can watch out for bugs being a result from executable formats differences. If you are dependent on Int 21h DOS services than this may bite you at one point. For example memory allocation works differently for COM and EXE programs. TASM ideal mode and FASM syntax are superior to MASM different quirks. |
|||
17 Sep 2015, 19:10 |
|
marste 19 Sep 2015, 09:41
Seems Periscope and Soft-ICE are available only "cracked", so I stayed on tasm that on phatcode seems available to be used and for my needs seems ok.
It took me more than expected but at the end I compiled the source without apparent errors. The problem seems that tdstrip remove more than needed. I need ds:0 to point at data section and so I wrote a simple program that show the problem I have: ideal model tiny segment code assume cs:code, ds:code, ss:code org 0 zero equ $ org 100h ; .com start: xor ax,ax ; mov ah,00 ; Select the video mode 0 int 10h ; Call video interrupt mov ax,ds add ax, (post_dataoffset - zero) / 16 mov ds,ax xor dx,dx mov ah,9 ; print string at ds:dx int 21h mov ax,4c00h int 21h dataoffset: align 16 post_dataoffset: org 0 db "simple string to print$" ends code end start After tdstrip the .com file is 32 bytes long and do not contain the "simple string to print$"... |
|||
19 Sep 2015, 09:41 |
|
marste 19 Sep 2015, 10:10
PS: the FASM "equivalent" version is infact 55 bytes long (i.e. include the string to print!)
use16 org 100h start: xor ax,ax ; mov ah,00 ; Select the video mode 0 int 10h ; Call video interrupt mov ax,ds add ax, post_dataoffset / 16 mov ds,ax xor dx,dx mov ah,9 ; print string at ds:dx int 21h mov ax,4c00h int 21h dataoffset: align 16 post_dataoffset: org 0 db "simple string to print$" |
|||
19 Sep 2015, 10:10 |
|
ACP 19 Sep 2015, 10:17
I think that the problem is org 0 statement after post_dataoffset label. Why are you putting you string at that location? COM files starts at 100h, the memory below is used by DOS structures and in COM files you can't have more than one segment containing code, data and stack.
BTW: I can't compile you example code using TASM 5 package. |
|||
19 Sep 2015, 10:17 |
|
marste 19 Sep 2015, 13:19
ACP wrote: I think that the problem is org 0 statement after post_dataoffset label. Why are you putting you string at that location? COM files starts at 100h, the memory below is used by DOS structures and in COM files you can't have more than one segment containing code, data and stack. I need to reset assembler location since to compact my code I need to reference the location at DS with zero offset. Infact in FASM this part works fine. ACP wrote: BTW: I can't compile you example code using TASM 5 package. Sorry, tryed with v5 (before was v4) and it works (to work properly need "zero = $" and not "zero equ $"!). Just the .com is 64 bytes and not 55 as the working FASM version. |
|||
19 Sep 2015, 13:19 |
|
ACP 19 Sep 2015, 14:06
When you try to assemble you example code with TASM and link it with TLINK directly to COM file you get the following error due to org 0 directive:
Cannot generate COM file: data below initial CS:IP defined. That is why TDSTRIP truncates your file when you convert from EXE to COM. This is exactly type of issue I've been warning you about. Just because the assembler/linker was able to produce output file doesn't mean it will run correctly. In case of FASM the resulting COM is not working properly due to the fact that COM file has single segment. You need to manually relocate data using rep movs and you can use EQUs definition for correct offsets when accessing your data. Additionally overwriting DOS structures like PSP isn't a good idea if you are using DOS INT 21h handler: some functions will not work correctly. BTW: the 16bit TASM.EXE and TASMX from TASM 5 package are in fact v4.1. Only the TASM32.EXE is v5.0. |
|||
19 Sep 2015, 14:06 |
|
revolution 19 Sep 2015, 14:17
ACP wrote: In case of FASM the resulting COM is not working properly due to the fact that COM file has single segment. You need to manually relocate data using rep movs and you can use EQUs definition for correct offsets when accessing your data. Additionally overwriting DOS structures like PSP isn't a good idea if you are using DOS INT 21h handler: some functions will not work correctly. |
|||
19 Sep 2015, 14:17 |
|
ACP 19 Sep 2015, 14:23
Did you actually run the resulting file under DOS/DosBOX? Even looking at the disassembly you can tell it will not run properly. Unless you are referring to the fact that DOS will happily execute resulting file. In such case you are right - FASM will generate output that DOS will execute.
|
|||
19 Sep 2015, 14:23 |
|
marste 19 Sep 2015, 16:18
Yes, I run both resulting files (55 and 64 bytes) and they worked!
Just... now I tryed to replicate the compilation to show it and ... I'm not able to obtain back the 64 bytes!!! Anyway org directive should just telling assembler to think that everything following that instruction has a different address but is not actually moving bytes around (as 100h is infact starting at the first byte). Assembler should just add up bytes than then dos with .com management load at 100h and start to execute. Anyway I confirm: the problem is in the org 0 directive. To use TASM I should offset everithing. Probably I will. In the meantime thank you!! |
|||
19 Sep 2015, 16:18 |
|
ACP 19 Sep 2015, 23:03
As for TASM there should be a way of creating TDS file for Turbo Debugger using TDMAP utility but I can't find a combination of tools that will work together. Basically after linking to COM file with TLINK you should create TDS file using TDMAP and later load COM file into TD.
|
|||
19 Sep 2015, 23:03 |
|
marste 20 Sep 2015, 08:24
ACP wrote: As for TASM there should be a way of creating TDS file for Turbo Debugger using TDMAP utility but I can't find a combination of tools that will work together. Basically after linking to COM file with TLINK you should create TDS file using TDMAP and later load COM file into TD. I have TDS file (and is loading in TD), my compilation is: Code: tasm /c /x /la /zi /m9 /dtasm=1 test.asm tlink /n /Tde /O /v test.obj tdstrip -s -c smext.exe test.com I was even able to make the source compatible with tasm and fasm together. The trick is in the option /dtasm=1 above and the instructions (if someone will find useful): Code: if tasm eq 1 ; tasm else ; fasm endif equ end if endif if tasm eq 1 ideal model tiny segment code assume cs:code, ds:code, ss:code else use16 endif org 0 zero = $ org 100h ; .com And then offsetting all the instructions and data definition with the "zero" offset when referring to offset, as for example: Code: les bx,[memory_location -zero] dw memory_location -zero memory_location db ... (sometimes not required but better more then less! ) The program should end with: Code: if tasm eq 1
ends code
end start
endif (it's giving a warning in tasm because didn't reach endif but just that) And now... let's debug! |
|||
20 Sep 2015, 08:24 |
|
ACP 20 Sep 2015, 10:16
TDMAP allows creating TDS files which means you could skip conversion from EXE to COM. In such case you can directly link to COM (TLINK /t or /Tdc option). Anyway I could not find in my collection a set of Borland tools that would work together and apparently TDMAP is missing from TASM v5 package. Oh well, it has been so long ago when I used all those tools.
Good luck with debugging. BTW: An interesting detail: I did not remember that TASM is using xchg bx,bx as padding (fasm is using nop). |
|||
20 Sep 2015, 10:16 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.