-
Notifications
You must be signed in to change notification settings - Fork 1
/
ASMDEMO.ASM
491 lines (382 loc) · 11 KB
/
ASMDEMO.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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;Û Sample ASSEMBLY shell for an HP 95LX SysMgr compliant application Û
;Û Copyright 1991 Hewlett Packard Company Û
;Û All rights reserved. Û
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
E_NONE equ 0
E_KEY equ 1
E_BREAK equ 2
E_ACTIV equ 3
E_DEACT equ 4
E_TERM equ 5
E_BRIDGE equ 6
E_GROW equ 7
E_SHRINK equ 8
E_ALARM_EXP equ 9
E_ALARM_DAY equ 10
E_TIMECHANGE equ 11
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
DOSSEG
.model small
.stack 2048
;* NOTE!!! ALL *INITIALIZED* data must go in the .DATA group.
;* ALL *UN-INITIALIZED* data must go in the .DATA? group
;* This is because the un-initialized data doesn't get stored in the
;* program file like the initialized data does, and the SysMgr (and E2M)
;* know how to setup the uninitialized data space for you.
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
.data
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
msgcredit db "Many thanks to all involved, especially:",0
db "Dan T Margaret K Eric V",0
db "Tim W Jeanette S Mark B",0
db "Jerry E Jeanine B Chris B",0
db " Randy S",0
db "Eric E Howard H Terry B Bob W",0
db "Stan B Kevin B Dennis E",0
db "Jean G Dennis E Ralph K Bill W",0
db "Bill J Randy H Jack M Ted B",0
db "Everett K Greg M Dave S Diana B",0
db "Pat M Dan R Jerry S Gabe E",0
db "Jim P Dennis S Max J",0
db "Bruce S Dennis Y Dave O",0
db "Paul S Preston B Steve H Charlie P",0
db "Susan W Mike B Tom L",0
db "Lynn W",0
db 0
msgcredit2 db "Don C Dave V Kent S",0
db "Bill F Tammy B Norbert H",0
db "Dan H Cary H John A",0
db "Tom H Debbie C Karen O",0
db "Scott R Ken C Mark G",0
db "Diana R Dan P Thanhhoa H",0
db "Sandy A Raan Y Fred R",0
db "Sheri D John S Steve S",0
db " Greg U",0
db "Gary P John D",0
db "Michael D Dolores E",0
db " Dave G",0
db "Tom P Tom H",0
db "Carl J Dianne T",0
db " ",0
db " ",0
db 0
msgcredit3 db "Carmen W Cindy B Al B Sarah H",0
db "Kermit Y Nolan B Mike B Mark B",0
db " Peter B Diane K",0
db "Kent H Neal B Rich B Richard M",0
db "Shyam J Jane B Rob C Kevin R",0
db "Randy P Georgia C Ann C Barbara W",0
db "Jack P Peter K Rich dF",0
db " Sarah L Roger D Leslie I",0
db "Tina L Ginny M Dave G Joanne S",0
db "Debbie H Dan M",0
db "Mattie F Eric S Leon N",0
db "Lucy H Mary Jo H Martin S",0
db "Claire S Carol N Eric S",0
db "Eva B Ron B",0
db "Rhonda R Bernie C",0
db " ...and a cast of thousands...",0
db 0
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;* NOTE: ALL items in the UN-INITIALIZED data group MUST be declared in the
;* following format:
;* label opc num dup (?)
;* where 'label' is the name of the item, opc is DB, DW, DD, etc, and
;* 'num' is the number of (bytes, words, longs, etc) that you want.
;* The value in the ()'s MUST be a question mark. NO constants of any
;* sort can be used in this group.
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
.data?
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
start_init_data label byte
;
dispnum dw 1 dup (?)
dispmode db 1 dup (?)
;
currow dw 1 dup (?)
nextstr dw 1 dup (?)
;
event dw 1 dup (?) ; kind
evdata dw 1 dup (?) ; data
evscan db 1 dup (?) ; scan
db 1 dup (?) ; shifts
dw 1 dup (?) ; lics
db 1 dup (?) ; fkey_num
dd 1 dup (?) ; bridge
;
len_init_data equ $-start_init_data
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
.code
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
public start
start:
cld
;* the following two lines are the requisite call to m_init() to log this
;* process into the SysMgr's stack.
mov di,0600h ; m_init()
int 60h
push ds ; DS points to our data space at entry
pop es ; make ES point there too
;* the following four lines of code zero out our uninitialized data space.
lea di,start_init_data ; point to our uninitialized data space
mov cx,len_init_data ; length of our uninitialized data space
xor al,al ; get a 0
rep stosb ; zero our uninitialized data space
call my_init ; call my initialization routine
sti ; make sure interrupts are going
exec_redisp:
;* DISPLAY CURRENT MESSAGE
call do_screen ; show current screen in current mode
;* MAIN EVENT DISPATCH LOOP
exec:
call getkey ; don't come back until a key is ready
cmp al,27 ; ESC key?
jz terminate ; jif yes
cmp al,13 ; ENTER key?
jnz nextscreen
not byte ptr dispmode ; switch display modes
cmp dispmode,0 ; alpha?
jz go_alpha
mov ax,0020h ; G_Mode(G_GRAPHICS);
int 5fh
jmp exec_redisp
go_alpha:
mov ax,0007h ; G_Mode(G_ALPHA);
int 5fh
jmp exec_redisp
;
nextscreen:
mov ax,dispnum ; increment the current display number
inc ax
cmp ax,3
jb @F
xor ax,ax ; wrap back to first screen
@@:
mov dispnum,ax
call do_screen ; show that screen
jmp exec
;
terminate:
;* FIRST DO MY DE-INITIALIZATION
call my_fini
;* THEN TERMINATE TO THE SYSMGR (DO *NOT* USE NORMAL DOS PGM TERMINATE SEQUENCE)
mov di,0601h ; m_fini()
int 60h
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;* ISKEY checks for a key, returns NZ if a key is available, else Z
iskey:
mov di,0101h ; m_nevent()
call get_event
mov ax,event
cmp ax,E_KEY ; keystroke?
jz gotiskey ; jif yes
cmp ax,E_ACTIV ; activating?
jz is_activate ; jif yes
cmp ax,E_DEACT ; de-activating?
jz is_deactivate ; jif yes
cmp ax,E_TERM ; terminate?
jz terminate ; jif yes
iskeyfail:
xor ax,ax ; set ZR flag
ret
gotiskey:
xor ax,ax
inc ax ; set NZ flag
mov ax,evdata ; get keycode
ret
;* THE SYSTEM MANAGER FIRST SENDS A DE-ACTIVATE EVENT. THE NEXT TIME YOU CALL
;* THE SYSMGR TO GET AN EVENT, IT DOESN'T RETURN UNTIL IT'S TIME TO RE-ACTIVATE
;* YOUR AP.
is_deactivate:
call my_fini
jmp iskey
;* WE'VE JUST BEEN RE-ACTIVATED, SO WE NEED TO REDRAW THE SCREEN
is_activate:
call activate_draw
jmp iskey
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;* HANGS UNTIL A KEY IS AVAILABLE
getkey:
mov di,0100h ; m_event()
call get_event
mov ax,event
cmp ax,E_KEY ; keystroke?
jz gotkey ; jif yes
cmp ax,E_ACTIV ; activating?
jz activate ; jif yes
cmp ax,E_DEACT ; de-activating?
jz deactivate ; jif yes
cmp ax,E_TERM ; terminate?
jnz getkey ; jif no, ignore
jmp terminate
gotkey:
mov ax,evdata ; get keycode
ret
;* THE SYSTEM MANAGER FIRST SENDS A DE-ACTIVATE EVENT. THE NEXT TIME YOU CALL
;* THE SYSMGR TO GET AN EVENT, IT DOESN'T RETURN UNTIL IT'S TIME TO RE-ACTIVATE
;* YOUR AP.
deactivate:
call my_fini
jmp getkey
;* WE'VE JUST BEEN RE-ACTIVATED, SO WE NEED TO REDRAW THE SCREEN
activate:
call activate_draw
jmp getkey
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
activate_draw:
push ds
pop es ; make sure ES=DS
call my_init ; do my initialization
call do_screen
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
do_screen:
call clear_screen
mov ax,dispnum
lea di,msgcredit ; point to first possible screen
or ax,ax ; screen 0?
jz ds_draw
lea di,msgcredit2
dec ax ; screen 1?
jz ds_draw
lea di,msgcredit3
ds_draw:
xor dx,dx ; init y-coord/row to 0
cmp dispmode,0 ; alpha?
jz ds_alpha ; jif yes
ds_loop:
xor cx,cx ; set x-coord to 0
mov ax,0f00h
int 5fh
add dx,8 ; move down a row on display
mov si,di ; now skip to next string
ds_skip:
lodsb
or al,al
jnz ds_skip
mov di,si
cmp byte ptr [di],0
jnz ds_loop
ret
;
;
;
ds_alpha:
sub dx,3 ; SysMgr 0,0 is third row of display
ds_aloop:
mov currow,dx ; save current row number
mov ax,0 ; OSTYLE (not really used)
push ax
mov ax,0 ; STYLE
push ax
mov si,di
ds_count:
lodsb
or al,al ; eol?
jnz ds_count ; jif no
mov cx,si
sub cx,di ; get length of string
dec cx ; adjust for NULL char
push cx
mov nextstr,si ; save ptr to next string
push ds
push di ; address of string (far ptr)
xor ax,ax ; column=0
push ax
push dx ; push row
mov di,0300h ; m_disp major/minor function numbers
push di
push di ; dummy ret adr
int 60h ; call SysMgr
add sp,18 ; clean up stack
mov di,nextstr
mov dx,currow
inc dx
cmp byte ptr [di],0
jnz ds_aloop ; loop til done
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;* GET_EVENT provides common code for doing an M_EVENT() or M_NEVENT() call
;* depending upon the contents of DI at entry.
get_event:
lea ax,event
push ds
push ax ; push far ptr to 'event' structure
push di ; csvc arg
push di ; dummy ret adr (as if CSVC called)
int 60h
add sp,8
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
clear_screen:
cmp dispmode,0
jnz clear_graphics
mov ax,40 ; clear 40 columns
push ax
mov ax,16 ; 16 rows
push ax
xor ax,ax ; starting at column 0
push ax
mov ax,-3
push ax ; row -3
mov di,0301h ; F_M_CLEAR = 256*SC_SCREEN + 1
; (major/minor SysMgr function #)
push di
push di ; dummy CSVC ret addr
int 60h ; call SysMgr
add sp,12 ; clean up stack
ret
clear_graphics:
call pen0 ; G_ColorSel(0);
xor ax,ax
xor bx,bx
mov cx,239
mov dx,127
call rectangle ; draw solidfilled rect 0,0 to 239,127
call pen1 ; G_ColorSel(1);
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
pen1:
mov ax,0901h
pencom:
int 5fh
ret
;
pen0:
mov ax,0900h
jmp pencom
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
rectangle:
push cx
push dx
mov cx,ax
mov dx,bx
mov ah,8 ; G_Move(cx,dx)
int 5fh
pop dx
pop cx
mov ax,0501h ; G_Rect(cx,dx,G_SOLIDFILL)
rectend:
int 5fh
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
my_init:
cmp dispmode,0 ; alpha mode?
jz noinit ; jif yes
;* GOTO GRAPHICS
mov ax,0020h ; goto GRAPHICS
int 5fh
noinit:
ret
my_fini:
cmp dispmode,0 ; alpha mode?
jz nouninit ; jif yes
;* GOTO TEXT
mov ax,0007h ; goto TEXT
int 5fh
nouninit:
ret
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
@curseg ends
end start