summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/MODE/MODELENG.ASM
blob: dfae017a8eb34c322f18fe03cc8f4d7a118a0461 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
PAGE ,132 ;
TITLE MODELENG.ASM - VARIOUS SERVICE ROUTINES

;This module contains procedures:
;MODELENG - convert 3 digit or less ASCII string to binary number
;GET_MACHINE_TYPE - determine the machine type based on model byte and sub model byte

.XLIST
   INCLUDE STRUC.INC
.LIST
;.SALL

;���������������������������������  P R O L O G  ����������������������������������������ͻ
;�											  �

;  AX001 - P4031: Was allowing rate and delay settings on ATs that did not have
;		  the functionality in the BIOS.  Have to check specifically for
;		  a date of 11/15/85 or later.

;  AX002 - P4543: Add VAIL and SNOWMASS to legal choices for 19200 baud

;�											  �
;���������������������������������  P R O L O G  ����������������������������������������ͼ



;��������������������������������  P U B L I C S  ���������������������������������������ͻ
;�											  �

PUBLIC	 get_machine_type
PUBLIC	 MODELENG

;�											  �
;��������������������������������  P U B L I C S  ���������������������������������������ͼ

;���������������������������������  M A C R O S  ����������������������������������������ͻ
;�											  �

BREAK MACRO destination 	 ;AN001;

JMP   ENDCASE_&destination	 ;AN001;

ENDM				 ;AN001;

;�											  �
;���������������������������������  M A C R O S  ����������������������������������������ͼ


;��������������������������������� E Q U A T E S ����������������������������������������ͻ
;�											  �

AT_or_XT286_or_PS2_50_or_PS2_60  EQU   0FCH  ;AN000;primary model byte for all 286 based machines
BIOS_date			 EQU   ES:[DI]	   ;used for accessing parts of the BIOS date ;AN001;
INTCONV 			 EQU   48	   ;CONVERT ASCII TO NUMERIC
model_byte_AH			 EQU   AH
return_system_configuration	 EQU   0C0H	   ;INT 15H subfunction
system_descriptor_table 	 EQU   ES:[BX]
system_services 		 EQU   15H	   ;ROM BIOS call
XT2				 EQU   0FBH  ;AN000;model byte for 2nd release of XT

INCLUDE  modequat.inc

;�											  �
;��������������������������������  E Q U A T E S  ���������������������������������������ͼ


;������������������������������  S T R U C T U R E S  �����������������������������������ͻ
;�											  �

BIOS_date_struc   STRUC 	       ;in form mm/dd/yy  ;AN001;
   month    DW	  ?					  ;AN001;
   slash1   DB	  ?					;AN001;
   day	    DW	  ?					;AN001;
   slash2   DB	  ?					;AN001;
   year     DW	  ?					;AN001;
BIOS_date_struc   ENDS					;AN001;


system_descriptor    STRUC
   length_of_descriptor    DW	 bogus			;number of bytes in the descriptor table
   primary_model_byte	   DB	 bogus
   secondary_model_byte    DB	 bogus
system_descriptor    ENDS

;�											  �
;������������������������������  S T R U C T U R E S  �����������������������������������ͼ


ROM	SEGMENT AT 0F000H

ORG   0FFF5H				     ;location of date ROM BIOS for the release was written ;AN001;
date_location  LABEL WORD		     ;AN001;

ORG   0FFFEH
model_byte	LABEL	BYTE

ROM	ENDS



PRINTF_CODE   SEGMENT PUBLIC
	 ASSUME CS:PRINTF_CODE,DS:PRINTF_CODE



;������������������������������������  D A T A	�����������������������������������������ͻ
;�											  �

HUNDRED  DB    100
TEN	 DB    10


;�											  �
;������������������������������������  D A T A	�����������������������������������������ͼ


;��������������������������������  E X T R N S	�����������������������������������������ͻ
;�											  �

EXTRN	 machine_type:BYTE	       ;see 'rescode.sal'
EXTRN	 submodel_byte:BYTE	       ;see 'rescode.sal'

;�											  �
;��������������������������������  E X T R N S	�����������������������������������������ͼ


MODELENG PROC	 NEAR
;
;INPUT:BP HAS ADDR OF PARM FIELD IN DATA SPACE (DS:)
;
    MOV    BL,0 		  ;INIT BL TO 0
;   IF THIS PARAMETER IS A THREE DIGIT NUMBER,
    CMP    BYTE PTR DS:[BP]+2,0 ;LOOK AT THIRD DIGIT
    JE	   ENDIF01
    CMP    BYTE PTR DS:[BP]+2,20H		;see if third char is a blank
    JE	   ENDIF01		;IF there is a third digit THEN
;
      MOV    AL,DS:[BP]     ;GET FIRST DIGIT
      SUB    AL,INTCONV     ;CONVERT TO INT
      MUL    HUNDRED	    ;HUNDREDTHS PLACE
      ADD    BL,AL	    ;ADD TO BL
      INC    BP 	    ;BUMP TO NEXT DIGIT
    ENDIF01:	;ENDIF THIS PARAMETER IS A THREE DIGIT NUMBER
    MOV    AL,DS:[BP]	    ;GET NEXT DIGIT
    SUB    AL,INTCONV	    ;CONVERT TO INT
       JNC    ENDIF02
       MOV     BL,0FFH	  ;encountered an error so put a bogus number in the sum
    ENDIF02:
    MUL    TEN		    ;TENS PLACE
    ADD    BL,AL	    ;ADD TO BL
    INC    BP		    ;GO TO NEXT DIGIT
    MOV    AL,DS:[BP]	    ;GET NEXT DIGIT
    SUB    AL,INTCONV	    ;CONVERT TO INT
    ADD    BL,AL	    ;ADD TO BL
    RET
