home *** CD-ROM | disk | FTP | other *** search
- Introductioε t∩ thσ 808╢ architecture.
- Addessinτ modes.
- The instruction set.
- Assembler Syntax of intructions and directives.
- Assembler Directives.
- Assembler Operators
- Invocation of XASM86.COM
- Example listing with comments
- :Thσ 808╢ ha≤ ß 2░ bi⌠ addres≤ bus¼ bu⌠ onl∙ 1╢ bi⌠ registers« T∩ ì
- accommodatσ this¼á thσ SEGMEN╘ registers¼á (CS,DS,SS,ES⌐ arσ useΣ ì
- t∩á suppl∙ thσ mos⌠ significan⌠ 1╢ oµ thσ 2░ bi⌠ physica∞ addres≤ ì
- lines«á Thσ lowe≥ 1╢ bit≤ arσ supplieΣ froφ thσ registe≥ useΣá iε ì
- thσ operation« Thσ segmen⌠ register≤ iε detai∞ are:
-
- ááááááááá CS-The code segment register.
-
- áááááááá Al∞ executablσ codσ mus⌠ residσ iε thσ codσ segment¼ anΣ ì
- áááááááái⌠á use≤ thσ intructioε pointer(IP⌐ t∩ providσ thσ 1╢ bi⌠ ì
- ááááááááoffset within the segment.
-
- áááááááá DS-The data segment register.
-
- ááááááááThσá datßá useΣá b∙á ß prograφá i≤á accessed(b∙á default⌐ ì
- ááááááááusinτ thσ D╙ registe≥ witΦ thσ offse⌠ addres≤ withiεá thσ ì
- áááááááásegmen⌠á provideΣ b∙ thσ addressinτ mode (seσá addressinτ ì
- áááááááámodes)«á Iµá anothe≥ segmen⌠ hold≤ thσ datß t∩ bσ useΣ b∙ ì
- ááááááááthσá program¼á thσá segmen⌠ ma∙ bσ specifieΣá withiεá thσ ì
- ááááááááinstructioεá b∙á usinτá ß SEGMEN╘á OVER-RID┼á PREFIX.(seσ ì
- later)
- áááááááá SS-The stack segment register.
-
- ááááááááThσá datßá iεá ßá prograφá PUSHE─á anΣá POPPE─á ont∩á thσ ì
- áááááááástack(usinτ thσ S╨ a≤ thσ offse⌠ withiε thσ segmen⌠) mus⌠ ì
- ááááááááliσ withiε thσ stacδ segment« Othe≥ register≤ ma∙ usσ thσ ì
- áááááááástacδ segmen⌠ b∙ usinτ thσ appropriatσ SEGMEN╘á OVER-RID┼ ì
- ááááááááPREFIX.
-
- áááááááá ES-The extra segment register.
-
- ááááááááAl∞á strinτ operation≤ usσ thσ extrß segmen⌠ registe≥á a≤ ì
- áááááthe destination segment.
- REGISTERS
-
- Thσá 808╢ ha≤ ┤ 1╢ bi⌠ register≤ tha⌠ caε bσ useΣ a≤ accumulator≤ ì
- fo≥ mos⌠ purposes«á The∙ arσ AX,BX,C╪ AN─ DX« Thesσ register≤ caε ì
- bσ operateΣ oε a≤ 1╢ bi⌠ registers¼á a≤ specifieΣ above,(e.g« AX⌐ ì
- o≥ a≤ independen⌠ ╕ bi⌠ registers¼ b∙ specifyinτ thσ registe≥ anΣ ì
- thσ uppe≥ o≥ lowe≥ ╕ bits«á Fo≥ example¼á thσ 1╢ bi⌠ registe≥á A╪ ì
- caεá bσ specifieΣ a≤ thσ concatenatioε oµ thσ lowe≥ ╕á bits¼á thσ ì
- registe≥ A╠ anΣ thσ uppe≥ ╕ bits¼ thσ registe≥ AH« Apar⌠ froφ thσ ì
- genera∞á arthimetiπ functions¼á eacΦ oµ thesσ ┤á register≤á havσ ì
- somσ implieΣ specia∞ function.
- ááááááááA╪á Thi≤á registe≥á mus⌠ bσ useΣ fo≥ al∞á I╬á anΣá OU╘ ì
- ááááááááinstructions¼á anΣá fo≥ al∞ multiplicatioεá anΣá divisioε ì
- ááááááááinstructions«á Also¼á specifyinτá thi≤á registe≥á a≤á thσ ì
- áááááááásourcσá o≥á destinatioεá fo≥á direc⌠á offse⌠á storinτá o≥ ì
- ááááááááretrieving of data, uses one less instruction byte.
-
- ááááááááB╪á Thi≤ registe≥ caε bσ useΣ a≤ aε inde° registe≥á t∩ ì
- áááááááápoin⌠á int∩á thσá datßá segment¼á togethe≥á witΦá anothe≥ ì
- ááááááááregister or offset.(see addressing modes)
-
- ááááááááC╪á Thi≤á i≤á ß genera∞ coun⌠ registe≥á fo≥á usσá witΦ ì
- ááááááááinstruction≤á sucΦá a≤á decremen⌠á C╪á anΣá jum≡á iµá no⌠ ì
- áááááááázero(LOOP⌐á o≥á fo≥ variablσ shif⌠ instruction≤á sucΦá a≤ ì
- ááááááááshif⌠ registe≥ ε times¼ wherσ ε i≤ helΣ iε CL¿ SH╠ AX,CL)
-
- ááááááááD╪ Thi≤ registe≥ i≤ useΣ fo≥ variablσ por⌠ addressing¼ ì
- ááááááááwherσá thσ por⌠ addres≤ i≤ froφ ░ t∩ FFF╞ h«á I⌠ i≤á als∩ ì
- ááááááááuseΣ a≤ aε extensioε registe≥ t∩ A╪ fo≥ 3▓ bi⌠ operation≤ ì
- áááááinvolved with multiplication and division.
- ááááááááB╨á anΣ S╨ Thesσ arσ 1╢ bi⌠ pointe≥á registers¼á anΣá arσ ì
- ááááááááuseΣ t∩ poin⌠ int∩ thσ stacδ segment« Al∞ PUSHe≤ anΣ POP≤ ì
- ááááááááusσá S╨á anΣ B╨ i≤ useΣ t∩ acces≤ datß oε thσá stacδá no⌠ ì
- áááááááápointeΣ t∩ b∙ SP.
-
- ááááááááS╔ anΣ D╔ Thesσ arσ 1╢ bi⌠ inde° registers¼ useΣ t∩ poin⌠ ì
- ááááááááint∩ thσ datß anΣ extrß segments.
-
- ááááááááI╨ Thi≤ i≤ thσ instructioε pointer¼á ß 1╢ bi⌠ registe≥ t∩ ì
- áááááááápoin⌠á int∩á thσá codσ segmen⌠ thσá thσá nex⌠á executablσ ì
- ááááááááinstruction.
- ááááááááFLA╟ register«á Thi≤ 1╢ bi⌠ registe≥ hold≤ thσ condition≤ ì
- ááááááááof the last applicable operation as follows:-
-
- áááááááá bit 15 [x x x x.OF DF IF TF.SF ZF x AF.x PF x CF]
- ááááááááwhere x is undefined, and the following are:-
- áááááááá OF Set if result caused an overflow (2's complement)
- áááááááá D╞ Se⌠ b∙ softwarσ t∩ causσ aut∩ IN├ o≥ DE├
- áááááááá IF Set by software for interrupt enable
- áááááááá TF TRAP-When set causes interrupt after one instruction
- áááááááá SF Set if instruction caused msb to be set.(sign)
- áááááááá ZF Set if instruction resulted in zero
- áááááááá AF Set if a carry occurred between nibbles
- áááááááá PF Parity flag,set if parity even
- ááááá CF Set if carry occurred from msb(or borrow)
- :Addressinτ modes
- Thσá followinτá tablσá give≤ thσ ful∞ se⌠á oµá possiblσá registe≥ ì
- to/froφ memor∙ addressinτ modes¼ anΣ thσ defaul⌠ segmen⌠ tha⌠ thσ ì
- offse⌠á i≤á placeΣ in«á BX,S╔ anΣ D╔ implicitl∙ addres≤ thσá datß ì
- segment¼á whilσá an∙á combinatioε witΦ B╨ wil∞ acces≤á thσá stacδ ì
- segment« Over-ridσ prefixe≤ arσ allowed.
- áááááááá offset default segment register
- áááááááá (BX) DS
- áááááááá DISP16 DS
- áááááááá (DI) DS
- áááááááá (SI) DS
- áááááááá (BP)+(DI) SS
- áááááááá (BP)+(SI) SS
- áááááááá (BX)+(DI) DS
- áááááááá (BX)+(SI) DS
-
- áááááááá (BX)+DISP8-16 DS
- áááááááá (BP)+DISP8-16 SS
- áááááááá (DI)+DISP8-16 DS
- áááááááá (SI)+DISP8-16 DS
- áááááááá (BP)+(DI)+DISP8-16 SS
- áááááááá (BP)+(SI)+DISP8-16 SS
- áááááááá (BX)+(DI)+DISP8-16 DS
- áááááááá (BX)+(SI)+DISP8-16 DS
- String operations
- Variou≤ onσ bytσ instruction≤ perforφ primitivσ strinτ operation≤ ì
- fo≥ thσ manipulatioε oµ continuou≤ datß strings« Thesσ operation≤ ì
- ma∙á bσá performeΣ repeatedl∙ b∙ precedinτ thσ instructioεá b∙á ß ì
- repeat prefix.( see REP).
- Al∞á thσ strinτ operation≤ usσ S╔ a≤ thσ source¿ defaul⌠á t∩á thσ ì
- datß segment¼á anΣ ma∙ usσ segmen⌠ over-ride)¼á anΣ usσ D╔ a≤ thσ ì
- destination(mus⌠áá bσá iεá extrßá segment)«áá Aut∩á incremen⌠á o≥ ì
- decrement of the registers is specified by the diection flag(DF).
- :Thσáá 808╢áá instructioεá set«áá Iεá al∞á cases,wherσáá meφáá i≤ ì
- specified, reg may be used
-
- Data Transfer
-
- MOV MOVE
- PUSH PUSH ONTO STACK
- POP POP FROM STACK
- XCHG EXCHANGE
- IN IN FROM PORT
- OUT OUT TO PORT
- XLAT TRANSLATE BYTE TO AL
- LEA LOAD EFFECTIVE ADDRESS
- LDS LOAD DOUBLE WORD TO DS (AND ANOTHER REGISTER)
- LES LOAD DOUBLE WORD TO ES (AND ANOTHER)
- LAHF LOAD AH WITH FLAGS
- SAHF STORE AH INTO FLAGS
- PUSHF PUSH FLAGS ONTO STACK
- POPF POP FLAGS FROM STACK
- Arithmetic
-
- ADD ADD
- ADC ADD WITH CARRY
- INC INCREMENT
- SUB SUBTRACT
- SBB SUBRACT WITH BORROW(CARRY FLAG)
- DEC DECREMENT
- AAA ASCII ADJUST FOR ADD
- DAA DECIMAL ADJUST FOR ADD
- AAS ASCII ADJUST FOR SUBRACT
- DAS DECIMAL ADJUST FOR SUBTRACT
- NEG CHANGE SIGN( 2's complement)
- CMP COMPARE
- MUL MULTIPLY (unsigned)
- IMUL MULTIPLY (signed)
- AAM ASCII ADJUST FOR MULTIPLY
- DIV DIVIDE (unsigned)
- IDIV DIVIDE (signed)
- AAD ASCII ADJUST FOR DIVIDE
- CBW CONVERT BYTE TO WORD
- CWD CONVERT WORD TO DOUBLE WORD
- Logic
-
- NOT LOGICAL INVERSION
- SHL(SAL) SHIFT LOGICAL(ARITHMETIC) LEFT
- SHR SHIFT LOGICAL RIGHT
- SAR SHIFT ARITHMETIC RIGHT
- ROL ROTATE LEFT
- ROR ROTATE RIGHT
- RCL ROTATE THRU' CARRY LEFT
- RCR ROTATE THRU' CARRY RIGHT
- AND LOGICAL AND
- TEST AND TO FLAGS, NO RESULT
- OR LOGICAL OR
- XOR EXCLUSIVE OR
- Strings
-
- REP
- REPNZ
- REPZ REPEAT PREFIX
- MOVS MOVE STRING
- CMPS COMPARE STRINGS
- SCAS SCAN STRING
- LODS LOAD STRING
- STOS STORE STRING
- Control transfer
-
- CALL CALL (direct or indirect,with in a segment)
- CALLF CALL (direct or indirect,to another segment)
- JMP JUMP (disp16,direct or indirect)
- JMPF JUMP (direct or indirect,to another segment)
- JMPS JUMP (direct,disp8,-128,+127 bytes)
- RET RETURN FROM CALL WITHIN SEGMENT(optional adding to SP)
- RETF RETURN FROM CALL FROM ANOTHER SEG(optional add to SP)
- JE(JZ) JMP IF EQUAL(ZERO)
- JL(JNGE) JMP ON LESS THAN
- JLE(JNG) JMP ON LESS THAN OR EQUAL
- JB(JNAE) JMP ON BELOW( NOT ABOVE)
- JBE(JNA) JMP ON BELOW OR EQUAL
- JP(JPE) JMP ON PARITY EVEN
- JO JMP ON OVERFLOW
- JS JMP ON SIGN
- JNE(JNZ) JMP ON NOT EQUAL
- JNL(JGE) JMP ON GREATER THAN OR EQUAL
- JNLE(JG) JMP ON GREATER THAN
- JNB(JAE) JMP ON ABOVE OR EQUAL
- JNBE(JA) JMP ON ABOVE
- JNP(JPO) JMP ON NOT PARITY(PARITY ODD)
- JNO JMP ON NOT OVERFLOW
- JNS JMP ON NOT SIGN
- JC JMP ON CARRY(Same as JB)
- JNC JMP ON NOT CARRY(Same as JNB)
- LOOP LOOP CX TIMES
- LOOPZ
- LOOPE LOOP CX TIMES WHILE ZERO(EQUAL)
- LOOPNZ
- LOOPNE LOOP CX TIMES WHILE NOT ZERO
- JCXZ JUMP IF CX NOT ZERO( no flags used)
-
- *¬ Abovσ anΣ belo≈ refe≥ t∩ thσ reletionshi≡ betweeε tw∩ unsigneΣ ì
- values, while greater and less refer to signed values **
- Interrupts
-
- INT INTERRUPT
- INTO INTERRUPT ON OVERFLOW
- IRET INTERRUPT RETURN
-
- Processor Control
-
- CLC CLEAR CARRY FLAG
- CMC COMPLEMENT CARRY FLAG
- STC SET CARRY FLAG
- NOP NO OPERATION (ACTUALLY XCHG AX,AX)
- CLD CLEAR DIRECTION FLAG
- STD SET DIRECTION FLAG
- CLI CLEAR INTERRUPT ENABLE FLAG
- STI SET INTERRUPT ENABLE FLAG
- HLT PROCCESSOR HALT
- WAIT WAIT UNTIL TEST PIN IS ASSERTED
- LOCK LOCK BUS FROM OTHER USERS
- ESC ESCAPE TO EXTERNAL DEVICE ON BUS
- Use of segment over-ride prefixes
-
- Operand register default with over-ride
- IP( code address) CS NEVER
- SP( stack address) SS NEVER
- BP( stack marker) SS DS or ES or CS
- SI or DI( not strings)DS SS or ES or CS
- SI (source strings) DS SS or ES or CS
- DI (dest. strings) ES NEVER
- :Assembler syntax of intructions and directives.
-
- The following is the syntax for an instuction statement.
-
- {label:} {prefix} Mnemonic {Operand(s)} {;comment}
-
- where the fields are as follows
-
- label║á ┴ásymbo∞á followeΣ b∙ ":ó define≤ ß labe∞ a⌠á thσ ì
- curren⌠á valuσá oµá thσ locatioεá counte≥á iεá thσ ì
- curren⌠ segment.(optional)
-
- prefi°á Certaiεá machinσ instruction≤ sucΦá a≤á LOC╦á anΣ ì
- segmen⌠á over-ride≤ ma∙ prefi° othe≥ instructions« ì
- (optional)
-
- mnemoniπá ┴ symbo∞ defineΣ a≤ ß machinσá instruction«á Thi≤ ì
- fielΣá i≤á optiona∞ unles≤ precedeΣá b∙á ßá prefi° ì
- instruction.
- operand(s) Instructions may have 0,1,2 operands.
-
- ;commen⌠ An∙ ╗ appearinτ outsidσ ß characte≥ strinτ begin≤ ì
- ß comment¼ whicΦ i≤ endeΣ by<CR>.(optional)
-
- The following is the syntax for a directive statement.
-
- {name} directive operand(s) {;comment}
-
- where the fields are defined as follows.
-
- name Unlike the label field of an instruction,the name
- field is NEVER terminated with a colon. Directive
- names are legal only for DB,DW,DD,RS and EQU.
-
- directive A keyword described under Assembler Directives.
-
- operands Analogous to operands for instruction mnemonics.
-
- ;comment Exactly as instructions
- :Assembler directives.
-
- Segment start directives.
-
- Al∞á 808╢ statement≤ mus⌠ bσ assigneΣ t∩ onσ oµ thσ fou≥ segment≤ ì
- s∩á the∙á caεá bσ accesseΣ b∙á thσá CPU«á ┴á statemen⌠á directivσ ì
- statement¼á CSE╟á DSEG,SSE╟ o≥ ESE╟ specifie≤ tha⌠ thσ statement≤ ì
- followinτá i⌠ belonτ t∩ tha⌠ segment«á Thi≤ i≤ neccessr∙ s∩á tha⌠ ì
- thσá assemble≥ caε providσ ß segmen⌠ over-ridσ prefi° iµá needed« ì
- The statements are as follows.
-
- CSEG numeric exp.
- CSEG
- CSEG $
- Specifie≤á tha⌠á thσá followinτ statement≤á belonτá t∩á thσá Codσ ì
- Segment« Thσ numeriπ expressioε fixe≤ thσ physica∞ addres≤ oµ thσ ì
- segment¼á anΣá thσá codσá i≤ no⌠á relocatable«á Thσá seconΣá forφ ì
- generate≤á relocatablσ code,anΣ i≤ useΣ wherσ thσ segmen⌠ addres≤ ì
- i≤ no⌠ knowε a⌠ assembl∙ time« Thσ thirΣ forφ i≤ useΣ t∩ continuσ ì
- a segment where it has been interrupted by another SEG directive.
- DSEG numeric exp.
- DSEG
- DSEG $
- Specifies that the following is assigned to the Data Segment.
-
- SSEG numeric exp.
- SSEG
- SSEG $
- Specifies that the following is assigned to the Stack Segment.
-
- ESEG numeric exp.
- ESEG
- ESEG $
- Specifies that the following is assigned to the Extra Segment.
- ORG numeric exp.
- Set≤ thσ offse⌠ oµ thσ locatioε counte≥ iε thσ curren⌠ segmen⌠ t∩ ì
- value of (numeric exp.)
-
- IF and END IF
-
- IF numeric expression
- source line 1
- .
- .
- source line n
- ENDIF
- Cause≤ conditiona∞ assembly.Iµ numeriπ expressioε i≤ non-zero,thσ ì
- line≤á arσ assembled,iµ zer∩ the∙ arσ excluded.NesteΣ I╞á i≤á no⌠ ì
- allowed.
- INCLUDE filename
- Thi≤á include≤á anothe≥ 808╢ filσ iε thσ sourcσ text.Ma∙á no⌠á bσ ì
- nested.File type defaults to .A86 .
-
- END
- Marks the end of the source file.(optional)
-
- EQU
- symbol EQU numeric exp.
- address exp.
- register
- instruction nmemonic
- The required symbol must not be terminated with a ":".
- eg M EQU MOV
- M AX,BX ;assembles as MOV AX,BX
- DB
- Assign≤ storagσ areß iε bytσ format.Thi≤ i≤ thσ onl∙ storagσ typσ ì
- to allow more than 2 bytes of a string.
-
- DW
- Assign≤á ▓á Bytσ word≤ oµ storage(lowes⌠ ╕ bit≤ storeΣ a⌠á lowes⌠ ì
- address).
-
- DD
- Assign≤á ┤ byte≤ oµ storage(A≤ aε addres≤ storage,thσá offse⌠á i≤ ì
- stored at the lowest word, the segment is stored at the highest).
-
- RS
- Reserves storage, but does not initialize it.
- eg BUFFER RS 80h
-
- RB(,RW) numeric exp.
- Reserves a number of bytes(,words),but does not initialize it.
- TITLE string const.
- Prints up to 30 chars at top of each printout page in listing.
-
- PAGESIZE numeric exp.
- Number of lines to a listing page( default 66)
-
- PAGEWIDTH numeric exp
- Number of colomns in listing (default 120,unless direct,=79)
-
- EJECT
- Eject a page during printout.EJECT is printed on next page.
-
- SIMFORM
- Replace≤á ßá forφá feeΣ characte≥ b∙ thσ correc⌠ numbe≥á oµá linσ ì
- feeds.
-
- NOLIST and LIST
- As usual
- :Assembler Operators
- THE 8086 Assembler operators falls into the following types.
-
- arithmetic
- logical
- relational
- segment over-ride
- variable manipulators and creators
-
- The following is the syntax of these operators.
-
- SYNTAX RESULT
- logical
-
- a XOR b
- a OR b
- a AND b
- NOT a a=16 bit
- relational
- a EQ b FFFFh if a=b,0 otherwise
- a LT b
- a LE b
- a GT b
- a GE b
- a NE b
-
- arithmetic
- $ current location,current segment.
- a+b
- a-b
- a*b unsigned
- a/b unsigned
- a MOD b
- a SHL b
- a SHR b
- +a
- -a
- segment over-ride
- ES:
- SS:
- CS:
- DS: over-rides assembler choice
-
- variable manipulators,creators
- SEG a creates no.=segment value
- OFFSET a creates no.=offset within segment
- TYPE a creates no.=1,2 or 4 if type
- is byte,word or dword
- LENGTH a creates no.=length of bytes
- LAST a creates no.=LENGTH-1,otherwise 0
- a PTR b creates type of a,attributes of b
- .a creates variable with offset of a,
- segment=current segment.
-
- :Invocation of XASM86.COM
-
- The cross assembler is run by the following.
-
- XASM86 filename {$optional parameters}
-
- where the filename is {D:}filename{.filetype}
- D:,if specified is the drive name.
- filetype is standard type,default to .A86
- eg XASM86 B:TEST
- would assemble a file B:TEST.A86
-
- The assembler produces 3 output files, as follows.
- filename.LST contains listing of source
- filename.SYM contains all user defined symbols
- filename.H86 contains HEX format listing
-
- Thσá HE╪á forma⌠ listinτ i≤ eithe≥ DIGITA╠ RESEARC╚ (default⌐á o≥ ì
- INTEL format(see below).
- Optional Parameters:
-
- Iε thσ following¼á A,B,C,─ specif∙ valiΣ filedrives¼á ╪ specifie≤ ì
- CO╬ ,┘ specifie≤ LST¼ ┌ specifie≤ NUL(suppres≤ output)
-
- A source file device,followed by A,B,C,D,X,Y,Z
-
- H hex output file device,followed by A,B,C,D,X,Y,Z
-
- P list file device,followed by A,B,C,D,X,Y,Z
-
- S symbol file device,followed by A,B,C,D,X,Y,Z
-
- F format of hex file,followed by I(INTEL),D(DIGITAL)
- eg XASM86 TEST $AD SZ
-
- Assemblσ TEST.A8╢ oε drivσ D║á ¼ producσ TEST.LST anΣ TEST.H8╢ oε
- the same drive, no output of TEST.SYM
-
- eg XASM86 TEST $AD SZ FI
- Same as above, but format of hex file is INTEL.
-
- :Example listing ( with comments)
-
- ASM86 VER 1.0 SOURCE: EXAMPLE.A86 PAGE 1
-
-
- ; ASSEMBLED BY THE INSTRUCTIONS:
- ;
- ;XASM86 EXAMPLE $FI
- ;
- ;The following is an example of an 8086
- ;assembly listing produced by the XASM86
- ;cross-assembler.Where possible the listing
- ;is provided with suitable comments to
- ;highlight certain actions of the assembler
- ;or the 8086 software.
- ;
- ;
- 0010 SSEG 10H ;ACTUAL ADDRESS=100H
- 0000 BOTTOM RW 40H ;40 WORDS
- 0080 TOP RW 0H ;JUST A LABEL
- 0020 DSEG 20H ;ADDRESS AT 200H
- 0000 12 FRED DB 12H ;1 BYTE
- 0001 34 TONY DB 34H ;ANOTHER BYTE
- 0002 34 12 GEORGE DW 1234H ;1 WORD,STORED AS 3412H
- 0004 80 00 10 00 LABEL DD TOP ;ASSEMBLER PICKS SEG,OFFSET
- 0008 45 58 41 4D 50 4C SOURCE DB 'EXAMPLE STRING NUMBER 1' ;TEXT
- 45 20 53 54 52 49
- 4E 47 20 4E 55 4D
- 42 45 52 20 31
- ;
- 0030 ESEG 30H ;ADDRESS AT 300H
- 0000 DESTB RB 40H ;DESTINATION BYTES
- 0040 DESTW RW 20H ;DESTINATION WORDS
- ;
- 0040 CSEG 40H ;ADDRESS AT 400H
- 0000 B8 10 00 START: MOV AX,SEG BOTTOM ;SEGMENT ADDRESS
- 0003 8E D0 MOV SS,AX ;TO SEGMENT REGISTER
- 0005 B8 80 00 MOV AX,OFFSET TOP ;OFFSET IN SEGMENT
- 0008 B8 80 00 MOV AX,LENGTH BOTTOM*TYPE BOTTOM
- 000B 8B E0 MOV SP,AX ;TO STACK POINTER
- ;
- ;The above section of code extracts the segment address of
- ;the stack for SS .The offset of the top of stack is loaded
- ;to the stack pointer,using two operators,giving the same result
- ;(offset and length*type).The same procedure for the other
- ;segment registers used should be done as follows.
- ;Note that the values loaded are immediate values,and not
- ;labels,and thus segment over-ride is not applicable.
- ;
- 000D B8 20 00 MOV AX,SEG LABEL
- 0010 8E D8 MOV DS,AX
- 0012 B8 30 00 MOV AX,SEG DESTB
- 0015 8E C0 MOV ES,AX
- ;
- ;Now to test the type operands,byte/word mixture
- ;
- 0017 A1 02 00 MOV AX,GEORGE
- ;
- ;This is valid,since AX and GEORGE are words
- ** ERROR NO: 8" OPERAND(S) MISMATCH INSTRUCTION
- ASM86 VER 1.0 SOURCE: EXAMPLE.A86 PAGE 2
-
-
- 001A 90 90 90 90 90 90 MOV AX,FRED
- ;
- ;Invalid,since FRED is byte
- ;
- 0020 A1 00 00 MOV AX,WORD PTR FRED
- ;
- ;Valid,since WORD PTR over-rides byte description
- ;for this case.
- ;
- ;Now we try string operations
- ;
- 0023 B9 17 00 MOV CX,LENGTH SOURCE/TYPE DESTB
- 0026 BE 08 00 MOV SI,OFFSET SOURCE
- 0029 BF 00 00 MOV DI,OFFSET DESTB
- 002C F3 A4 REP MOVS DESTB,SOURCE
- ;The operands must be used for the MOVS instruction
- ;to allow the assembler to chose the byte or word
- ;code,and to allow for segment over-ride where valid
- ;
- 002E B9 0C 00 MOV CX,LENGTH SOURCE/TYPE DESTW+1
- 0031 BE 08 00 MOV SI,OFFSET SOURCE
- 0034 BF 40 00 MOV DI,OFFSET DESTW
- 0037 F3 A5 REP MOVS DESTW,WORD PTR SOURCE
- ;
- ;The word type of string move.
- ;
- 0039 26 8B 1E 40 00 MOV BX,DESTW
- ;
- ;Assembler will generate segment over-ride prefix
- ;to segment ES(=26H),or can generate yourself,
- ;(usually error) as follows.
- ;
- 003E 36 8B 1E 40 00 MOV BX,SS:DESTW
-
- END OF ASSEMBLY. NUMBER OF ERRORS: 1