Skip to content

Commit 812414d

Browse files
committed
Byte golfing, cleanup
1 parent ad61505 commit 812414d

File tree

1 file changed

+53
-79
lines changed

1 file changed

+53
-79
lines changed

src/GLABIOS.ASM

Lines changed: 53 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ TURBO_REV EQU 2 ; reversed PPI B (bit 3)
122122
;
123123
VER_NAME EQU 'GLaBIOS'
124124
IFNDEF VER_NUM
125-
VER_NUM EQU '0.2.4' ; (max 5 chars)
125+
VER_NUM EQU '0.2.5' ; (max 5 chars)
126126
ENDIF
127127
IFNDEF VER_DATE
128-
VER_DATE EQU '07/11/23' ; must be MM/DD/YY format
128+
VER_DATE EQU '07/23/23' ; must be MM/DD/YY format
129129
ENDIF
130130
COPY_YEAR EQU '2022-23' ; Copyright year range
131131

@@ -537,10 +537,6 @@ POST_COL_VT EQU POST_COL_LBL_W + L_POST_L
537537
; space between next column
538538
POST_TAB_COL_I EQU POST_TAB_COL - POST_COL_LBL_W - L_POST_L - POST_COL_PAD
539539

540-
; hard drive post display
541-
POST_HD_CHS_L EQU '(' ; chars to enclose CHS display
542-
POST_HD_CHS_R EQU ')'
543-
544540
; prefer period-correct "KB" or IEC "KiB"
545541
IF UNITS_IEC EQ 1
546542
POST_K_UNIT EQU <'KiB'> ; KiB size unit abbrev.
@@ -631,7 +627,7 @@ PPI_B EQU 61H ; PPI (8255) Port B OUT - Speaker, Switch selection, Misc
631627
PPI_C EQU 62H ; PPI (8255) Port C IN - Switches
632628
PPI_CW EQU 63H ; PPI (8255) Port Control Word
633629

634-
; 8042 Keyboard Controller
630+
; 8042 (AT) Keyboard Controller
635631
ATKB_IO EQU 60H ; 8042 Keyboard input/output buffer register
636632
ATKB_CMD EQU 64H ; 8042 Keyboard command/status register
637633

@@ -2227,7 +2223,6 @@ _BDA_ABS ENDS
22272223
; 0030:0000 - Bootstrap temporary stack
22282224
;----------------------------------------------------------------------------;
22292225
_BOOT_STACK SEGMENT AT 30H
2230-
_TEMP_MEM LABEL BYTE ; use for scratch space during POST
22312226
DW 80H DUP(?)
22322227
STACK_TOP DW ?
22332228
_BOOT_STACK ENDS
@@ -3283,7 +3278,7 @@ SETTINGS_SAVE:
32833278

32843279
IF ARCH_SUB_TYPE EQ ARCH_VEN888
32853280
;----------------------------------------------------------------------------;
3286-
; Explicitly set initial speed for Vendex 888-XT
3281+
; Set initial speed for Vendex 888-XT
32873282
;
32883283
CALL TOGGLE_TURBO ; set speed according to PPI (reversed)
32893284
ENDIF
@@ -3906,7 +3901,7 @@ POST_KB_RESET ENDP
39063901
CALL CRLF ; clear row if video type not shown
39073902
ENDIF
39083903

3909-
IF DRAM_REFRESH EQ 1
3904+
IF DRAM_REFRESH EQ 1
39103905
;----------------------------------------------------------------------------;
39113906
; [27B] Verify that the 8237 DMA Channel 0 Terminal Count (TC 0) status bit
39123907
; is on. This test is only done on a cold boot.
@@ -3917,7 +3912,7 @@ POST_KB_RESET ENDP
39173912
JNZ DMA_STATUS_OK ; jump if zero reached
39183913
POST_FLAG_SET PDMA ; else mark in POST error flags
39193914
DMA_STATUS_OK:
3920-
ENDIF
3915+
ENDIF
39213916

