I have been trying to understand the object code and the exe file generated by the MASM assembler , but some parts are still blurry for me, I hope someone can really help me in understanding the same.
So i have a very simple MASM program
Q1.ASM
.model small
.stack 100h
.data
string db 'hello$'
.code
MAIN PROC
mov ax, @data
mov ds, ax
lea dx , string
mov ah, 9
int 21h
mov ah, 4ch
int 21h
MAIN ENDP
END MAIN
I ran it on dosbox with MASM Q1.ASM
and it generated Q1.OBJ
$ xxd Q1.OBJ
00000000: 8008 0006 5131 2e41 534d e196 2500 0006 ....Q1.ASM..%...
00000010: 4447 524f 5550 0444 4154 4104 434f 4445 DGROUP.DATA.CODE
00000020: 0553 5441 434b 055f 4441 5441 055f 5445 .STACK._DATA._TE
00000030: 5854 8f98 0700 4811 0007 0401 fc98 0700 XT....H.........
00000040: 4806 0006 0301 0998 0700 7400 0105 0501 H.........t.....
00000050: e19a 0600 02ff 02ff 035b 8804 0000 a200 .........[......
00000060: d1a0 0a00 0200 0068 656c 6c6f 241c a015 .......hello$...
00000070: 0001 0000 b800 008e d88d 1600 00b4 09cd ................
00000080: 21b4 4ccd 21f0 9c0b 00c8 0115 0101 c407 !.L.!...........
00000090: 1401 0297 8a07 00c1 0001 0100 00ac ..............
Then i ran $ link Q1.OBJ
and then it generated Q1.EXE
.
$ xxd Q1.EXE
00000000: 4d5a 1800 0200 0100 2000 1100 ffff 0200 MZ...... .......
00000010: 0001 c58b 0000 0000 1e00 0000 0100 0100 ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000200: b801 008e d88d 1602 00b4 09cd 21b4 4ccd ............!.L.
00000210: 2100 6865 6c6c 6f24 !.hello$
Now i have two questions,
The object code generated should have modification records and relocation bits in it, but all are in binary, is there any way to properly analyse the modification records generated from the .OBJ file.
The
Q1.EXE
file generated, as you can see, has many blanks given by 0000, what exactly are the use of them and what is the significance of 'L' in the line00000200:
.