forked from numberformat/helppc_reference_library_html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASM.TXT
4138 lines (2576 loc) · 95.3 KB
/
ASM.TXT
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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@Assembler Programming Topics
:8086 architecture
^Intel 8086 Family Architecture
% General Purpose Registers Segment Registers
AH/AL AX (EAX) Accumulator CS Code Segment
BH/BL BX (EBX) Base DS Data Segment
CH/CL CX (ECX) Counter SS Stack Segment
DH/DL DX (EDX) Data ES Extra Segment
(FS) 386 and newer
(Exx) indicates 386+ 32 bit register (GS) 386 and newer
% Pointer Registers Stack Registers
SI (ESI) Source Index SP (ESP) Stack Pointer
DI (EDI) Destination Index BP (EBP) Base Pointer
IP Instruction Pointer
% Status Registers
FLAGS Status Flags (see ~FLAGS~)
% Special Registers (386+ only)
CR0 Control Register 0 DR0 Debug Register 0
CR2 Control Register 2 DR1 Debug Register 1
CR3 Control Register 3 DR2 Debug Register 2
DR3 Debug Register 3
TR4 Test Register 4 DR6 Debug Register 6
TR5 Test Register 5 DR7 Debug Register 7
TR6 Test Register 6
TR7 Test Register 7
% Register Default Segment Valid Overrides
BP SS DS, ES, CS
SI or DI DS ES, SS, CS
DI strings ES None
SI strings DS ES, SS, CS
- see ~CPU~ ~DETECTING~ ~Instruction Timing~
:Instruction Timing
^Instruction Clock Cycle Calculation
Some instructions require additional clock cycles due to a "Next
Instruction Component" identified by a "+m" in the instruction
clock cycle listings. This is due to the prefetch queue being
purge on a control transfers. Below is the general rule for
calculating "m":
88/86 not applicable
286 "m" is the number of bytes in the next instruction
386 "m" is the number of components in the next instruction
(the instruction coding (each byte), plus the data and
the displacement are all considered components)
^8088/8086 Effective Address (EA) Calculation
% Description Clock Cycles
Displacement 6
Base or Index (BX,BP,SI,DI) 5
Displacement+(Base or Index) 9
Base+Index (BP+DI,BX+SI) 7
Base+Index (BP+SI,BX+DI) 8
Base+Index+Displacement (BP+DI,BX+SI) 11
Base+Index+Displacement (BP+SI+disp,BX+DI+disp) 12
- add 4 cycles for word operands at odd addresses
- add 2 cycles for segment override
- 80188/80186 timings differ from those of the 8088/8086/80286
% Task State Calculation
"TS" is defined as switching from VM/486 or 80286 TSS to one of
the following:
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ New Task ³
ÃÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´486 TSS³486 TSS³386 TSS³386 TSS³286 TSS³
³ Old Task ³ (VM=0)³ (VM=1)³ (VM=0)³ (VM=1)³ ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´
386 TSS (VM=0) ³ ³ ³ 309 ³ 226 ³ 282 ³
ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´
386 TSS (VM=1) ³ ³ ³ 314 ³ 231 ³ 287 ³
ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´
386 CPU/286 TSS ³ ³ ³ 307 ³ 224 ³ 280 ³
ÃÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´
486 CPU/286 TSS ³ 199 ³ 177 ³ ³ ³ 180 ³
ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ
% Miscellaneous
- all timings are for best case and do not take into account wait
states, instruction alignment, the state of the prefetch queue,
DMA refresh cycles, cache hits/misses or exception processing.
- to convert clocks to nanoseconds divide one microsecond by the
processor speed in MegaHertz:
^(1000MHz/(n MHz)) = X nanoseconds
- see ~8086 Architecture~
:directives:asm directives
^Macro Assembler Directives
^Processor Code Generation Directives
.186 enables assembly of 80186 instructions
.286 enables assembly of non privileged 80286 instructions
.286C same as .286
.286P enables assembly of all 80286 instructions
.287 enabled assembly of 80287 instructions
.386 enabled assembly of non privileged 80386 instructions
If used before .MODEL segments are defined as 32bits.
Causes all segments to default to DWORD alignment.
.386P enabled assembly of all 80386 instructions (see .386)
.387 enabled assembly of 80387 instructions
.8086 default, enables assembly of 8088/8086 instruction
.8087 default, enables assembly of 8087 instructions
These directives must precede the segment they are to effect.
they cannot occur within a segment.
^Memory Model Directives
.CODE [name] starts code segment; must follow .MODEL directive
.CONST starts a constant data segment with name CONST;
must follow .MODEL directive; placed in DGROUP
.DATA starts a near data segment for initialized data
with name _DATA; must follow .MODEL directive;
placed in DGROUP
.DATA? starts a near data segment for uninitialized
data with name _BSS; must follow .MODEL
directive; placed in DGROUP
.FARDATA [name] not placed in any group
.FARDATA? [name] not placed in any group
.MODEL model defines memory model to be one of the following:
SMALL, COMPACT, MEDIUM, LARGE or HUGE; must be
used prior to any other segment directive
.STACK [size] indicates start of stack segment named 'STACK'
with size indicating number of bytes to reserve,
default is 1k; placed in DGROUP
^Segment Definition, Segment Ordering and Linkage Directives
.ALPHA orders segments alphabetically
.SEQ orders segments sequentially (default)
ASSUME sreg:name [,sreg:name...] selects default segment
register to be used by the assembler, not the CPU,
for addressing all symbols in the segment or group.
Name must be associated with a SEGMENT or GROUP
or set to "NOTHING" to indicate no segment register
is to be associated.
COMM def [,def...] defines variables that are both public and
external (communal). Can be used in and include
file to identify it to each source file without
declaring it in each model as extern. Actually
defines data once. Communal variables cannot be
initialized, and are not guaranteed to be allocated
contiguously since these are allocated by the linker.
DOSSEG orders segments the same as DOS. This is Microsoft
languages default order; causes paragph alignment
END [name] marks end of source module and sets program
start address (CS:IP) if 'name' is present
name ENDP ends procedure 'name'
name ENDS ends a segment or structure
EXTRN name:type [,name:type...] defines one or more external symbols
name GROUP seg[,seg]
name LABEL [NEAR|FAR|PROC] defines an entry point; If PROC is specified,
it's value depends on the current MODEL
NAME pgmName ignored since MASM 5.0; used to set module name
name PROC [NEAR|FAR] defines procedure; NEAR/FAR has .MODEL default
PUBLIC name[,name...] makes symbol 'name' available to other modules
name SEGMENT [align][combine][use]['class']
align = BYTE align on byte address (no alignment)
= WORD align on even address
= DWORD align on DWORD address
= PARA align on next 16 byte paragraph
= PAGE align on next 256 byte boundary
combine = PUBLIC similar named segments are concatenated (CS)
= STACK similar named segments are concatenated (SS)
= COMMON similar named segment are overlapped
= MEMORY similar names segments are concatenated
= AT addr segment relative to absolute address
= nothing segment is private and loaded independent
use = USE16 segments will be 16 bits (if .386)
= USE32 segments will be 32 bits (if .386)
^Data Allocation Directives
ALIGN n aligns next variable or instruction on a boundary
that is a multiple of "n". This can speed memory
fetches on 16 and 32 bit CPU'S if aligned. New to
~MASM~ 5.0, previous versions used EVEN. Can result
in NOP's added to code.
[name] DB init[,init...] define byte
[name] DD init[,init...] define double word (DWORD, 4 bytes)
[name] DF init[,init...] define far word (FWORD, 386, 6 bytes)
[name] DQ init[,init...] define quad word (QWORD, 8 bytes)
[name] DT init[,init...] define temp word (TBYTE, 10 bytes)
[name] DW init[,init...] define word (WORD, 2 bytes)
count DUP (init[,init...]) duplicate 'init' 'count' times; DUP can be
nested to 17 levels; DUP'ed initial values
of (?) don't result in data in the object file
but instead increment the next data addr
name ENDS end of structure or segment
EVEN same as align 2; Aligns data on even boundary
ORG expr sets location counter to 'expr'; If 'expr'
is '$' the code is ORG'ed at the current loc.
name RECORD fld[,fld...] defines a byte or word variable
consisting of bit fields; fields have the format:
fieldname:width[=expr]; the sum of all widths
must be <= 0
[name] STRUC <[init[,init]]> defines beginning of a structure; Values
between <> are initializers; The '<>' symbols
are required.
^Logical and Bit Oriented Directives
expr1 AND expr2 returns nonzero if any set bit matches
expr1 EQ expr2 returns (-1) for true or (0) for false
expr1 GE expr2 returns (-1) for true or (0) for false
expr1 LE expr2 returns (-1) for true or (0) for false
expr1 LT expr2 returns (-1) for true or (0) for false
MASK {fldname|record} returns bit mask for bits in record
expr1 OR expr2 returns bitwise OR on expr1 and expr2
NOT expr returns 'expr' with all bits reversed
expr SHL count returns expr shifted left count times
expr SHR count returns expr shifted right count times
WIDTH {fldname|record} returns width of field in bit record
expr1 XOR expr2 returns bitwise XOR on expr1 and expr2
^Other Operators and Directives
[] index operator, same as addition
.MSFLOAT encode floats in Microsoft Real Format
.TYPE expr returns byte defining mode and scope of expr
name EQU expr assigns expression to name. surround text with <>
HIGH expr returns high byte of 'expr'
INCLUDE filespec inserts code from 'filespec' into file
INCLUDELIB filespec stores link library info in .OBJ file
LENGTH var returns number of data objects in DUPed 'var'
LOW expr returns low byte of 'expr'
expr1 MOD expr2 return remainder of expr1/expr2
OFFSET expr returns offset of expr; When .MODEL is used
the offset of a group relative segment refers
to the end of the segment
type PTR expr forces 'expr' to 'type'
SEG expr returns segment of expression
SHORT sets type of label to short, less than 128
bytes from start of next instruction
SIZE var returns # of bytes allocated by DUP directive
THIS type returns an operand of specified type whose
offset and segment values are equal to the
current location
TYPE expr returns type of expression
% Program Listing and Documentation Directives
.CREF restores listing of cross reference symbols
.LALL include macro expansion in listings
.LFCOND include false conditional blocks in listings
.LIST starts listing of statements
.SALL suppress listing of all macro expansions
.SFCOND suppress false conditional blocks in listings
.XALL start listing of macro expansion
.XCREF [name[,name...]] suppress symbols in cross reference
.XLIST suppress program listing
COMMENT delimiter [text]
PAGE [[len],wid] sets page length&width or ejects if no parms
SUBTTL text defines program listing subtitle
TITLE text defines program listing title
% Condition Assembly Directives
ELSE else clause for conditional assembly block
ENDIF terminates a conditional assembly block
IFDEF name conditional assembly if name is defined
% Macro Definition Directives
ENDM terminates a macro block
EXITM exit macro expansion immediately
IRP parm,<arg[,arg...]> parm in the statements enclosed by the
IRP and ENDM will be repeated and replaced with the
values of "arg" for each "arg" in the <>.
IRPC parm,<string> parm in the statements enclosed by the IRPC
and ENDM will be repeated and replaced with the values
of each char in the "string" for each character
position in the string. "string" should be enclosed
in <> if it contains spaces or other separators.
LOCAL name[,name...] defines scope symbol as local to a macro
name MACRO [parm[,parm...]] defines a macro and it's parameters
PURGE name[,name] purges macros from memory
REPT expr repeats all statements through ENDM statement for
'expr' times
% User Message Directives
.ERR generates and error
.ERR1 generates an error on PASS 1
.ERR2 generates an error on PASS 2
.ERRB <arg> generates an error if 'arg' is blank
.ERRDEF name generates an error if 'name' is previously defined
.ERRDIF[I] <arg1>,<arg2>
.ERRE expr generates and error is 'expr' is false
%OUT text displays 'text' to console
% Predefined Equates (available only if simplified segments are used)
@curseg contains the current segment
@filename current file name without extension
@code contains the current code segment
@codesize 0 for small & compact, 1 for large, medium & huge
@datasize 0 for small & medium, 1 for compact & large, 2=huge
@const contains segment of define by .CONST
@data contains segment of define by .DATA
@data? contains segment of define by .DATA?
@fardata contains segment of define by .FARDATA
@fardata? contains segment of define by .FARDATA?
@stack contains segment of define by .STACK
Most of these are only available if the simplified segment system
is used. @curseg and @filename are available regardless.
% Radix Specifiers
.RADIX expr sets radix [2..16] for numbers (dec. default)
B binary data specifier
Q octal data specifier
O octal data specifier
D decimal data specifier
H hexadecimal data specifier
:masm options:assembler options
^Microsoft Assembler Command Line Options
^MASM [options] srcfile[,[objfile][,[lstfile][,[xreffile]]]][;]
% Options Definition
/A generate segments in alphabetical order
/B[size] sets I/O buffer size in K bytes (1..63, default 32)
/C generate cross reference file with .CRF extension
/D generate PASS 1 listing
/Dsym[=val] define symbol for use during assembly
/E emulate floating point instructions (for use with HLL)
/H list options and command syntax
/Ipath include-file search path
/L generate listing file with .LST extension
/ML case sensitive for all symbols
/MU upper case all symbols (default)
/MX case sensitive in external and public symbols
/N suppress symbol tables in listings
/P check for impure code in 286 and 386 protected
mode (invalid CS overrides)
/S generate segments in the order they are found (default)
/T terse message display; display errors only
/V verbose message display; includes # lines and symbols
/W{0|1|2} assembly warning level
0 = no warnings
1 = severe warnings only
2 = all warnings enabled
/X display complete conditional assembly blocks in
listing including false conditionals
/Z display errors including line numbers to screen
/ZD generate line numbers in .OBJ files
/ZI generate both symbolic and line number information in
.OBJ files
% Environment Variables
INCLUDE search path for include files
MASM default command line options
:flags register:8086 flags
^FLAGS - Intel 8086 Family Flags Register
³11³10³F³E³D³C³B³A³9³8³7³6³5³4³3³2³1³0³
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ CF Carry Flag
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ 1
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ PF Parity Flag
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ 0
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ AF Auxiliary Flag
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ 0
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ ZF Zero Flag
³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ SF Sign Flag
³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ TF Trap Flag (Single Step)
³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ IF Interrupt Flag
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ DF Direction Flag
³ ³ ³ ³ ³ ³ ÀÄÄÄ OF Overflow flag
³ ³ ³ ³ ÀÄÁÄÄÄ IOPL I/O Privilege Level (286+ only)
³ ³ ³ ÀÄÄÄÄÄ NT Nested Task Flag (286+ only)
³ ³ ÀÄÄÄÄÄ 0
³ ÀÄÄÄÄÄ RF Resume Flag (386+ only)
ÀÄÄÄÄÄÄ VM Virtual Mode Flag (386+ only)
- see ~PUSHF~ ~POPF~ ~STI~ ~CLI~ ~STD~ ~CLD~
:models:segment names
^Memory Model Programming & Segment Information
% Model
TINY Data and code fit in one 64K segment. All code and
data are accessed via near pointers.
SMALL 64k data segment max and 64k code segment max. All
code and data are accessed via near pointers.
COMPACT 1Mb data segment max and 64K code segment max. Code
is accessed via near pointers, data is accessed via
far pointers. No array can be greater than 64K
MEDIUM 64K data segment max and 1Mb code segment max. Code is
accessed via far pointers, data is accessed via near pointers.
LARGE 1Mb data segment max and 1Mb code segment max. All
code and data are accessed via far pointers. No
single element can be greater than 64K.
HUGE 1Mb data segment max and 1Mb code segment max. All
code and data are accessed via far pointers. This is
the only model where arrays can be larger than 64K.
In this mode is C will normalize all data pointers
to avoid segment wrapping.
^Small Memory Model
% Directive Segment Alignment Combine Class
.CODE _TEXT WORD PUBLIC 'CODE'
.DATA _DATA WORD PUBLIC 'DATA'
.CONST CONST WORD PUBLIC 'CONST'
.DATA? _BSS WORD PUBLIC 'BSS'
.STACK STACK PARA STACK 'STACK'
^Compact Memory Model
% Directive Segment Alignment Combine Class
.CODE _TEXT WORD PUBLIC 'CODE'
.FARDATA FAR_DATA PARA private 'FAR_DATA'
.FARDATA? FAR_BSS PARA private 'FAR_BSS'
.DATA _DATA WORD PUBLIC 'DATA'
.CONST CONST WORD PUBLIC 'CONST'
.DATA? _BSS WORD PUBLIC 'BSS'
.STACK STACK PARA STACK 'STACK'
^Medium Memory Model
% Directive Segment Alignment Combine Class
.CODE name_TEXT WORD PUBLIC 'CODE'
.DATA _DATA WORD PUBLIC 'DATA'
.CONST CONST WORD PUBLIC 'CONST'
.DATA? _BSS WORD PUBLIC 'BSS'
.STACK STACK PARA STACK 'STACK'
^Large or Huge Memory Models
% Directive Segment Alignment Combine Class
.CODE name_TEXT WORD PUBLIC 'CODE'
.FARDATA FAR_DATA PARA private 'FAR_DATA'
.FARDATA? FAR_BSS PARA private 'FAR_BSS'
.DATA _DATA WORD PUBLIC 'DATA'
.CONST CONST WORD PUBLIC 'CONST'
.DATA? _BSS WORD PUBLIC 'BSS'
.STACK STACK PARA STACK 'STACK'
- all segments fall into DGROUP except for ???_TEXT, FAR_DATA
and FAR_BSS
- see ~ASM DIRECTIVES~
:msw:machine status word
^MSW - Machine Status Word (286+ only)
³31³30-5³4³3³2³1³0³ Machine Status Word
³ ³ ³ ³ ³ ³ ÀÄÄÄÄ Protection Enable (PE)
³ ³ ³ ³ ³ ÀÄÄÄÄÄ Math Present (MP)
³ ³ ³ ³ ÀÄÄÄÄÄÄ Emulation (EM)
³ ³ ³ ÀÄÄÄÄÄÄÄ Task Switched (TS)
³ ³ ÀÄÄÄÄÄÄÄÄ Extension Type (ET)
³ ÀÄÄÄÄÄÄÄÄÄÄ Reserved
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄ Paging (PG)
Bit 0 PE Protection Enable, switches processor between
protected and real mode
Bit 1 MP Math Present, controls function of the ~WAIT~
instruction
Bit 2 EM Emulation, indicates whether coprocessor functions
are to be emulated
Bit 3 TS Task Switched, set and interrogated by coprocessor
on task switches and when interpretting coprocessor
instructions
Bit 4 ET Extension Type, indicates type of coprocessor in
system
Bits 5-30 Reserved
bit 31 PG Paging, indicates whether the processor uses page
tables to translate linear addresses to physical
addresses
- see ~SMSW~ ~LMSW~
:aaa
^AAA - Ascii Adjust for Addition
Usage: AAA
Modifies flags: AF CF (OF,PF,SF,ZF undefined)
Changes contents of AL to valid unpacked decimal. The high order
nibble is zeroed.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 8 3 4 3 1
- see ~Instruction Timing~
:aad
^AAD - Ascii Adjust for Division
Usage: AAD
Modifies flags: SF ZF PF (AF,CF,OF undefined)
Used before dividing unpacked decimal numbers. Multiplies AH by
10 and the adds result into AL. Sets AH to zero. This instruction
is also known to have an undocumented behavior.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 60 14 19 14 2
- see ~Instruction Timing~
:aam
^AAM - Ascii Adjust for Multiplication
Usage: AAM
Modifies flags: PF SF ZF (AF,CF,OF undefined)
Used after multiplication of two unpacked decimal numbers, this
instruction adjusts an unpacked decimal number. The high order
nibble of each byte must be zeroed before using this instruction.
This instruction is also known to have an undocumented behavior.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 83 16 17 15 2
- see ~Instruction Timing~
:aas
^AAS - Ascii Adjust for Subtraction
Usage: AAS
Modifies flags: AF CF (OF,PF,SF,ZF undefined)
Corrects result of a previous unpacked decimal subtraction in AL.
High order nibble is zeroed.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 8 3 4 3 1
- see ~Instruction Timing~
:adc
^ADC - Add With Carry
Usage: ADC dest,src
Modifies flags: AF CF OF SF PF ZF
Sums two binary operands placing the result in the destination.
If CF is set, a 1 is added to the destination.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg 3 2 2 1 2
mem,reg 16+EA 7 7 3 2-4 (W88=24+EA)
reg,mem 9+EA 7 6 2 2-4 (W88=13+EA)
reg,immed 4 3 2 1 3-4
mem,immed 17+EA 7 7 3 3-6 (W88=23+EA)
accum,immed 4 3 2 1 2-3
- see ~Instruction Timing~
:add
^ADD - Arithmetic Addition
Usage: ADD dest,src
Modifies flags: AF CF OF PF SF ZF
Adds "src" to "dest" and replacing the original contents of "dest".
Both operands are binary.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg 3 2 2 1 2
mem,reg 16+EA 7 7 3 2-4 (W88=24+EA)
reg,mem 9+EA 7 6 2 2-4 (W88=13+EA)
reg,immed 4 3 2 1 3-4
mem,immed 17+EA 7 7 3 3-6 (W88=23+EA)
accum,immed 4 3 2 1 2-3
- see ~Instruction Timing~
:and
^AND - Logical And
Usage: AND dest,src
Modifies flags: CF OF PF SF ZF (AF undefined)
Performs a logical AND of the two operands replacing the destination
with the result.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg 3 2 2 1 2
mem,reg 16+EA 7 7 3 2-4 (W88=24+EA)
reg,mem 9+EA 7 6 1 2-4 (W88=13+EA)
reg,immed 4 3 2 1 3-4
mem,immed 17+EA 7 7 3 3-6 (W88=23+EA)
accum,immed 4 3 2 1 2-3
- see ~Instruction Timing~
:arpl
^ARPL - Adjusted Requested Privilege Level of Selector
^(286+ protected mode)
Usage: ARPL dest,src
Modifies flags: ZF
Compares the RPL bits of "dest" against "src". If the RPL bits
of "dest" are less than "src", the destination RPL bits are set
equal to the source RPL bits and the Zero Flag is set. Otherwise
the Zero Flag is cleared.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg - 10 20 9 2
mem,reg - 11 21 9 4
- see ~Instruction Timing~
:bound
^BOUND - Array Index Bound Check (80188+)
Usage: BOUND src,limit
Modifies flags: None
Array index in source register is checked against upper and lower
bounds in memory source. The first word located at "limit" is
the lower boundary and the word at "limit+2" is the upper array bound.
Interrupt 5 occurs if the source value is less than or higher than
the source.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg16,mem32 - nj=13 nj=10 7 2
reg32,mem64 - nj=13 nj=10 7 2
- nj = no jump taken
- see ~Instruction Timing~
:bsf
^BSF - Bit Scan Forward (386+ only)
Usage: BSF dest,src
Modifies flags: ZF
Scans source operand for first bit set. Sets ZF if a bit is found
set and loads the destination with an index to first set bit. Clears
ZF is no bits are found set. BSF scans forward across bit pattern
(0-n) while BSR scans in reverse (n-0).
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg - - 10+3n 6-42 3
reg,mem - - 10+3n 7-43 3-7
reg32,reg32 - - 10+3n 6-42 3-7
reg32,mem32 - - 10+3n 7-43 3-7
- see ~Instruction Timing~
:bsr
^BSR - Bit Scan Reverse (386+ only)
Usage: BSR dest,src
Modifies flags: ZF
Scans source operand for first bit set. Sets ZF if a bit is found
set and loads the destination with an index to first set bit. Clears
ZF is no bits are found set. BSF scans forward across bit pattern
(0-n) while BSR scans in reverse (n-0).
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg,reg - - 10+3n 6-103 3
reg,mem - - 10+3n 7-104 3-7
reg32,reg32 - - 10+3n 6-103 3-7
reg32,mem32 - - 10+3n 7-104 3-7
- see ~Instruction Timing~
:bswap
^BSWAP - Byte Swap (486+ only)
Usage: BSWAP reg32
Modifies flags: none
Changes the byte order of a 32 bit register from big endian to
little endian or vice versa. Result left in destination register
is undefined if the operand is a 16 bit register.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg32 - - - 1 2
- see ~Instruction Timing~
:bt
^BT - Bit Test (386+ only)
Usage: BT dest,src
Modifies flags: CF
The destination bit indexed by the source value is copied into the
Carry Flag.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg16,immed8 - - 3 3 4-8
mem16,immed8 - - 6 6 4-8
reg16,reg16 - - 3 3 3-7
mem16,reg16 - - 12 12 3-7
- see ~Instruction Timing~
:btc
^BTC - Bit Test with Compliment (386+ only)
Usage: BTC dest,src
Modifies flags: CF
The destination bit indexed by the source value is copied into the
Carry Flag after being complimented (inverted).
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg16,immed8 - - 6 6 4-8
mem16,immed8 - - 8 8 4-8
reg16,reg16 - - 6 6 3-7
mem16,reg16 - - 13 13 3-7
- see ~Instruction Timing~
:btr
^BTR - Bit Test with Reset (386+ only)
Usage: BTR dest,src
Modifies flags: CF
The destination bit indexed by the source value is copied into the
Carry Flag and then cleared in the destination.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg16,immed8 - - 6 6 4-8
mem16,immed8 - - 8 8 4-8
reg16,reg16 - - 6 6 3-7
mem16,reg16 - - 13 13 3-7
- see ~Instruction Timing~
:bts
^BTS - Bit Test and Set (386+ only)
Usage: BTS dest,src
Modifies flags: CF
The destination bit indexed by the source value is copied into the
Carry Flag and then set in the destination.
% Clocks Size
% Operands 808x 286 386 486 Bytes
reg16,immed8 - - 6 6 4-8
mem16,immed8 - - 8 8 4-8
reg16,reg16 - - 6 6 3-7
mem16,reg16 - - 13 13 3-7
- see ~Instruction Timing~
:call
^CALL - Procedure Call
Usage: CALL destination
Modifies flags: None
Pushes Instruction Pointer (and Code Segment for far calls) onto
stack and loads Instruction Pointer with the address of proc-name.
Code continues with execution at CS:IP.
% Clocks
% Operands 808x 286 386 486
rel16 (near, IP relative) 19 7 7+m 3
rel32 (near, IP relative) - - 7+m 3
reg16 (near, register indirect) 16 7 7+m 5
reg32 (near, register indirect) - - 7+m 5
mem16 (near, memory indirect) - 21+EA 11 10+m 5
mem32 (near, memory indirect) - - 10+m 5
ptr16:16 (far, full ptr supplied) 28 13 17+m 18
ptr16:32 (far, full ptr supplied) - - 17+m 18
ptr16:16 (far, ptr supplied, prot. mode) - 26 34+m 20
ptr16:32 (far, ptr supplied, prot. mode) - - 34+m 20
m16:16 (far, indirect) 37+EA 16 22+m 17
m16:32 (far, indirect) - - 22+m 17
m16:16 (far, indirect, prot. mode) - 29 38+m 20
m16:32 (far, indirect, prot. mode) - - 38+m 20
ptr16:16 (task, via TSS or task gate) - 177 TS 37+TS
m16:16 (task, via TSS or task gate) - 180/185 5+TS 37+TS
m16:32 (task) - - TS 37+TS
m16:32 (task) - - 5+TS 37+TS
ptr16:16 (gate, same privilege) - 41 52+m 35
ptr16:32 (gate, same privilege) - - 52+m 35
m16:16 (gate, same privilege) - 44 56+m 35
m16:32 (gate, same privilege) - - 56+m 35
ptr16:16 (gate, more priv, no parm) - 82 86+m 69
ptr16:32 (gate, more priv, no parm) - - 86+m 69
m16:16 (gate, more priv, no parm) - 83 90+m 69
m16:32 (gate, more priv, no parm) - - 90+m 69
ptr16:16 (gate, more priv, x parms) - 86+4x 94+4x+m 77+4x
ptr16:32 (gate, more priv, x parms) - - 94+4x+m 77+4x
m16:16 (gate, more priv, x parms) - 90+4x 98+4x+m 77+4x
m16:32 (gate, more priv, x parms) - - 98+4x+m 77+4x
- see ~Instruction Timing~
:cbw
^CBW - Convert Byte to Word
Usage: CBW
Modifies flags: None
Converts byte in AL to word Value in AX by extending sign of AL
throughout register AH.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 2 2 3 3 1
- see ~Instruction Timing~
:cdq
^CDQ - Convert Double to Quad (386+ only)
Usage: CDQ
Modifies flags: None
Converts signed DWORD in EAX to a signed quad word in EDX:EAX by
extending the high order bit of EAX throughout EDX
% Clocks Size
% Operands 808x 286 386 486 Bytes
none - - 2 3 1
- see ~Instruction Timing~
:clc
^CLC - Clear Carry
Usage: CLC
Modifies flags: CF
Clears the Carry Flag.
% Clocks Size
% Operands 808x 286 386 486 Bytes
none 2 2 2 2 1
- see ~Instruction Timing~