39223917
;----------------------------------------------------------------------------;
39233918
; Display Additional Configuration Items such as COM/LPT, CPU, FPU, etc
@@ -4213,8 +4208,7 @@ BOOT_FAIL DB 'Disk Boot Fail.'
42134208
DB ' You monster.'
42144209
NL2_ANY_KEY DB LF
42154210
NL_ANY_KEY DB CR, LF
4216-
ANY_KEY DB 'Press the Any Key'
4217-
DB '...'
4211+
ANY_KEY DB 'Press the Any Key...'
42184212
DB 0
42194213
BANNER_STRINGS ENDP
42204214

@@ -4266,6 +4260,8 @@ STRINGS ENDP
42664260
; Input:
42674261
; AX = starting segment
42684262
; DI = ending segment
4263+
; Output:
4264+
; AX, DI = ending segment
42694265
;
42704266
; Note: ROM init's can clobber any or all registers so important to save
42714267
; any that are used here between calls.
@@ -4274,7 +4270,7 @@ STRINGS ENDP
42744270
; Size: 73 bytes
42754271
;----------------------------------------------------------------------------;
42764272
BIOS_ROM_SCAN PROC
4277-
ASSUME ES:_BDA
4273+
ASSUME ES:_BDA
42784274
PUSHX BP, DS, ES ; some option ROMs may clobber BP
42794275
MOV DS, AX ; DS = starting segment
42804276
CHECK_ROM:
@@ -4346,7 +4342,7 @@ BIOS_ROM_SCAN ENDP
43464342
; Size: 20 bytes
43474343
;----------------------------------------------------------------------------;
43484344
ROM_CHECKSUM PROC
4349-
ASSUME DS:BIOS
4345+
ASSUME DS:BIOS
43504346
PUSH CX
43514347
PUSH SI
43524348
CBW ; AH = 0
@@ -4460,7 +4456,9 @@ ZERO_ALL_RAM:
44604456
ADC AL, POST_COL_VT ; space inner column for 2 or 3 digits
44614457
CALL MOVE_COL ; move to start of inner column
44624458
MOV AX, BX ; move RAM size to AX for display
4459+
PUSH BX ; save RAM size
44634460
CALL OUT_DECU ; display AX as decimal
4461+
POP BX ; restore RAM size
44644462
MOV AX, ES ; AX = last segment tested
44654463
ADD AX, 16 * 1024 SHR 4 ; move to next 16K segment/block
44664464
CMP AX, DX ; is last segment of RAM?
@@ -4722,7 +4720,7 @@ POST_SYS_VIDEO ENDP
47224720
ENDIF
47234721

47244722
;
4725-
; 2 BYTES HERE
4723+
; 0 BYTES HERE
47264724
;
47274725
BYTES_HERE INT_19
47284726

@@ -5130,12 +5128,8 @@ NMI_RESET PROC
51305128
RET
51315129
NMI_RESET ENDP
51325130

5133-
IF POST_VIDEO_TYPE EQ 1
5134-
POST_MDA DB 'Mono', 0
5135-
ENDIF
5136-
51375131
;
5138-
; 1 BYTE HERE
5132+
; 6 BYTES HERE
51395133
;
51405134
BYTES_HERE INT_16
51415135