MODELENG ENDP


ascii_to_int   PROC  NEAR  ;input: AX=2 digit ascii number ;AN001;
			   ;output: BL has binary value 	   ;AN001;
			   ;assume: no overflow or underflow	   ;AN001;

    PUSH   AX		    ;the MUL destroys AH		   ;AN001;
    SUB    AL,INTCONV	    ;CONVERT high order digit to binary    ;AN001;
    MUL    TEN		    ;TENS PLACE 			   ;AN001;
    MOV    BL,AL	    ;ADD TO BL				   ;AN001;
    POP    AX							   ;AN001;
    MOV    AL,AH	    ;AL=low order digit 		   ;AN001;
    SUB    AL,INTCONV	    ;CONVERT TO binary			   ;AN001;
    ADD    BL,AL	    ;ADD TO BL				   ;AN001;
    RET 							   ;AN001;

ascii_to_int   ENDP						   ;AN001;


;------------------------------------------------------------------------------

;�������������������������������������������������������������������������������
;�
;� GET_MACHINE_TYPE
;� ----------------
;�
;�  Get the machine type and store for future reference.
;�
;�
;�  INPUT: none
;�
;�
;�  RETURN: A scalar value indicating the type of machine is stored in
;�	    'machine_type'.
;�
;�
;�  MESSAGES: none
;�
;�
;�
;�  REGISTER
;�  USAGE AND
;�  COMVENTIONS: AX - general usage
;�		 BX - used to address the system descriptor table
;�
;�
;�
;�
;�
;�  ASSUMPTIONS: DS has segment of MODE's data area
;�
;�
;�  SIDE EFFECT: ES is changed.
;�
;�
;�������������������������������������������������������������������������������


get_machine_type  PROC	  NEAR



PUSH  ES
PUSH  BX			       ;will be used to point to 'system descriptor table'
MOV   AH,return_system_configuration
INT   15H
.IF   NC	     ;IF the call was handled successfully
   MOV	 AH,system_descriptor_table.secondary_model_byte
   MOV	 submodel_byte,AH				;save submodel byte
   MOV	 AH,system_descriptor_table.primary_model_byte
.ELSE
   MOV	 AX,ROM 		;get addressability to the model byte
   MOV	 ES,AX
   MOV	 AH,ES:model_byte
.ENDIF

.IF <model_byte_AH EQ AT_or_XT286_or_PS2_50_or_PS2_60> THEN    ;AN000;may have a submodel byte, check it

   .IF <submodel_byte EQ PS2Model60> THEN	;AN000;
      MOV   AH,PS2Model60			;AN000;
   .ELSEIF <submodel_byte EQ VAIL> OR		;AN000;
   .IF <submodel_byte EQ PS2Model50> THEN	;AN000;
      MOV   AH,PS2Model50			;AN000;
   .ELSEIF <submodel_byte EQ XT286> THEN	;AN000;
      MOV   AH,XT286				;AN000;
   .ELSEIF <submodel_byte EQ AT3> THEN		;AN000;
      MOV   DI,OFFSET date_location		       ;ES:DI=>BIOS date (BIOS_date EQU ES:[DI])	       ;AN001;

;     CASE BIOS_date=											;AN001;

;	 later than 1985:										;AN001;

	       MOV   AX,BIOS_date.year			 ;AX=ASCII form of BIOS date year	       ;AN001;
	       CALL  ascii_to_int			 ;BL=binary form of BIOS date year		;AN001;
	       .IF <BL GT 85> THEN			 ;IF AT built in 86 or later		  ;AN001;

	    MOV   AH,AT4										;AN001;
	    BREAK 0											;AN001;

	       .ENDIF											;AN001;

;	 1985, on 11/15:	       ;BL already has year from above check				;AN001;

	       .IF <BL EQ 85> AND									;AN001;
	       .IF <BIOS_date.month EQ "11"> AND                                                        ;AN001;
	       .IF <BIOS_date.day EQ "51"> THEN       ;"51" is the word form of "15"                    ;AN001;

	    MOV   AH,AT4										;AN001;
	    BREAK 0											;AN001;

	       .ENDIF											;AN001;

;	 otherwise:		       ;internal release of third version of AT 				       ;AN001;

	    MOV   AH,AT3										;AN001;


       ENDCASE_0:											;AN001;

   .ELSEIF <submodel_byte EQ AT2> THEN		;AN000;
      MOV   AH,AT2				;AN000;
   .ENDIF					;AN000;IF none of the above AH has correct value for AT1 (FC)
.ELSEIF <model_byte_AH EQ XT2> THEN		;AN000;
   MOV	 AH,PCXT				;AN000;no difference from XT1
.ENDIF						;AN000;

MOV   DS:machine_type,AH	 ;AH was set as result of getting the system configuration or during the IF.
POP   BX
POP   ES

RET			;RETURN TO MODE MAIN ROUTINE
get_machine_type  ENDP
PRINTF_CODE   ENDS
    END