forked from fysnet/i440fx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinter.asm
163 lines (146 loc) · 6.25 KB
/
printer.asm
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
comment |*******************************************************************
* Copyright (c) 1984-2024 Forever Young Software Benjamin David Lunt *
* *
* i440FX BIOS ROM v1.0 *
* FILE: printer.asm *
* *
* This code is freeware, not public domain. Please use respectfully. *
* *
* You may: *
* - use this code for learning purposes only. *
* - use this code in your own Operating System development. *
* - distribute any code that you produce pertaining to this code *
* as long as it is for learning purposes only, not for profit, *
* and you give credit where credit is due. *
* *
* You may NOT: *
* - distribute this code for any purpose other than listed above. *
* - distribute this code for profit. *
* *
* You MUST: *
* - include this whole comment block at the top of this file. *
* - include contact information to where the original source is located. *
* https://github.com/fysnet/i440fx *
* *
* DESCRIPTION: *
* printer include file *
* *
* BUILT WITH: NewBasic Assembler *
* http://www.fysnet/newbasic.htm *
* NBASM ver 00.27.15 *
* Command line: nbasm i440fx /z<enter> *
* *
* Last Updated: 8 Dec 2024 *
* *
****************************************************************************
* Notes: *
* *
***************************************************************************|
srvs_17_unknown_call_str db 13,10,'services_17: Unknown call 0x%02X',0
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; The printer services function
; on entry:
; ds = 0x0040
; stack currently has (after we set bp):
; flags cs ip es ds
; [bp+44] [bp+42] [bp+40] [bp+38] [bp+36]
; edi esi ebp esp ebx edx ecx eax
; [bp+04] [bp+08] [bp+12] [bp+16] [bp+20] [bp+24] [bp+28] [bp+32]
; on return
; nothing
; destroys nothing
int17_function proc near ; don't put anything here
push bp
mov bp,sp
;sub sp,4
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; make sure dx < 3
mov bx,REG_DX
cmp bx,0x03
jnb short int17_func_fail
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; get the timeout value
mov cl,[bx+0x78]
xor ch,ch
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; get the port address
shl bx,1
mov dx,[bx+0x08]
or dx,dx
jz short int17_func_fail
; service call
mov ah,REG_AH
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; write character
cmp ah,0x00 ;
jne short @f
mov al,REG_AL
out dx,al
add dx,2
in al,dx
or al,0x01
out dx,al
nop
and al,0xFE
out dx,al
dec dx
int17_func_00_timeout:
in al,dx
test al,0x40
jnz short int17_func_02
loop int17_func_00_timeout
jmp short int17_func_02
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; initialize port
@@: cmp ah,0x01 ;
jne short @f
add dx,2
in al,dx
and al,(~0x04)
out dx,al
nop
or al,0x04
out dx,al
jmp short int17_func_02
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; get printer status
@@: cmp ah,0x02 ;
jne short @f
int17_func_02:
; return the status in ah
mov dx,REG_DX
inc dx
in al,dx
xor al,0x48 ; toggle bits 6 and 3 ?????
; did we timeout (cx = 0 if timed out)
or cx,cx
jnz short int17_func_02_ret
or al,0x01
int17_func_02_ret:
mov REG_AH,al
jmp short int17_func_success
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; unknown function call
@@: push ds
push cs
pop ds
shr ax,8
push ax
mov si,offset srvs_17_unknown_call_str
call bios_printf
add sp,2
pop ds
mov byte REG_AH,0x86
;jmp short int17_func_fail
int17_func_fail:
or word REG_FLAGS,0x0001
mov sp,bp
pop bp
ret
int17_func_success:
and word REG_FLAGS,(~0x0001)
mov sp,bp
pop bp
ret
int17_function endp
.end