as86 - Assembler for 8086..80386 processors


SUBMITTED BY: Guest

DATE: June 4, 2014, 6:24 a.m.

FORMAT: Text only

SIZE: 11.7 kB

HITS: 4789

  1. NAME
  2. as86 - Assembler for 8086..80386 processors
  3. SYNOPSIS
  4. as86 [-0123agjuw] [-lm[list]] [-n name] [-o obj] [-b[bin]] [-s sym] [-t textseg] src
  5. as86_encap prog.s prog.v [prefix_] [as86_options]
  6. DESCRIPTION
  7. as86 is an assembler for the 8086..80386 processors, it's syntax is closer to the intel/microsoft form rather than the more normal generic form of the unix system assembler.
  8. The src file can be '-' to assemble the standard input.
  9. This assembler can be compiled to support the 6809 cpu and may even work.
  10. as86_encap is a shell script to call as86 and convert the created binary into a C file prog.v to be included in or linked with programs like boot block installers. The prefix_ argument is a prefix to be added to all variables defined by the source, it defaults to the name of the source file. The variables defined include prefix_start prefix_size and prefix_data to define and contain the code, plus integers containing the values of all exported labels. Either or both the prog.s and prog.v arguments can be '-' for standard in/out.
  11. OPTIONS
  12. -0
  13. start with 16-bit code segment, warn for all instructions > 8086
  14. -1
  15. start with 16-bit code segment, warn for all instructions > 80186
  16. -2
  17. start with 16-bit code segment, warn for all instructions > 80286
  18. -3
  19. start with 32-bit code segment, don't warn for any instructions. (not even 486 or 586)
  20. -a
  21. enable partial compatibility with Minix asld. This swaps the interpretation of round brackets and square brackets as well as making alterations to the code generation and syntax for 16bit jumps and calls. ("jmp @(bx)" is then a valid instruction)
  22. -g
  23. only put global symbols in object or symbol file
  24. -j
  25. replace all short jumps with similar 16 or 32 bit jumps, the 16 bit conditional branches are encoded as a short conditional and a long unconditional branch.
  26. -O
  27. this causes the assembler to add extra passes to try to use forward references to reduce the bytes needed for some instructions. If the labels move on the last pass the assembler will keep adding passes until the labels all stabilise (to a maximum of 30 passes) It's probably not a good idea to use this with hand written assembler use the explicit br bmi bcc style opcodes for 8086 code or the jmp near style for conditional i386 instructions and make sure all variables are defined before they are used.
  28. -l
  29. produce list file, filename may follow
  30. -m
  31. print macro expansions in listing
  32. -n
  33. name of module follows (goes in object instead of source name)
  34. -o
  35. produce object file, filename follows
  36. -b
  37. produce a raw binary file, filename may follow. This is a 'raw' binary file with no header, if there's no -s option the file starts at location 0.
  38. -s
  39. produce an ASCII symbol file, filename follows. The format of this table is designed to be easy to parse for encapsulation and related activities in relation to binary files created with the -b option. If a binary file doesn't start at location zero the first two items in the table are the start and end addresses of the binary file.
  40. -u
  41. assume undefined symbols are imported-with-unspecified segment.
  42. -w-
  43. allow the assembler to print warning messages.
  44. -t n
  45. move all text segment data in segment n+3.
  46. AS86 SOURCE
  47. Special characters
  48. *
  49. Address of the start of the current line.
  50. ; !
  51. Either of these marks the start of a comment. In addition any 'unexpected' character at the start of a line is assumed to be a comment (but it's also displayed to the terminal).
  52. $
  53. Prefix for hexadecimal numbers, the 'C' syntax, eg 0x1234, is also accepted.
  54. %
  55. Prefix for binary numbers.
  56. #
  57. Prefix for immediate operands.
  58. [ ]
  59. Specifies an indirect operand.
  60. Unlike MASM the assembler has no type information on labels just a segment and offset. This means that the way this operator and the immediate prefix work are like traditional assemblers.
  61. Examples:
  62. mov ax,bx
  63. jmp bx
  64. Direct register addressing, the jump copies BX into PC.
  65. mov ax,[bx]
  66. jmp [bx]
  67. Simple indirect register addressing, the jump moves the contents of the location specified by BX into the PC.
  68. mov ax,#1234
  69. Immediate value, ax becomes 1234.
  70. mov ax,1234
  71. mov ax,_hello
  72. mov ax,[_hello]
  73. Absolute addressing, ax is set to contents of location 1234. Note the third option is not strictly consistant but is in place mainly for asld compatibility.
  74. mov ax,_table[bx]
  75. mov ax,_table[bx+si]
  76. mov eax,_table[ebx*4]
  77. mov ax,[bx+_table]
  78. mov ax,[bx+si+_table]
  79. mov eax,[ebx*4+_table]
  80. Indexed addressing, both formats are ok, I think the first is more correct but I tend to used the second. :-)
  81. Conditionals
  82. IF, ELSE, ELSEIF, ENDIF
  83. Numeric condition
  84. IFC, ELSEIFC
  85. String compare (str1,str2)
  86. FAIL .FAIL
  87. Generate user error. Segment related
  88. .TEXT .ROM .DATA .BSS
  89. Set current segment. These can be preceded by the keyword .SECT
  90. LOC
  91. Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 14=MAX. The segment order set by the linker is now 0,4,5,6,7,8,9,A,B,C,D,E,1,2,3. Segment 0 and all segments above 3 are assumed to be text segment. Note the 64k size restrictions are not imposed for segments 3-14. Label type definition
  92. EXPORT PUBLIC .DEFINE
  93. Export label defined in this object
  94. ENTRY
  95. Force linker to include the specified label in a.out
  96. .GLOBL .GLOBAL
  97. Define label as external and force import even if it isn't used.
  98. EXTRN EXTERN IMPORT .EXTERN
  99. Import list of externally defined labels
  100. NB: It doesn't make sense to use imports for raw binary files.
  101. .ENTER
  102. Mark entry for old binary file (obs) Data definition
  103. DB .DATA1 .BYTE FCB
  104. List of 1 byte objects.
  105. DW .DATA2 .SHORT FDB .WORD
  106. List of 2 byte objects.
  107. DD .DATA4 .LONG
  108. List of 4 byte objects.
  109. .ASCII FCC
  110. Ascii string copied to output.
  111. .ASCIZ
  112. Ascii string copied to output with trailing nul byte. Space definition
  113. .BLKB RMB .SPACE
  114. Space is counted in bytes.
  115. .BLKW .ZEROW
  116. Space is counted in words. (2 bytes each)
  117. COMM .COMM LCOMM .LCOMM
  118. Common area data definition Other useful pseudo operations.
  119. .ALIGN .EVEN
  120. Alignment
  121. EQU
  122. Define label
  123. SET
  124. Define re-definable label
  125. ORG .ORG
  126. Set assemble location
  127. BLOCK
  128. Set assemble location and stack old one
  129. ENDB
  130. Return to stacked assemble location
  131. GET INCLUDE
  132. Insert new file (no quotes on name)
  133. USE16 [cpu]
  134. Define default operand size as 16 bit, argument is cpu type the code is expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus later than specified give a warning.
  135. USE32 [cpu]
  136. Define default operand size as 32 bit, argument is cpu type the code is expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus later than specified give a warning. If the cpu is not mentioned the assembler ensures it is >= 80386.
  137. END
  138. End of compilation for this file.
  139. .WARN
  140. Switch warnings
  141. .LIST
  142. Listings on/off (1,-1)
  143. .MACLIST
  144. Macro listings on/off (1,-1) Macros, now working, the general form is like this.
  145. MACRO sax
  146. mov ax,#?1
  147. MEND
  148. sax(1)
  149. Unimplemented/unused.
  150. IDENT
  151. Define object identity string.
  152. SETDP
  153. Set DP value on 6809
  154. MAP
  155. Set binary symbol table map number.
  156. Registers
  157. BP BX DI SI
  158. EAX EBP EBX ECX EDI EDX ESI ESP
  159. AX CX DX SP
  160. AH AL BH BL CH CL DH DL
  161. CS DS ES FS GS SS
  162. CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7
  163. TR3 TR4 TR5 TR6 TR7 ST
  164. Operand type specifiers
  165. BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR
  166. The 'near and 'far' do not allow multi-segment programming, all 'far' operations are specified explicitly through the use of the instructions: jmpi, jmpf, callf, retf, etc. The 'Near' operator can be used to force the use of 80386 16bit conditional branches. The 'Dword' and 'word' operators can control the size of operands on far jumps and calls.
  167. General instructions.
  168. These are in general the same as the instructions found in any 8086 assembler, the main exceptions being a few 'Bcc' (BCC, BNE, BGE, etc) instructions which are shorthands for a short branch plus a long jump and 'BR' which is the longest unconditional jump (16 or 32 bit).
  169. Long branches
  170. BCC BCS BEQ BGE BGT BHI BHIS BLE BLO BLOS BLT BMI BNE BPC BPL BPS BVC BVS BR
  171. Intersegment
  172. CALLI CALLF JMPI JMPF
  173. Segment modifier instructions
  174. ESEG FSEG GSEG SSEG
  175. Byte operation instructions
  176. ADCB ADDB ANDB CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB
  177. Standard instructions
  178. AAA AAD AAM AAS ADC ADD AND ARPL BOUND BSF BSR BSWAP BT BTC BTR BTS CALL CBW CDQ CLC CLD CLI CLTS CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CMPXCHG CSEG CWD CWDE DAA DAS DEC DIV DSEG ENTER HLT IDIV IMUL IN INC INS INSB INSD INSW INT INTO INVD INVLPG INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JE JECXE JECXZ JG JGE JL JLE JMP JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LAR LDS LEA LEAVE LES LFS LGDT LGS LIDT LLDT LMSW LOCK LODB LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ LSL LSS LTR MOV MOVS MOVSB MOVSD MOVSW MOVSX MOVW MOVZX MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR RDMSR REP REPE REPNE REPNZ REPZ RET RETF RETI ROL ROR SAHF SAL SAR SBB SCAB SCAS SCASB SCASD SCASW SCAW SEG SETA SETAE SETB SETBE SETC SETE SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ SGDT SHL SHLD SHR SHRD SIDT SLDT SMSW STC STD STI STOB STOS STOSB STOSD STOSW STOW STR SUB TEST VERR VERW WAIT WBINVD WRMSR XADD XCHG XLAT XLATB XOR
  179. Floating point
  180. F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS FDECSTP FDISI FDIV FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP FIDIV FIDIVR FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1 FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1
  181. Using GASP
  182. The Gnu assembler preprocessor provides some reasonable implementations of user biased pseudo opcodes.
  183. It can be invoked in a form similar to:
  184. gasp
  185. [-a...] file.s [file2.s] |
  186. as86 [...] - [-o obj] [-b bin] Be aware though that Gasp generates an error for .org commands, if you're not using alternate syntax you can use org instead, otherwise use block and endb. The directive export is translated into .global, which forces an import, if you are making a file using -b use public or .define instead.
  187. The GASP list options have no support in as86.

comments powered by Disqus