@@ -5564,8 +5558,6 @@ BYTES_HERE INT_09
55645558
;
55655559
; In short, it needs to do this:
55665560
; https://stanislavs.org/helppc/scan_codes.html
5567-
;
5568-
; TODO: this still needs some clean up.
55695561
;----------------------------------------------------------------------------;
55705562
ORG 0E987H
55715563
INT_09 PROC
@@ -5587,11 +5579,11 @@ INT_09 PROC
55875579
OUT INT_P0, AL ; write EOI to port 0
55885580
STI ; enable interrupts
55895581
CLD ; string functions increment
5590-
IF CPU_TYPE EQ CPU_V20
5582+
IF CPU_TYPE EQ CPU_V20
55915583
PUSHA ; save working registers
5592-
ELSE
5584+
ELSE
55935585
PUSHX BX, CX, DX, DI, SI ; save working registers
5594-
ENDIF
5586+
ENDIF
55955587
PUSHX DS, ES ; save segment registers
55965588
MOV DX, SEG _BDA ; DX = BIOS Data Area
55975589
MOV AL, AH ; AL = original scan code
@@ -5737,7 +5729,6 @@ KB_INT_UC: ; one to use lower case
57375729
KB_INT_NOT_FLAG:
57385730
TEST AH, AH ; test high bit of scan code
57395731
JS INT_KB_DONE ; if set, it is an unhandled break code
5740-
; TODO verify this where 0Eh are caught
57415732
KB_INT_IS_CAPS:
57425733
TEST DL, MASK K1CL ; is CAPS LOCK on?
57435734
JZ KB_INT_IS_CAPS_DONE
@@ -5818,11 +5809,11 @@ KB_INT_CHECK_FULL:
58185809
;
58195810
INT_KB_DONE:
58205811
POPX ES, DS
5821-
IF CPU_TYPE EQ CPU_V20
5812+
IF CPU_TYPE EQ CPU_V20
58225813
POPA ; restore used registers
5823-
ELSE
5814+
ELSE
58245815
POPX SI, DI, DX, CX, BX ; restore used registers
5825-
ENDIF
5816+
ENDIF
58265817
POP AX
58275818
IRET
58285819

@@ -7487,11 +7478,11 @@ INT_10 PROC
74877478
CMP AH, 0FH ; function > 15?
74887479
JA INT_10_IRET ; exit if function not valid
74897480
PUSHX ES, DS, DI ; always preserve these registers
7481+
CLD ; string instructions forward direction
74907482
MOV DI, SEG _BDA ; DS = BDA segment
74917483
MOV DS, DI
74927484
MOV DI, AX ; save AX
74937485
XCHG AH, AL ; AL = function, AH = video mode
7494-
CLD ; string instructions forward direction
74957486
SHL AL, 1 ; word align index
74967487
CBW ; AX = jump index
74977488
XCHG AX, DI ; restore AX, DI = jump offset
@@ -7939,8 +7930,7 @@ INT_10_5 ENDP
79397930
;----------------------------------------------------------------------------;
79407931
; NOTE: The original XT BIOS (and maybe clones) appear to have a bug where
79417932
; if the lines to scroll (AL) is greater than the height of the rectangle
7942-
; it will scroll incorrectly.
7943-
; TODO: Fix this "bug" or be consistent with XT behavior?
7933+
; it will scroll incorrectly. This behavior has been preserved.
79447934
;----------------------------------------------------------------------------;
79457935
INT_10_7 PROC
79467936
STD ; Set direction flag
@@ -8782,9 +8772,9 @@ INT_10_B_SET_PAL:
87828772
IF CPU_TYPE EQ CPU_V20
87838773
ROR BL, 3 ; move low bit into bit 5
87848774
ELSE
8785-
REPT 3
8775+
REPT 3
87868776
ROR BL, 1 ; move low bit into bit 5
8787-
ENDM
8777+
ENDM
87888778
ENDIF
87898779
INT_10_B_DONE:
87908780
OR AL, BL ; combine bytes
@@ -9382,7 +9372,7 @@ MOVE_COL_SET:
93829372
INT 10H ; row = DH, column = DL
93839373
IF CPU_TYPE EQ CPU_V20
93849374
POPA ; restore all registers
9385-
ELSE
9375+
ELSE
93869376
POPX DX, CX, BX, AX
93879377
ENDIF
93889378
RET
@@ -9420,41 +9410,27 @@ SPACE PROC
94209410
RET
94219411
SPACE ENDP
94229412

