flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > fasmg - Add EFI x64 sample to x86 |
Author |
|
Akeo 19 Aug 2016, 10:31
Hi,
I like the work being conducted with the generic assembler, and the whole design concept behind it, so, since I'm playing with UEFI, I created a new x86 sample for EFI (for x86_64) called efi64.asm, if you want to consider it for inclusion. With this, I think the x86 samples could provide a comprehensive portfolio of what people may be interested in. Before the sample can be added however, the following modification needs to be applied to examples/x86/include/format/format.inc, to enable the EFI subsystem for PE. Also, since the sample is using 'du', a new utf8.inc should probably be added to examples/x86/include/ Finally, the sample also includes an efi.inc reference to make it more readable. Should you decide to add the sample, I leave it up to you whether you want to add that .inc to the include directory, leave it at the root of the samples or just copy paste its content into efi64.asm and remove the reference. Oh, and if you are interested, I have the whole thing on github along with some instructions on how you can test the sample with qemu on Windows. At any rate, thank you very much for fasmg - it's awesome! |
|||
19 Aug 2016, 10:31 |
|
Tomasz Grysztar 19 Aug 2016, 11:38
Akeo wrote: I like the work being conducted with the generic assembler, and the whole design concept behind it, so, since I'm playing with UEFI, I created a new x86 sample for EFI (for x86_64) called efi64.asm, if you want to consider it for inclusion. With this, I think the x86 samples could provide a comprehensive portfolio of what people may be interested in. I think we really need a common hub for such projects, to create the "comprehensive portfolio" you mentioned. Shoorick is doing great job with some older CPUs/microcontrollers, it would be great to gather it all in one place. Akeo wrote: Before the sample can be added however, the following modification needs to be applied to examples/x86/include/format/format.inc, to enable the EFI subsystem for PE. Code: PE.Settings.Magic = 0x20B PE.Settings.Subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION PE.Settings.Machine = IMAGE_FILE_MACHINE_AMD64 PE.Settings.MajorSubsystemVersion = 5 PE.Settings.MinorSubsystemVersion = 0 ; ... include 'format/pe.inc' use64 Akeo wrote: Also, since the sample is using 'du', a new utf8.inc should probably be added to examples/x86/include/ Akeo wrote: Finally, the sample also includes an efi.inc reference to make it more readable. Should you decide to add the sample, I leave it up to you whether you want to add that .inc to the include directory, leave it at the root of the samples or just copy paste its content into efi64.asm and remove the reference. Great! I was hoping to see more works like this. And I am more than happy to hear that there are people liking my "insane" ideas of fasmg. Also: have you tried my struct macro for fasmg? It is a plain and simple macro that has many qualites of fasm's macro with the same name. |
|||
19 Aug 2016, 11:38 |
|
Akeo 19 Aug 2016, 17:43
Tomasz Grysztar wrote: I decided to stop extending the examples in the basic package, as I wanted to keep them relatively simple and release more complex ones (like conversions of fasm's macro-heavy Windows examples) in separate packages. I can understand where you're coming from. Quote: I think we really need a common hub for such projects +1 fasm/fasmg users need to be able to find as many samples as possible in a central location, that we can expand on. There's nothing worse than not being aware that a code sample exists, that already has the basics of what you're trying to do. Akeo wrote: You could also use the fasmg's PE formatting macros directly and include something like this in your headers (...) I'm mentioning this, because this PE formatter gives you much greater flexibility that one from original fasm (for instance you can alter things like SectionAlignment/FileAlignment), and the "format" macro only emulates the legacy syntax of fasm that has much fewer options. That's good to know. But I'd still like to see the EFI option added to the official PE/format header for fasmg, on account that this feature was available in fasm, and while fasmg offers more flexibility, it'd be nice to at least have it on par with fasm by default. Quote: I was hoping to see more works like this. And I am more than happy to hear that there are people liking my "insane" ideas of fasmg. I saw that post of yours, and hopefully I'll have something that is right up the alley of what you'd like to see listed there some time in the future (that x86_64 sample was actually a stepping stone towards that). I'll let you know then. Quote: Also: have you tried my struct macro for fasmg? Not yet, but I think I'll have a closer look at that for my other fasmg project... |
|||
19 Aug 2016, 17:43 |
|
Akeo 19 Aug 2016, 20:57
Awesome!
I tested the latest and everything looks good. Many thanks! |
|||
19 Aug 2016, 20:57 |
|
Tomasz Grysztar 20 Aug 2016, 16:52
I also suggest minor corrections to your utf8.inc:
Code: ; UTF-8 macro du? arg local current,__input,char if arg eqtype '' virtual at 0 __input:: db arg count = $ end virtual current = 0 while current < count load char byte from __input:current wide = char current = current + 1 if char > 0C0h if char < 0E0h wide = char and 11111b load char byte from __input:current wide = wide shl 6 + (char and 111111b) current = current + 1 else if char < 0F0h wide = char and 1111b load char byte from __input:current wide = wide shl 6 + (char and 111111b) load char byte from __input:current+1 wide = wide shl 6 + (char and 111111b) current = current + 2 else if char < 0F8h wide = char and 111b load char byte from __input:current wide = wide shl 6 + (char and 111111b) load char byte from __input:current+1 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+2 wide = wide shl 6 + (char and 111111b) current = current + 3 else if char < 0FCh wide = char and 11b load char byte from __input:current wide = wide shl 6 + (char and 111111b) load char byte from __input:current+1 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+2 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+3 wide = wide shl 6 + (char and 111111b) current = current + 4 else wide = char and 1 load char byte from __input:current wide = wide shl 6 + (char and 111111b) load char byte from __input:current+1 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+2 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+3 wide = wide shl 6 + (char and 111111b) load char byte from __input:current+4 wide = wide shl 6 + (char and 111111b) current = current + 5 end if end if if wide < 10000h dw wide else dw 0D7C0h + wide shr 10,0DC00h or (wide and 3FFh) end if end while else dw arg end if end macro macro du? args& iterate arg,args du arg end iterate end macro struc du? args& label . word du args end struc Code: Hello du 0x0D, 0x0A du "Hello EFI World!", 0x0D, 0x0A, 0x0D, 0x0A du "Press any key to exit", 0x0D, 0x0A du 0x00 |
|||
20 Aug 2016, 16:52 |
|
Akeo 20 Aug 2016, 22:06
Nice one.
I already knew the utf8.inc I had was limited, but you solved exactly the issue that still annoyed me with multiple data items. Thank you very much for this!! I have now applied your suggested changes to the sample. |
|||
20 Aug 2016, 22:06 |
|
Kevin_Zheng 20 Sep 2017, 13:38
Hi,Thomas:
The newest fasmg complier (version: hxhsr) can't complier the efi.inc, it will throw error messages: Code: efi.inc
struc int64
align 8
. dq ?
end struc
fasmg efi64.asm flat assembler version g.hxhsr efi64.asm [8] efi.inc [87]: struct EFI_TABLE_HEADER macro struct [2] macro EFI_TABLE_HEADER [1] macro int64 [1]: align 8 Processed: align 8 Error: illegal instruction. But the previous fasmg can compiler it okay, no error. Could you help me to check it? Thank you a lot . Kenneth Zheng
_________________ Pure Assembly Language Funs |
|||||||||||||||||||||
20 Sep 2017, 13:38 |
|
Tomasz Grysztar 20 Sep 2017, 14:20
The sources you provided assembled correctly for me (I used UTF8.INC from the Windows headers package):
Code: >fasmg efi64.asm flat assembler version g.hxhsr 3 passes, 1536 bytes. |
|||
20 Sep 2017, 14:20 |
|
Kevin_Zheng 20 Sep 2017, 14:46
Thanks Thomas quickly helpping about it Please see below steps to dupicate the complier error messages: (I've put the efi64.asm and efi.inc into this folder: c:\fasmg\examples\x86\uefi)
Code: C:\>set path=c:\fasmg C:\>cd c:\fasmg\examples\x86 C:\fasmg\examples\x86>make.cmd cd uefi fasmg efi64.asm flat assembler version g.hxhsr efi64.asm [8] efi.inc [87]: struct EFI_TABLE_HEADER macro struct [2] macro EFI_TABLE_HEADER [1] macro int64 [1]: align 8 Processed: align 8 Error: illegal instruction. The root cause is that the make.cmd will set "@set include=include", it will affect the fasmg.exe to report above complier error. If we don't use this line "@set include=include", it will complier okay. Thanks. Kenneth Zheng _________________ Pure Assembly Language Funs |
|||
20 Sep 2017, 14:46 |
|
Tomasz Grysztar 20 Sep 2017, 17:15
Then probably your "include" directory contains invalid version of some needed include files.
Please try increasing the number of displayed error with parameter like "-e100". Perhaps you may find the true source of the problem. |
|||
20 Sep 2017, 17:15 |
|
Kevin_Zheng 21 Sep 2017, 01:41
Hi, Thomas:
Yes, you are right. The root cause is that the efi.inc will use "align" macro, but the "align" macro in the "C:\fasmg\examples\x86\include\format\elfexe.inc", so the efi.inc willl report "align 8 Processed: align 8 Eror: illegal instruction.".. Another question is : include instruction supports several directores? for example: Code: set include=include;..\include;\fasmg\examples\include Thank you a lot. Kenneth Zheng _________________ Pure Assembly Language Funs |
|||
21 Sep 2017, 01:41 |
|
Tomasz Grysztar 21 Sep 2017, 07:06
Kevin_Zheng wrote: Another question is : include instruction supports several directores? for example: |
|||
21 Sep 2017, 07:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.