EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

Test t8864: COFF object module for 64bit Windows links COFF module


Source & expected listing t8864.htm.lst
| | EUROASM AUTOSEGMENT=ON,CPU=X64,DUMPWIDTH=25 |7438383634 |%test %SET t8864 | |;; | |;; Create the first auxilliary COFF module. | |%test.WB PROGRAM FORMAT=COFF,MODEL=FLAT,WIDTH=64 |[.text] ::::Section changed. |00000000: |Write.W64:: PROC ; Write ASCIIZ string DS:RSI in 64bit Windows. | | IMPORT GetStdHandle:,WriteFile: ; Declare imported Windows kernel functions. |00000000:4889E5 | MOV RBP,RSP ; Save (perhaps unaligned) stack pointer. |00000003:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |00000007:4883EC30 | SUB RSP,5*8+8 ; Allocate shadow space on stack for max 5 arguments. |0000000B:48C7C1F5FFFFFF| MOV RCX,-11 ; %1 Identifier of standard output STD_OUTPUT_HANDLE. |00000012:E8(00000000) | CALL GetStdHandle: ; Fastcall the imported Windows function with 1 argument. |00000017:4889C3 | MOV RBX,RAX ; Temporary save the returned StdOutput handle to RBX. |0000001A:4889F7 | MOV RDI,RSI ; Use RDI to find the end of input string. |0000001D:31C9 | XOR ECX,ECX ; Clear RCX to keep the size of input string. |0000001F:31C0 | XOR EAX,EAX ; Clear AL, the searched terminating character. |00000021:48F7D1 | NOT RCX ; Assume unlimited possible string size. |00000024:F2AE | REPNE SCASB ; Find the zero terminator. |00000026:48F7D1 | NOT RCX ; Get string size to RCX. |00000029:4889442420 | MOV [RSP+20h],RAX ; %5 Overlapped I/O is not used. |0000002E:4C8D4C2418 | LEA R9,[RSP+18h] ; %4 Local variable for the number of written bytes uses shadowed R9. |00000033:4989C8 | MOV R8,RCX ; %3 String size. |00000036:4889F2 | MOV RDX,RSI ; %2 String address. |00000039:4889D9 | MOV RCX,RBX ; %1 Standard output file handle. |0000003C:E8(00000000) | CALL WriteFile: ; Fastcall the imported function with 5 arguments. |00000041:4889EC | MOV RSP,RBP ; Restore the stack. |00000044:C3 | RET ; Return to caller. |00000045: | ENDPROC Write.W64: | |;; |00000045: |Beep.W64:: PROC ; Play a sound in 64bit Windows. |00000045:488D35(000000~| LEA RSI,[=B"Beeping..."] ; Define a literal string in [.rodata]. |0000004C:E8AFFFFFFF | CALL Write.W64:: ; Display the notification "Beeping...". | | IMPORT Beep: ; Declare imported Windows kernel function. |00000051:4889E5 | MOV RBP,RSP ; Save (perhaps unaligned) stack pointer. |00000054:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |00000058:4883EC20 | SUB RSP,4*8 ; Allocate shadow space on stack. |0000005C:BAC8000000 | MOV RDX,200 ; %2 Sound duration [ms]. |00000061:B9B8010000 | MOV RCX,440 ; %1 Sound frequency [Hz]. |00000066:E8(00000000) | CALL Beep: ; Fastcall the imported function with 2 arguments. |0000006B:BA90010000 | MOV RDX,400 ; %2 Sound duration [ms]. |00000070:B94B020000 | MOV RCX,587 ; %1 Sound frequency [Hz]. |00000075:E8(00000000) | CALL Beep: ; Fastcall the imported function with 2 arguments. |0000007A:4889EC | MOV RSP,RBP ; Restore the stack. |0000007D:C3 | RET ; Return to caller. |0000007E: | ENDPROC Beep.W64: |[@LT1] ====ListLiterals in section [@LT1]. |00000000:42656570696E~~=B"Beeping..." | |ENDPROGRAM %test.WB | **** ListMap "t8864.WB.obj",model=FLAT,groups=0,segments=3,entry=,stack= | [.text],FA=0000008Ch,RVA=00000000h,size=0000007Eh=126,width=64,align=0010h,purpose=CODE | [.rodata],FA=0000013Ch,RVA=00000000h,size=0000000Bh=11,width=64,align=0010h,purpose=RODATA+LITERAL | [.drectve],FA=00000147h,RVA=00000000h,size=00000034h=52,width=0,align=1,purpose=DRECTVE | **** ListGlobals "t8864.WB.obj",Global=0,Public=2,Extern=0,eXport=0,Import=3 | Beep,[Beep]:00000000h,scope='I',lib="kernel32.dll" | Beep.W64,[.text]:00000045h,scope='P' | GetStdHandle,[GetStdHandle]:00000000h,scope='I',lib="kernel32.dll" | Write.W64,[.text]:00000000h,scope='P' | WriteFile,[WriteFile]:00000000h,scope='I',lib="kernel32.dll" | |;; | |;; Create the second auxilliary COFF module. | |%test.EX PROGRAM FORMAT=COFF,MODEL=FLAT,WIDTH=64 |[.text] ::::Section changed. |00000000: |Exit.W64:: PROC ; Terminate program in 64bit Windows. |00000000:488D35(000000~| LEA RSI,[.M:] ; Address in segment [.bss] for the message. |00000007:C706456E6400 | MOVD [RSI+0],"End" ; Dynamically define the message "End". |0000000D:C746030D0A0000| MOVD [RSI+3],0x0A0D ; CR+LF. |00000014:E8(00000000) | CALL Write.W64:: ; Display the notification "End". | | IMPORT ExitProcess ; Declare imported Windows kernel function. |00000019:4883E4F0 | AND RSP,-16 ; OWORD alignment downwards. |0000001D:4883EC20 | SUB RSP,4*8 ; Allocate shadow space on stack. |00000021:31C9 | XOR ECX,ECX ; %1 Terminate with errorlevel 0. |00000023:E9(00000000) | JMP ExitProcess: ; Use imported function with 1 argument. No return. |[.bss] ::::Section changed. |00000000:..............|.M: DB 7*BYTE ; Reserve space for ASCIIZ string "End" in segment [.bss]. |[.text] ::::Section changed. |00000028: | ENDPROC Exit.W64: | |ENDPROGRAM %test.EX | **** ListMap "t8864.EX.obj",model=FLAT,groups=0,segments=3,entry=,stack= | [.text],FA=0000008Ch,RVA=00000000h,size=00000028h=40,width=64,align=0010h,purpose=CODE | [.bss],FA=00000000h,RVA=00000000h,size=00000007h=7,width=64,align=0010h,purpose=BSS | [.drectve],FA=000000D2h,RVA=00000000h,size=00000014h=20,width=0,align=1,purpose=DRECTVE | **** ListGlobals "t8864.EX.obj",Global=0,Public=1,Extern=1,eXport=0,Import=1 | Exit.W64,[.text]:00000000h,scope='P' | ExitProcess,[ExitProcess]:00000000h,scope='I',lib="kernel32.dll" | Write.W64,[Write.W64]:00000000h,scope='E' | |;; | |;; Create the main COFF module. | |%test PROGRAM FORMAT=COFF,MODEL=FLAT,WIDTH=64 | | LINK %test.WB.obj, %test.EX.obj |[.data] ::::Section changed. |00000000:363462697420~~|Msg:: DB '%^WIDTH[]bit %^MODEL %^FORMAT program "%^OUTFILE".',13,10,0 | |ENDPROGRAM %test |# I0560 Linking COFF module ".\t8864.WB.obj". |# I0563 Accepting link directive '/IMPORT:GetStdHandle'. |# I0563 Accepting link directive '/IMPORT:WriteFile'. |# I0563 Accepting link directive '/IMPORT:Beep'. |# I0560 Linking COFF module ".\t8864.EX.obj". |# I0563 Accepting link directive '/IMPORT:ExitProcess'. | **** ListMap "t8864.obj",model=FLAT,groups=0,segments=5,entry=,stack= | [.text],FA=000000DCh,RVA=00000000h,size=000000A8h=168,width=64,align=0010h,purpose=CODE | [.rodata],FA=000001CAh,RVA=00000000h,size=0000000Bh=11,width=64,align=0010h,purpose=RODATA | [.data],FA=000001D5h,RVA=00000000h,size=00000027h=39,width=64,align=0010h,purpose=DATA | [.bss],FA=00000000h,RVA=00000000h,size=00000007h=7,width=64,align=0010h,purpose=BSS | [.drectve],FA=000001FCh,RVA=00000000h,size=00000048h=72,width=0,align=1,purpose=DRECTVE | **** ListGlobals "t8864.obj",Global=0,Public=4,Extern=0,eXport=0,Import=4 | Beep,[Beep]:00000000h,scope='I',lib="kernel32.dll" | Beep.W64,[.text]:00000045h,scope='P' | Exit.W64,[.text]:00000080h,scope='P' | ExitProcess,[ExitProcess]:00000000h,scope='I',lib="kernel32.dll" | GetStdHandle,[GetStdHandle]:00000000h,scope='I',lib="kernel32.dll" | Msg,[.data]:00000000h,scope='P' | Write.W64,[.text]:00000000h,scope='P' | WriteFile,[WriteFile]:00000000h,scope='I',lib="kernel32.dll"
Expected messages t8864.out
I0180 Assembling source file "t8864.htm". I0270 Assembling source "t8864". I0310 Assembling source pass 1. I0330 Assembling source pass 2 - final. I0470 Assembling program "t8864.WB". "t8864.htm"{45} I0510 Assembling program pass 1. "t8864.htm"{45} I0510 Assembling program pass 2. "t8864.htm"{45} I0530 Assembling program pass 3 - final. "t8864.htm"{45} I0660 64bit FLAT COFF file "t8864.WB.obj" created, size=702. "t8864.htm"{89} I0650 Program "t8864.WB" assembled in 3 passes with errorlevel 0. "t8864.htm"{89} I0470 Assembling program "t8864.EX". "t8864.htm"{102} I0510 Assembling program pass 1. "t8864.htm"{102} I0510 Assembling program pass 2. "t8864.htm"{102} I0530 Assembling program pass 3 - final. "t8864.htm"{102} I0660 64bit FLAT COFF file "t8864.EX.obj" created, size=483. "t8864.htm"{118} I0650 Program "t8864.EX" assembled in 3 passes with errorlevel 0. "t8864.htm"{118} I0470 Assembling program "t8864". "t8864.htm"{129} I0510 Assembling program pass 1. "t8864.htm"{129} I0510 Assembling program pass 2. "t8864.htm"{129} I0530 Assembling program pass 3 - final. "t8864.htm"{129} I0560 Linking COFF module ".\t8864.WB.obj". "t8864.htm"{133} I0563 Accepting link directive '/IMPORT:GetStdHandle'. "t8864.htm"{133} I0563 Accepting link directive '/IMPORT:WriteFile'. "t8864.htm"{133} I0563 Accepting link directive '/IMPORT:Beep'. "t8864.htm"{133} I0560 Linking COFF module ".\t8864.EX.obj". "t8864.htm"{133} I0563 Accepting link directive '/IMPORT:ExitProcess'. "t8864.htm"{133} I0660 64bit FLAT COFF file "t8864.obj" created, size=1069. "t8864.htm"{133} I0650 Program "t8864" assembled in 3 passes with errorlevel 0. "t8864.htm"{133} I0750 Source "t8864" (262 lines) assembled in 2 passes with errorlevel 0. I0860 Listing file "t8864.htm.lst" created, size=8650. I0990 EuroAssembler terminated with errorlevel 0.
Expected output file t8864. obj
0000: 64 86 05 00 00 00 00 00 44 02 00 00 17 00 00 00  d¤·°°°°°D·°°·°°°
0010: 00 00 20 00 2E 74 65 78 74 00 00 00 00 00 00 00  °°¯°.text°°°°°°°
0020: 00 00 00 00 A8 00 00 00 DC 00 00 00 84 01 00 00  °°°°¤°°°¤°°°¤·°°
0030: 00 00 00 00 07 00 00 00 20 00 50 60 2E 72 6F 64  °°°°·°°°¯°P`.rod
0040: 61 74 61 00 00 00 00 00 00 00 00 00 0B 00 00 00  ata°°°°°°°°°·°°°
0050: CA 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ¤·°°°°°°°°°°°°°°
0060: 40 00 50 40 2E 64 61 74 61 00 00 00 00 00 00 00  @°P@.data°°°°°°°
0070: 00 00 00 00 27 00 00 00 D5 01 00 00 00 00 00 00  °°°°'°°°¤·°°°°°°
0080: 00 00 00 00 00 00 00 00 40 00 50 C0 2E 62 73 73  °°°°°°°°@°P¤.bss
0090: 00 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00  °°°°°°°°°°°°·°°°
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
00B0: 80 00 50 C0 2E 64 72 65 63 74 76 65 00 00 00 00  ¤°P¤.drectve°°°°
00C0: 00 00 00 00 48 00 00 00 FC 01 00 00 00 00 00 00  °°°°H°°°¤·°°°°°°
00D0: 00 00 00 00 00 00 00 00 00 0A 10 02 48 89 E5 48  °°°°°°°°°¬··H¤¤H
00E0: 83 E4 F0 48 83 EC 30 48 C7 C1 F5 FF FF FF E8 00  ¤¤¤H¤¤0H¤¤¤¤¤¤¤°
00F0: 00 00 00 48 89 C3 48 89 F7 31 C9 31 C0 48 F7 D1  °°°H¤¤H¤¤1¤1¤H¤¤
0100: F2 AE 48 F7 D1 48 89 44 24 20 4C 8D 4C 24 18 49  ¤¤H¤¤H¤D$¯L¤L$·I
0110: 89 C8 48 89 F2 48 89 D9 E8 00 00 00 00 48 89 EC  ¤¤H¤¤H¤¤¤°°°°H¤¤
0120: C3 48 8D 35 00 00 00 00 E8 AF FF FF FF 48 89 E5  ¤H¤5°°°°¤¤¤¤¤H¤¤
0130: 48 83 E4 F0 48 83 EC 20 BA C8 00 00 00 B9 B8 01  H¤¤¤H¤¤¯¤¤°°°¤¤·
0140: 00 00 E8 00 00 00 00 BA 90 01 00 00 B9 4B 02 00  °°¤°°°°¤¤·°°¤K·°
0150: 00 E8 00 00 00 00 48 89 EC C3 90 90 48 8D 35 00  °¤°°°°H¤¤¤¤¤H¤5°
0160: 00 00 00 C7 06 45 6E 64 00 C7 46 03 0D 0A 00 00  °°°¤·End°¤F··¬°°
0170: E8 67 FF FF FF 48 83 E4 F0 48 83 EC 20 31 C9 E9  ¤g¤¤¤H¤¤¤H¤¤¯1¤¤
0180: 00 00 00 00 13 00 00 00 13 00 00 00 04 00 3D 00  °°°°·°°°·°°°·°=°
0190: 00 00 16 00 00 00 04 00 48 00 00 00 08 00 00 00  °°·°°°·°H°°°·°°°
01A0: 04 00 67 00 00 00 0F 00 00 00 04 00 76 00 00 00  ·°g°°°·°°°·°v°°°
01B0: 0F 00 00 00 04 00 83 00 00 00 02 00 00 00 04 00  ·°°°·°¤°°°·°°°·°
01C0: A4 00 00 00 12 00 00 00 04 00 42 65 65 70 69 6E  ¤°°°·°°°·°Beepin
01D0: 67 2E 2E 2E 00 36 34 62 69 74 20 46 4C 41 54 20  g...°64bit¯FLAT¯
01E0: 43 4F 46 46 20 70 72 6F 67 72 61 6D 20 22 74 38  COFF¯program¯"t8
01F0: 38 36 34 2E 6F 62 6A 22 2E 0D 0A 00 20 2F 49 4D  864.obj".·¬°¯/IM
0200: 50 4F 52 54 3A 42 65 65 70 20 2F 49 4D 50 4F 52  PORT:Beep¯/IMPOR
0210: 54 3A 47 65 74 53 74 64 48 61 6E 64 6C 65 20 2F  T:GetStdHandle¯/
0220: 49 4D 50 4F 52 54 3A 57 72 69 74 65 46 69 6C 65  IMPORT:WriteFile
0230: 20 2F 49 4D 50 4F 52 54 3A 45 78 69 74 50 72 6F  ¯/IMPORT:ExitPro
0240: 63 65 73 73 2E 66 69 6C 65 00 00 00 00 00 00 00  cess.file°°°°°°°
0250: FE FF 00 00 67 01 74 38 38 36 34 2E 68 74 6D 00  ¤¤°°g·t8864.htm°
0260: 00 00 00 00 00 00 00 00 2E 62 73 73 00 00 00 00  °°°°°°°°.bss°°°°
0270: 00 00 00 00 04 00 00 00 03 01 00 00 00 00 00 00  °°°°·°°°··°°°°°°
0280: 00 00 00 00 00 00 00 00 00 00 00 00 2E 64 61 74  °°°°°°°°°°°°.dat
0290: 61 00 00 00 00 00 00 00 03 00 00 00 03 01 27 00  a°°°°°°°·°°°··'°
02A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
02B0: 2E 64 72 65 63 74 76 65 00 00 00 00 05 00 00 00  .drectve°°°°·°°°
02C0: 03 01 48 00 00 00 00 00 00 00 00 00 00 00 00 00  ··H°°°°°°°°°°°°°
02D0: 00 00 00 00 2E 72 6F 64 61 74 61 00 00 00 00 00  °°°°.rodata°°°°°
02E0: 02 00 00 00 03 01 0B 00 00 00 00 00 00 00 00 00  ·°°°···°°°°°°°°°
02F0: 00 00 00 00 00 00 00 00 2E 74 65 78 74 00 00 00  °°°°°°°°.text°°°
0300: 00 00 00 00 01 00 00 00 03 01 A8 00 00 00 07 00  °°°°·°°°··¤°°°·°
0310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
0320: 04 00 00 00 00 00 00 00 02 00 0C 00 03 00 40 4C  ·°°°°°°°·°·°·°@L
0330: 54 31 00 00 00 00 00 00 00 00 02 00 01 01 03 00  T1°°°°°°°°·°···°
0340: 00 00 00 00 13 00 00 00 00 00 00 00 04 00 0C 00  °°°°·°°°°°°°·°·°
0350: 03 00 42 65 65 70 00 00 00 00 00 00 00 00 00 00  ·°Beep°°°°°°°°°°
0360: 01 01 02 00 42 65 65 70 2E 57 36 34 45 00 00 00  ···°Beep.W64E°°°
0370: 01 00 01 02 02 00 45 78 69 74 2E 57 36 34 80 00  ·°···°Exit.W64¤°
0380: 00 00 01 00 01 02 02 00 00 00 00 00 1E 00 00 00  °°·°···°°°°°·°°°
0390: 00 00 00 00 00 00 01 01 02 00 00 00 00 00 2A 00  °°°°°°···°°°°°*°
03A0: 00 00 00 00 00 00 00 00 01 01 02 00 4D 73 67 00  °°°°°°°°···°Msg°
03B0: 00 00 00 00 00 00 00 00 03 00 0C 00 02 00 00 00  °°°°°°°°·°·°·°°°
03C0: 00 00 37 00 00 00 00 00 00 00 01 00 01 02 02 00  °°7°°°°°°°·°···°
03D0: 00 00 00 00 41 00 00 00 00 00 00 00 00 00 01 01  °°°°A°°°°°°°°°··
03E0: 02 00 4B 00 00 00 3D 42 22 42 65 65 70 69 6E 67  ·°K°°°=B"Beeping
03F0: 2E 2E 2E 22 00 45 78 69 74 2E 57 36 34 2E 4D 00  ..."°Exit.W64.M°
0400: 45 78 69 74 50 72 6F 63 65 73 73 00 47 65 74 53  ExitProcess°GetS
0410: 74 64 48 61 6E 64 6C 65 00 57 72 69 74 65 2E 57  tdHandle°Write.W
0420: 36 34 00 57 72 69 74 65 46 69 6C 65 00           64°WriteFile°

▲Back to the top▲