9423-
;----------------------------------------------------------------------------;
9424-
; Write Unsigned word as decimal to console - preserve all registers
9425-
;----------------------------------------------------------------------------;
9426-
; Input: AX value
9427-
; Size: 33 bytes
9428-
;----------------------------------------------------------------------------;
9429-
OUT_DECU PROC
9430-
PUSHX AX, BX, DX
9431-
CALL OUT_DECU_R
9432-
POPX DX, BX, AX
9433-
RET
9434-
94359413
;----------------------------------------------------------------------------;
94369414
; Write Unsigned word as decimal to console
94379415
;----------------------------------------------------------------------------;
94389416
; Input: AX value
9439-
; Clobbers AX, BX, DX
9417+
; Clobbers: AX, BX
94409418
;----------------------------------------------------------------------------;
9441-
OUT_DECU_R PROC
9419+
OUT_DECU PROC
94429420
MOV BX, 10 ; decimal divisor = 10
9443-
OUT_DECU_DIV:
9421+
OUT_DECU_R:
9422+
PUSH DX ; save remainder digit / caller DX
94449423
XOR DX, DX ; clear high word of dividend
94459424
DIV BX ; AX = DX:AX / 10, DX = DX:AX % 10
94469425
TEST AX, AX ; is zero?
94479426
JZ OUT_DECU_DONE ; loop while AX > 0
9448-
PUSH DX ; save remainder digit
9449-
CALL OUT_DECU_DIV ; recursive call to next division
9450-
POP DX ; restore digit
9427+
CALL OUT_DECU_R ; recursive call to next division
94519428
OUT_DECU_DONE:
94529429
XCHG AX, DX ; AL = digit, AH = 0
9453-
OUT_DECU_OUT_R:
94549430
XOR AX, DBW <0EH, '0'> ; ASCII convert digit, AH = 0EH
9455-
INT 10H
9431+
INT 10H ; write to console
9432+
POP DX ; restore digit
94569433
RET
9457-
OUT_DECU_R ENDP
94589434
OUT_DECU ENDP
94599435

94609436
;----------------------------------------------------------------------------;
@@ -9491,9 +9467,9 @@ BYTE_HEX PROC
94919467
IF CPU_TYPE EQ CPU_V20
94929468
DB 0FH, 28H, 0C0H ; ROL4 AL ; swap nibbles (V20 only)
94939469
ELSE
9494-
REPT 4
9470+
REPT 4
94959471
SHR AL, 1 ; move high nibble to low nibble
9496-
ENDM
9472+
ENDM
94979473
ENDIF
94989474
CALL NIB_HEX ; write low nibble of AL as HEX to console
94999475
POP AX ; restore AL
@@ -9611,16 +9587,17 @@ IO_WAIT_MS_125 ENDP
96119587

96129588
IF POST_VIDEO_TYPE EQ 1
96139589
;----------------------------------------------------------------------------;
9614-
; POST Video Adapter Type Strings (1 of 2)
9615-
; 12 bytes
9590+
; POST Video Adapter Type Strings
9591+
; 17 bytes
96169592
;
96179593
POST_VGA DB 'VGA', 0
96189594
POST_EGA DB 'EGA', 0
96199595
POST_CGA DB 'CGA', 0
9596+
POST_MDA DB 'Mono', 0
96209597
ENDIF
96219598

96229599
;
9623-
; 3 BYTES HERE
9600+
; 8 BYTES HERE
96249601
;
96259602
BYTES_HERE INT_12
96269603

@@ -10390,20 +10367,20 @@ INT_15 ENDP
1039010367
;
1039110368
; Input:
1039210369
; DL = drive #
10393-
; Output:
10394-
; AH = status
1039510370
;
10396-
; AL clobbered
10371+
; Clobbers: AX, BX
1039710372
;
10398-
; Size: 99 bytes
10373+
; Size: 100 bytes
1039910374
;----------------------------------------------------------------------------;
1040010375
SHOW_DISK_PARAMS PROC
10401-
PUSHX BX, CX, DX ; call preserve working registers
10402-
PUSH DX ; save drive ID again
10376+
PUSHX CX, DX ; call preserve working registers
10377+
PUSH DX ; save drive ID
1040310378
CALL GET_DISK_PARAMS ; AL=heads, BX=cyl, CL=sec, DL=#drives
1040410379
POP DX ; restore drive ID
10405-
PUSH AX ; save return status in AH
1040610380
JC SHOW_DISK_PARAMS_DONE ; exit if error getting drive
10381+
PUSH CX ; save sectors/track for CHS display
10382+
PUSH AX ; save heads
10383+
PUSH BX ; save cylinders
1040710384

