home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / DRI-archive / roche / HEADER.TXT < prev    next >
Internet Message Format  |  2009-12-11  |  15KB

  1. From: "French Luser" <Bill.Ga...@microsoft.com>
  2. Newsgroups: comp.os.cpm
  3. Subject: Header Record of CP/M-86 (Plus)
  4. Date: Fri, 26 Nov 2004 12:52:37 +0100
  5. X-Priority: 3
  6. X-MSMail-Priority: Normal
  7. X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
  8. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
  9. Lines: 455
  10. Message-ID: <41a71871$0$25111$8fcfb975@news.wanadoo.fr>
  11. Organization: les newsgroups par Wanadoo
  12. NNTP-Posting-Host: APoitiers-106-2-3-49.w81-248.abo.wanadoo.fr
  13. X-Trace: 1101469810 news.wanadoo.fr 25111 81.248.43.49:21824
  14. X-Complaints-To: abuse@wanadoo.fr
  15.  
  16. HEADER.TXT  by Emmanuel ROCHE
  17. ----------
  18.  
  19. Everything you wanted to know about the Header Record,  but were
  20. too afraid to ask...
  21.  
  22. The more  I work  with CP/M-86  (Plus) ComManD  files, the  more
  23. often I need to know what is inside its Header Record.
  24.  
  25. For the record, a CMD file generally has 2 or 3 parts, which can
  26. be described thus:
  27.  
  28.         +---------------+
  29.         | Header Record |
  30.         +---------------+
  31.         | Segments Used |
  32.         +---------------+
  33.         | Footer Record |  (If RSX(s) present)
  34.         +---------------+
  35.  
  36. The Header Record contains a description of the Segments used by
  37. the program,  that the  loader of  the CP/M-86  (Plus) Operating
  38. System will use to allocate memory and load  the program  in the
  39. TPA.  As its name implies, it is 128 bytes long, or one  record.
  40. It contains Group Descriptors at the beginning.  A first byte of
  41. zero  in  a  Group  Descriptor  indicates  that  no  more  Group
  42. Descriptors follows.  The rest of the record is filled with null
  43. bytes (00h), except the 5 last  bytes, which  will be  explained
  44. later.
  45.  
  46. The Segments Used part of the CMD file are those segments, up to
  47. 8.
  48.  
  49. The  Footer  Record  is  a record  containing the  names or  the
  50. addresses/names of the RSXs  linked/attached (up  to 8)  to this
  51. CMD file. This record does not exist if the CMD file has no RSX.
  52.  
  53. Enough theory, let us see some Header Records.
  54.  
  55. A>mbasic header
  56. BASIC-86 Rev. 5.22
  57. [CP/M-86 Plus]
  58. Copyright 1977-1982 (C) by Microsoft
  59. Created:  5-Mar-82
  60. 62390 Bytes free
  61.  
  62. HEADER> Enter CMD File Name: ? CMD1
  63.  
  64.          G-Form  G-Length  A-Base   G-Min    G-Max
  65.         +-------+--------+--------+--------+--------+
  66. (Code)  |  01h  |  0018  |  0000  |  0018  |  0000  |
  67.         +-------+--------+--------+--------+--------+
  68.  
  69. Offset of Footer Record: 0000
  70. Offset of Fixups Record: 0000
  71. Program Flag: 00
  72.  
  73. (8080 Memory Model)
  74.  
  75. Ok
  76. run
  77.  
  78. HEADER> Enter CMD File Name: ? CMD2
  79.  
  80.          G-Form  G-Length  A-Base   G-Min    G-Max
  81.         +-------+--------+--------+--------+--------+
  82. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  83.         +-------+--------+--------+--------+--------+
  84. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  85.         +-------+--------+--------+--------+--------+
  86.  
  87. Offset of Footer Record: 0000
  88. Offset of Fixups Record: 0000
  89. Program Flag: 00
  90.  
  91. (Small Memory Model)
  92.  
  93. Ok
  94. run
  95.  
  96. HEADER> Enter CMD File Name: ? CMD3
  97.  
  98.          G-Form  G-Length  A-Base   G-Min    G-Max
  99.         +-------+--------+--------+--------+--------+
  100. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  101.         +-------+--------+--------+--------+--------+
  102. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  103.         +-------+--------+--------+--------+--------+
  104. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  105.         +-------+--------+--------+--------+--------+
  106.  
  107. Offset of Footer Record: 0000
  108. Offset of Fixups Record: 0000
  109. Program Flag: 00
  110.  
  111. (Compact Memory Model)
  112.  
  113. Ok
  114. run
  115.  
  116. HEADER> Enter CMD File Name: ? CMD4
  117.  
  118.          G-Form  G-Length  A-Base   G-Min    G-Max
  119.         +-------+--------+--------+--------+--------+
  120. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  121.         +-------+--------+--------+--------+--------+
  122. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  123.         +-------+--------+--------+--------+--------+
  124. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  125.         +-------+--------+--------+--------+--------+
  126. (Stack) |  04h  |  0008  |  0000  |  0008  |  0000  |
  127.         +-------+--------+--------+--------+--------+
  128.  
  129. Offset of Footer Record: 0000
  130. Offset of Fixups Record: 0000
  131. Program Flag: 00
  132.  
  133. (Compact Memory Model)
  134.  
  135. Ok
  136. run
  137.  
  138. HEADER> Enter CMD File Name: ? CMDX1
  139.  
  140.          G-Form  G-Length  A-Base   G-Min    G-Max
  141.         +-------+--------+--------+--------+--------+
  142. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  143.         +-------+--------+--------+--------+--------+
  144. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  145.         +-------+--------+--------+--------+--------+
  146. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  147.         +-------+--------+--------+--------+--------+
  148. (Stack) |  04h  |  0008  |  0000  |  0008  |  0000  |
  149.         +-------+--------+--------+--------+--------+
  150. (Aux.1) |  05h  |  0000  |  0000  |  0040  |  0000  |
  151.         +-------+--------+--------+--------+--------+
  152.  
  153. Offset of Footer Record: 0000
  154. Offset of Fixups Record: 0000
  155. Program Flag: 00
  156.  
  157. (Compact Memory Model)
  158.  
  159. Ok
  160. run
  161.  
  162. HEADER> Enter CMD File Name: ? CMDX2
  163.  
  164.          G-Form  G-Length  A-Base   G-Min    G-Max
  165.         +-------+--------+--------+--------+--------+
  166. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  167.         +-------+--------+--------+--------+--------+
  168. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  169.         +-------+--------+--------+--------+--------+
  170. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  171.         +-------+--------+--------+--------+--------+
  172. (Stack) |  04h  |  0008  |  0000  |  0008  |  0000  |
  173.         +-------+--------+--------+--------+--------+
  174. (Aux.1) |  05h  |  0000  |  0000  |  0040  |  0000  |
  175.         +-------+--------+--------+--------+--------+
  176. (Aux.2) |  06h  |  0000  |  0000  |  0040  |  0000  |
  177.         +-------+--------+--------+--------+--------+
  178.  
  179. Offset of Footer Record: 0000
  180. Offset of Fixups Record: 0000
  181. Program Flag: 00
  182.  
  183. (Compact Memory Model)
  184.  
  185. Ok
  186. run
  187.  
  188. HEADER> Enter CMD File Name: ? CMDX3
  189.  
  190.          G-Form  G-Length  A-Base   G-Min    G-Max
  191.         +-------+--------+--------+--------+--------+
  192. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  193.         +-------+--------+--------+--------+--------+
  194. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  195.         +-------+--------+--------+--------+--------+
  196. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  197.         +-------+--------+--------+--------+--------+
  198. (Stack) |  04h  |  0008  |  0000  |  0008  |  0000  |
  199.         +-------+--------+--------+--------+--------+
  200. (Aux.1) |  05h  |  0000  |  0000  |  0040  |  0000  |
  201.         +-------+--------+--------+--------+--------+
  202. (Aux.2) |  06h  |  0000  |  0000  |  0040  |  0000  |
  203.         +-------+--------+--------+--------+--------+
  204. (Aux.3) |  07h  |  0000  |  0000  |  0040  |  0000  |
  205.         +-------+--------+--------+--------+--------+
  206.  
  207. Offset of Footer Record: 0000
  208. Offset of Fixups Record: 0000
  209. Program Flag: 00
  210.  
  211. (Compact Memory Model)
  212.  
  213. Ok
  214. run
  215.  
  216. HEADER> Enter CMD File Name: ? CMDX4
  217.  
  218.          G-Form  G-Length  A-Base   G-Min    G-Max
  219.         +-------+--------+--------+--------+--------+
  220. (Code)  |  01h  |  0008  |  0000  |  0008  |  0000  |
  221.         +-------+--------+--------+--------+--------+
  222. (Data)  |  02h  |  0018  |  0000  |  0018  |  0000  |
  223.         +-------+--------+--------+--------+--------+
  224. (Extra) |  03h  |  0008  |  0000  |  0008  |  0000  |
  225.         +-------+--------+--------+--------+--------+
  226. (Stack) |  04h  |  0008  |  0000  |  0008  |  0000  |
  227.         +-------+--------+--------+--------+--------+
  228. (Aux.1) |  05h  |  0000  |  0000  |  0040  |  0000  |
  229.         +-------+--------+--------+--------+--------+
  230. (Aux.2) |  06h  |  0000  |  0000  |  0040  |  0000  |
  231.         +-------+--------+--------+--------+--------+
  232. (Aux.3) |  07h  |  0000  |  0000  |  0040  |  0000  |
  233.         +-------+--------+--------+--------+--------+
  234. (Aux.4) |  08h  |  0000  |  0000  |  0040  |  0000  |
  235.         +-------+--------+--------+--------+--------+
  236.  
  237. Offset of Footer Record: 0000
  238. Offset of Fixups Record: 0000
  239. Program Flag: 00
  240.  
  241. (Compact Memory Model)
  242.  
  243. Ok
  244. run
  245.  
  246. HEADER> Enter CMD File Name: ? CALLVERS
  247.  
  248.          G-Form  G-Length  A-Base   G-Min    G-Max
  249.         +-------+--------+--------+--------+--------+
  250. (Code)  |  01h  |  0002  |  0000  |  0002  |  0000  |
  251.         +-------+--------+--------+--------+--------+
  252. (Data)  |  02h  |  0012  |  0000  |  0012  |  0000  |
  253.         +-------+--------+--------+--------+--------+
  254.  
  255. Offset of Footer Record: 0400
  256. Offset of Fixups Record: 0000
  257. Program Flag: 00
  258.  
  259. (Small Memory Model)
  260.  
  261. Ok
  262. run
  263.  
  264. HEADER> Enter CMD File Name: ? ECHOVERS
  265.  
  266.          G-Form  G-Length  A-Base   G-Min    G-Max
  267.         +-------+--------+--------+--------+--------+
  268. (Code)  |  01h  |  0006  |  0000  |  0006  |  0000  |
  269.         +-------+--------+--------+--------+--------+
  270. (Data)  |  02h  |  0012  |  0000  |  0012  |  0000  |
  271.         +-------+--------+--------+--------+--------+
  272.  
  273. Offset of Footer Record: 0000
  274. Offset of Fixups Record: 0000
  275. Program Flag: 10
  276.  
  277. (Small Memory Model)
  278.  
  279. Ok
  280. run
  281.  
  282. HEADER> Enter CMD File Name: ? TESTGIOS
  283.  
  284.          G-Form  G-Length  A-Base   G-Min    G-Max
  285.         +-------+--------+--------+--------+--------+
  286. (Code)  |  01h  |  0298  |  0000  |  0298  |  0000  |
  287.         +-------+--------+--------+--------+--------+
  288. (Data)  |  02h  |  0058  |  0000  |  0058  |  0000  |
  289.         +-------+--------+--------+--------+--------+
  290. (Extra) |  03h  |  0006  |  0000  |  0006  |  0000  |
  291.         +-------+--------+--------+--------+--------+
  292. (Stack) |  04h  |  0094  |  0000  |  0094  |  0000  |
  293.         +-------+--------+--------+--------+--------+
  294.  
  295. Offset of Footer Record: 0000
  296. Offset of Fixups Record: 7300
  297. Program Flag: 80
  298.  
  299. (Large Memory Model)
  300.  
  301. Ok
  302.  
  303. From the above, some things become clear: when there is only one
  304. Code segment, it is a "8080 Memory model CMD file".
  305.  
  306. When there are 2 segments (but only if they are Code  and Data),
  307. then it is a "Small Memory model CMD file".
  308.  
  309. When there are more  than 2  segments, it  is a  "Compact Memory
  310. model CMD file".
  311.  
  312. Historically, those were the 3 kinds of Memory  Models described
  313. in the CP/M-86 Version  1.x technical  documentation by  Digital
  314. Research.
  315.  
  316. Under CP/M-86 Plus, RSXes exist. ECHOVERS is an example of  such
  317. an RSX.   As  you  can  see,  its  Program  Flag  contains  10h.
  318. CALLVERS, the CMD file  calling it,  has its  "Offset to  Footer
  319. Record" field containing the value 0400h.
  320.  
  321. But, what is this "Large Memory  model CMD  file", TESTGIOS,  we
  322. have seen last?
  323.  
  324. With Concurrent CP/M Version 1.0, Digital Research introduced in
  325. the Summer of 1983 a new kind of  CMD file,  where each  segment
  326. can be up to 1 Megabyte  in length...   (Previously, they  could
  327. only be 64k long, at the maximum.)
  328.  
  329. But, to  be compatible  with all  the CMD  files produced  until
  330. then, they had to choose a way to let the CMD file loader of the
  331. operating system knows that this CMD file was of the new kind.
  332.  
  333. Since they could not modify the format of the Group Descriptors,
  334. they chose to use a byte inside the Header Record.
  335.  
  336. Over the years, this byte came to be used as flags for 4 things:
  337.  
  338.      Bit: 7 6 5 4 3 2 1 0
  339.         +-----------------+
  340.         | 1 1 1 1 1 1 1 1 |
  341.         +-----------------+
  342.           | | | | | | | |
  343.           | | | | | | | +--> Bit 0: Not used
  344.           | | | | | | +----> Bit 1: Not Used
  345.           | | | | | +------> Bit 2: Not used
  346.           | | | | +--------> Bit 3: Not used
  347.           | | | +----------> Bit 4: RSX Footer Record Flag
  348.           | | +------------> Bit 5: 8087 Present Flag
  349.           | +--------------> Bit 6: 8087 Support Flag
  350.           +----------------> Bit 7: Large Memory Model Flag
  351.  
  352.         Program Flag format
  353.  
  354. The last 2 CMD files that  we examined  (ECHOVERS and  TESTGIOS)
  355. displayed 10h and 80h; that is  to say:  Bits 4  and 7  set. But
  356. what is the purpose of Bits 5 and 6?
  357.  
  358. Searching for clues in later Digital Research guides,  I finally
  359. found the following  paragraph in  the "Concurrent  CP/M Release
  360. 3.1 Programmer's Reference Guide":
  361.  
  362. 3.1.2 8087 support
  363. ------------------
  364.  
  365. Concurrent CP/M provides optional 8087 support for systems  that
  366. use  the  8087  processor.   This  support  is indicated  by the
  367. Program Flag, byte 127  (7Fh), of  the CMD  file Header  Record.
  368. Setting bit 6 (bit 0 is  least significant  bit) of  the Program
  369. Flag indicates optional 8087 support, which  means that,  if the
  370. 8087 is  present, the  program uses  it; otherwise,  the program
  371. will  emulate  it.  If  bit 5  of the  Program Flag  is set,  it
  372. indicates that the 8087 must be present in order for the program
  373. to run. If no 8087 is present and bit 5 of the  Program Flag  is
  374. set,  the  system returns  an error  when it  tries to  load the
  375. program. The  CHSET utility  can be  used to  set the  program's
  376. header record for optional or required 8087 support.
  377.  
  378. -----------------
  379.  
  380. So, you now know what would mean a Program Flag with a value  of
  381. 20h or 40h.
  382.  
  383. Now that  we have  explained everything  known about  the Header
  384. Record, here is the BASIC program used to learn all this:
  385.  
  386. list
  387. 10 REM HEADER.BAS  by Emmanuel ROCHE
  388. 20 :
  389. 30 PRINT
  390. 40 INPUT "HEADER> Enter CMD File Name: " ; file1$
  391. 50 PRINT
  392. 60 file1$ = file1$ + ".CMD"
  393. 70 :
  394. 80 group$ (1) = "(Code) "
  395. 90 group$ (2) = "(Data) "
  396. 100 group$ (3) = "(Extra)"
  397. 110 group$ (4) = "(Stack)"
  398. 120 group$ (5) = "(Aux.1)"
  399. 130 group$ (6) = "(Aux.2)"
  400. 140 group$ (7) = "(Aux.3)"
  401. 150 group$ (8) = "(Aux.4)"
  402. 160 :
  403. 170 ruler$ =  "+-------+--------+--------+--------+--------+"
  404. 180 :
  405. 190 PRINT TAB(9) " G-Form  G-Length  A-Base   G-Min    G-Max"
  406. 200 PRINT TAB(9) ruler$
  407. 210 :
  408. 220 OPEN "R", #1, file1$, 9
  409. 230 FIELD #1, 1 AS gform1$, 2 AS glength1$, 2 AS abase1$,
  410.     2 AS gmin1$, 2 AS gmax1$
  411. 240 GET #1
  412. 250 :
  413. 260 gform1 = ASC (gform1$)
  414. 270 IF gform1 = 0 THEN GOTO 420
  415. 280 NrSeg1 = NrSeg1 + 1
  416. 290 PRINT group$ (gform1) TAB(9) "|  " ;
  417. 300 PRINT RIGHT$ ("0" + HEX$ (gform1), 2) "h  |  " ;
  418. 310 glength1 = CVI (glength1$)
  419. 320 PRINT RIGHT$ ("000" + HEX$ (glength1), 4) "  |  " ;
  420. 330 abase1 = CVI (abase1$)
  421. 340 PRINT RIGHT$ ("000" + HEX$ (abase1), 4) "  |  " ;
  422. 350 gmin1 = CVI (gmin1$)
  423. 360 PRINT RIGHT$ ("000" + HEX$ (gmin1), 4) "  |  " ;
  424. 370 gmax1 = CVI (gmax1$)
  425. 380 PRINT RIGHT$ ("000" + HEX$ (gmax1), 4) "  |"
  426. 390 PRINT TAB(9) ruler$
  427. 400 GOTO 240
  428. 410 :
  429. 420 CLOSE #1
  430. 430 OPEN "R", #1, file1$, 1
  431. 440 FIELD #1, 1 AS byte1$
  432. 450 GET #1, &H7B
  433. 460 :
  434. 470 PRINT
  435. 480 GET #1 : lofo = ASC (byte1$)
  436. 490 GET #1 : hifo = ASC (byte1$)
  437. 500 fo = hifo + 256 * lofo
  438. 510 PRINT "Offset of Footer Record: " ;
  439. 520 PRINT RIGHT$ ("000" + HEX$ (fo), 4)
  440. 530 GET #1 : lofi = ASC (byte1$)
  441. 540 GET #1 : hifi = ASC (byte1$)
  442. 550 fi = hifi + 256 * lofi
  443. 560 PRINT "Offset of Fixups Record: " ;
  444. 570 PRINT RIGHT$ ("000" + HEX$ (fi), 4)
  445. 580 GET #1 : fl = ASC (byte1$)
  446. 590 PRINT "Program Flag: " ;
  447. 600 PRINT RIGHT$ ("0" + HEX$ (fl), 2)
  448. 610 :
  449. 620 PRINT
  450. 630 PRINT "(" ;
  451. 640 IF fl > &H7F THEN PRINT "Large" ; : GOTO 680
  452. 650 IF NrSeg1 = 1 THEN PRINT "8080" ; : GOTO 680
  453. 660 IF NrSeg1 = 2 THEN PRINT "Small" ; : GOTO 680
  454. 670 IF NrSeg1 > 2 THEN PRINT "Compact" ;
  455. 680 PRINT " Memory Model)"
  456. 690 :
  457. 700 PRINT
  458. 710 CLOSE
  459. 720 END
  460.  
  461. system
  462. A>That's all, folks!
  463.  
  464. Yours Sincerely,
  465. "French Luser"
  466.  
  467.  
  468. EOF
  469.