1040810385
;----------------------------------------------------------------------------;
1040910386
; Display Drive letter
@@ -10413,8 +10390,6 @@ SHOW_DISK_PARAMS PROC
1041310390
AND AL, 0011B ; only drives 0-3
1041410391
ADD AL, 'C' ; convert to drive letter
1041510392
CALL OUT_CHAR
10416-
PUSH CX ; save sectors/track
10417-
PUSH DX ; save heads
1041810393

1041910394
;----------------------------------------------------------------------------;
1042010395
; Display HD size: MiB = C*H*S*512/1024/1024 = C*H*S/2048
@@ -10424,17 +10399,17 @@ SHOW_DISK_PARAMS PROC
1042410399
MUL BX ; DX:AX = heads * sectors * cyl
1042510400
MOV CX, 1024 * (1024 / 512) ; AX = DX:AX / 2048
1042610401
DIV CX ; (size in MB)
10427-
POST_COL_1 POST_HD, POST_CLR_VAL1, 1 ; start column 1, SI = POST_MB
10402+
POST_COL_1 POST_HD, POST_CLR_VAL1 ; start column 1, SI = POST_MB
1042810403
CALL OUT_DECU ; print size in MB
10429-
CALL OUT_SZ ; 'MB', SI = POST_MB
10430-
XCHG AX, BX ; AX = cylinders, BX = size in MB
10404+
CALL OUT_SZ ; 'MB' (SI = POST_MB from above)
10405+
POP AX ; AX = cylinders
1043110406
POST_COL_END ; end column 1
1043210407

1043310408
;----------------------------------------------------------------------------;
1043410409
; Display HD geometry: Cylinders Heads Sectors
1043510410
;
1043610411
POST_COL_2 POST_CHS, POST_CLR_VAL1 ; start column 2
10437-
CALL OUT_DECU_R ; print # cylinders
10412+
CALL OUT_DECU ; print # cylinders
1043810413
CALL SPACE
1043910414
POP AX ; AX = heads
1044010415
CALL OUT_DECU_R ; print # heads
@@ -10444,8 +10419,7 @@ SHOW_DISK_PARAMS PROC
1044410419
POST_COL_END_NL ; end column 2
1044510420

1044610421
SHOW_DISK_PARAMS_DONE:
10447-
POP AX ; restore return status
10448-
POPX DX, CX, BX ; restore working registers
10422+
POPX DX, CX ; restore working registers
1044910423
RET
1045010424

1045110425
POST_CHS DB 'CHS', 0 ; CHS column 2 label
@@ -10602,7 +10576,7 @@ ROM_SCAN_POST_CHK:
1060210576
PRINT_SZ S_OPT_CHK ; display 'Checksum' message
1060310577
MOV AL, DL ; AL = computed checksum
1060410578
CALL BYTE_HEX ; write as hex byte
10605-
JMP SHORT ROM_SCAN_POST_DONE ; end column and return
10579+
JMP ROM_SCAN_POST_DONE ; end column and return
1060610580

1060710581
S_OPT_ROM DB 'ROM', 0
1060810582
S_OPT_SIZE DB 'Size', 0
@@ -10613,7 +10587,7 @@ ROM_SCAN_POST ENDP
1061310587
ENDIF
1061410588

1061510589
;
10616-
; 269 BYTES HERE / (16 BYTES HERE 5150)
10590+
; 274 BYTES HERE / (16 BYTES HERE 5150)
1061710591
;
1061810592
BYTES_HERE GFX_CHARSET
1061910593

0 commit comments

Comments
 (0)