flat assembler
Message board for the users of flat assembler.
Index
> Main > FASMG and namespace Goto page Previous 1, 2, 3, 4 Next |
Author |
|
Tomasz Grysztar 12 Jan 2021, 22:33
Fulgurance wrote: Anonyme label exist with fasmg ? There is also a slightly more capable variant in the utility directory. You may use it instead, if you prefer. |
|||
12 Jan 2021, 22:33 |
|
Tomasz Grysztar 13 Jan 2021, 09:53
Oh, I forgot to include the WRITABLE as synonym in PE.INC, only WRITEABLE works right now. Also, I should perhaps modify that custom error so that it would show which of the keywords was not recognized.
|
|||
13 Jan 2021, 09:53 |
|
Calanor 13 Jan 2021, 09:53
Fulgurance: "writable" should read "writeable"
[Edit] Oh, I was too slow again. |
|||
13 Jan 2021, 09:53 |
|
Fulgurance 13 Jan 2021, 18:45
Tomasz Grysztar wrote: Oh, I forgot to include the WRITABLE as synonym in PE.INC, only WRITEABLE works right now. Also, I should perhaps modify that custom error so that it would show which of the keywords was not recognized. Stupid mistake lol,sorry Now, I have this error: Code: zohran@msi-gs73vr-6rf ~/Documents/Programmation/OS $ fasmg BOOTX64.fasm flat assembler version g.j5ii BOOTX64.fasm [55] Data/Data.fasm [1]: Data: macro data? [17]: number = type Processed: number = : Error: invalid expression. BOOTX64.fasm: Code: include "FASMG/macro/@@.inc" include "FASMG/format/format.inc" format PE64 EFI entry Bootx64 include "Virtual/Virtual.fasm" section '.text' code readable executable include "Code/Code.fasm" Bootx64: Code.UEFI.Initialize Code.UEFI.Call ConOut,SimpleTextOutputProtocol,ClearScreen,1, \ InstancePointer Code.UEFI.GetStatusCode [text1] Code.UEFI.Call BootServices,BootServices,GetMemoryMap,5, \ Address,[Data.UEFI.GetMemoryMap.MemoryMapSize] Code.UEFI.GetStatusCode [text2] mov rax,[Data.UEFI.GetMemoryMap.MemoryMapSize] add qword [Data.UEFI.GetMemoryMap.MemoryMapSize],rax Code.UEFI.Call BootServices,BootServices,AllocatePool,3, \ Value,Virtual.UEFI.MemoryTypes.LoaderData, \ Value,[Data.UEFI.GetMemoryMap.MemoryMapSize], \ Address,[Data.UEFI.GetMemoryMap.MemoryMapAddress] Code.UEFI.GetStatusCode [text3] Code.UEFI.Call BootServices,BootServices,GetMemoryMap,5, \ Address,[Data.UEFI.GetMemoryMap.MemoryMapSize], \ Value,[Data.UEFI.GetMemoryMap.MemoryMapAddress], \ Address,[Data.UEFI.GetMemoryMap.MapKey], \ Address,[Data.UEFI.GetMemoryMap.DescriptorSize], \ Address,[Data.UEFI.GetMemoryMap.DescriptorVersion] Code.UEFI.GetStatusCode [text2] Code.UEFI.Call ConOut,SimpleTextOutputProtocol,OutputString,2, \ InstancePointer,0, \ Address,[text4] Code.UEFI.GetStatusCode [text4] jmp $ section '.data' data readable writeable include "Data/Data.fasm" text1: dw "UEFI ClearScreen:",0xD,0xA,0x0 text2: dw "UEFI GetMemoryMap:",0xD,0xA,0x0 text3: dw "UEFI AllocatePool:",0xD,0xA,0x0 text4: dw "UEFI OutputString:",0xD,0xA,0x0 Data.fasm: Code: Data: namespace Data include "UEFI/UEFI.fasm" end namespace If I do that, I solve the problem: Code: ?Data: namespace Data include "UEFI/UEFI.fasm" end namespace Last edited by Fulgurance on 13 Jan 2021, 18:58; edited 1 time in total |
|||
13 Jan 2021, 18:45 |
|
Tomasz Grysztar 13 Jan 2021, 18:54
This has already been discussed in this thread earlier - "data" is a case-insensitive command defined for PE format (just like in fasm 1). See the post above when I mentioned the solution:
Code: ?Data: |
|||
13 Jan 2021, 18:54 |
|
Fulgurance 13 Jan 2021, 19:00
Yes I edited my post at the same moment you write, you are too fast for me xD
Just something, is it normal when all is assembled, I have .exe file ? Normally is a .efi no ? |
|||
13 Jan 2021, 19:00 |
|
Tomasz Grysztar 13 Jan 2021, 19:33
Fulgurance wrote: Just something, is it normal when all is assembled, I have .exe file ? Normally is a .efi no ? Note that you may alter details like that easily by tweaking the FORMAT.INC. |
|||
13 Jan 2021, 19:33 |
|
Fulgurance 13 Jan 2021, 19:58
Okay. I think just the output name is EXE, but the binary generated is for UEFI? Because when I test my application with uefi shell into virtualbox, she don't work.
Is it because the file assembled is different or I done mistakes into my code when I migrated? |
|||
13 Jan 2021, 19:58 |
|
Tomasz Grysztar 13 Jan 2021, 20:03
Fulgurance wrote: Is it because the file assembled is different or I done mistakes into my code when I migrated? |
|||
13 Jan 2021, 20:03 |
|
Fulgurance 13 Jan 2021, 20:10
Okay I start to do that. If the problem come from the format directive, I will tell you
|
|||
13 Jan 2021, 20:10 |
|
Fulgurance 13 Jan 2021, 20:22
Okay, I done that, It's a old simple code I used before (I already tested, he work with fasm 1).
But when I try to assemble it with fasmg, I have this error: Code: zohran@msi-gs73vr-6rf ~/Downloads/Test $ fasmg Test.fasm flat assembler version g.j5ii Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [328]: .NumberOfSections dw NUMBER_OF_SECTIONS Processed: .NumberOfSections dw NUMBER_OF_SECTIONS Error: symbol 'PE.NUMBER_OF_SECTIONS' is undefined or out of scope. Code: include "FASMG/macro/@@.inc" include "FASMG/format/format.inc" format pe64 efi entry Main section '.text' code readable executable Main: mov [UEFIHandle],rcx mov [UEFISystemTable],rdx push rbp ;-------------------------------------------- mov rdx,[UEFISystemTable] push rbp sub rsp,0x20 mov rcx,[rdx+SystemTable.ConOut] mov rax,[rcx+SimpleTextOutputProtocol.ClearScreen] call rax add rsp,0x20 ;-------------------------------------------- jmp $ section '.data' data readable writeable include "DataTypes.fasm" include "TableHeader.fasm" include "SimpleTextOutputProtocol.fasm" include "SystemTable.fasm" UEFIHandle: dq ? UEFISystemTable: dq ? |
|||
13 Jan 2021, 20:22 |
|
Tomasz Grysztar 13 Jan 2021, 20:25
This error is probably cascading out of some structural error in the code, you can try to hunt down the actual error by increasing the "-e" setting from command line.
|
|||
13 Jan 2021, 20:25 |
|
Fulgurance 13 Jan 2021, 20:53
Code: zohran@msi-gs73vr-6rf ~/Downloads/Test $ fasmg -e 20 Test.fasm flat assembler version g.j5ii Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [328]: .NumberOfSections dw NUMBER_OF_SECTIONS Processed: .NumberOfSections dw NUMBER_OF_SECTIONS Error: symbol 'PE.NUMBER_OF_SECTIONS' is undefined or out of scope. Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [359]: .SizeOfImage dd SIZE_OF_IMAGE Processed: .SizeOfImage dd SIZE_OF_IMAGE Error: symbol 'PE.SIZE_OF_IMAGE' is undefined or out of scope. Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [394]: db (NUMBER_OF_SECTIONS-1)*SectionTable.ENTRY_LENGTH dup 0 Processed: db (NUMBER_OF_SECTIONS-1)*SectionTable.ENTRY_LENGTH dup 0 Error: symbol 'PE.NUMBER_OF_SECTIONS' is undefined or out of scope. Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [417]: relocated_addresses:: rd NUMBER_OF_RELOCATIONS Processed: rd NUMBER_OF_RELOCATIONS Error: symbol 'PE.NUMBER_OF_RELOCATIONS' is undefined or out of scope. Test.fasm [4] macro format?.PE64? [68] macro format?.include [1] FASMG/format/pe.inc [421]: relocation_types:: rw NUMBER_OF_RELOCATIONS Processed: rw NUMBER_OF_RELOCATIONS Error: symbol 'PE.NUMBER_OF_RELOCATIONS' is undefined or out of scope. Test.fasm [10]: mov [UEFIHandle],rcx mov? [2] x86.parse_operand [126] (CALM) Error: symbol 'UEFIHandle' is undefined or out of scope. Test.fasm [10]: mov [UEFIHandle],rcx mov? [2] x86.parse_operand [129] (CALM) Error: symbol 'UEFIHandle' is undefined or out of scope. Test.fasm [11]: mov [UEFISystemTable],rdx mov? [2] x86.parse_operand [126] (CALM) Error: symbol 'UEFISystemTable' is undefined or out of scope. Test.fasm [11]: mov [UEFISystemTable],rdx mov? [2] x86.parse_operand [129] (CALM) Error: symbol 'UEFISystemTable' is undefined or out of scope. Test.fasm [15]: mov rdx,[UEFISystemTable] mov? [3] x86.parse_operand [126] (CALM) Error: symbol 'UEFISystemTable' is undefined or out of scope. Test.fasm [15]: mov rdx,[UEFISystemTable] mov? [3] x86.parse_operand [129] (CALM) Error: symbol 'UEFISystemTable' is undefined or out of scope. Test.fasm [20]: mov rcx,[rdx+SystemTable.ConOut] mov? [3] x86.parse_operand [126] (CALM) Error: symbol 'SystemTable.ConOut' is undefined or out of scope. Test.fasm [20]: mov rcx,[rdx+SystemTable.ConOut] mov? [3] x86.parse_operand [129] (CALM) Error: symbol 'SystemTable.ConOut' is undefined or out of scope. Test.fasm [20]: mov rcx,[rdx+SystemTable.ConOut] mov? [9] (CALM) Error: values not comparable. Test.fasm [20]: mov rcx,[rdx+SystemTable.ConOut] mov? [12] (CALM) Error: variable term used where not expected. Test.fasm [21]: mov rax,[rcx+SimpleTextOutputProtocol.ClearScreen] mov? [3] x86.parse_operand [126] (CALM) Error: symbol 'SimpleTextOutputProtocol.ClearScreen' is undefined or out of scope. Test.fasm [21]: mov rax,[rcx+SimpleTextOutputProtocol.ClearScreen] mov? [3] x86.parse_operand [129] (CALM) Error: symbol 'SimpleTextOutputProtocol.ClearScreen' is undefined or out of scope. Test.fasm [21]: mov rax,[rcx+SimpleTextOutputProtocol.ClearScreen] mov? [9] (CALM) Error: values not comparable. Test.fasm [21]: mov rax,[rcx+SimpleTextOutputProtocol.ClearScreen] mov? [12] (CALM) Error: variable term used where not expected. Test.fasm [29]: section '.data' data readable writeable macro section? [7]: store SECTION_BASE-IMAGE_BASE at PE:SectionTable.VirtualAddress+SECTION_INDEX*SectionTable.ENTRY_LENGTH Processed: store SECTION_BASE-IMAGE_BASE at PE:SectionTable.VirtualAddress+SECTION_INDEX*SectionTable.ENTRY_LENGTH Error: address out of range. |
|||
13 Jan 2021, 20:53 |
|
Tomasz Grysztar 13 Jan 2021, 21:17
Seems like you may have even more of them there (try larger number). Cascades like this are usually caused by some kind of block not closed properly, etc.
|
|||
13 Jan 2021, 21:17 |
|
Fulgurance 13 Jan 2021, 21:49
Thanks for this advice, I found the problem, I need to do a little conversion of macro and struc for fasmg.
I tested, the problem now come from my implementation, thanks you. I think I done something bad during my migration, I start to perfom checks FASMG is a very wonderfull work, thanks you again |
|||
13 Jan 2021, 21:49 |
|
Fulgurance 13 Jan 2021, 22:24
I have question Tomasz, how can I display the value of a label for check the result ? I use display but this command show me just the ASCII code
|
|||
13 Jan 2021, 22:24 |
|
Calanor 13 Jan 2021, 23:15
Fulgurance: There's an example of how to do that in the manual:
Code: macro show description,value repeat 1, d:value display description,`d,13,10 end repeat end macro show '2^64=',1 shl 64 |
|||
13 Jan 2021, 23:15 |
|
Fulgurance 13 Jan 2021, 23:29
Oh yes, sorry.
I have a question about match, because when I convert my macro for call UEFI function with match, I see the test don't work correctly. I don't understand very well how match work.... It's my macro before fasmg: Code: macro UEFI Entry*,Interface*,Function*,ParametersNumber*,Type1*,Argument1,Type2,Argument2,Type3,Argument3,Type4,Argument4,Type5,Argument5,Type6,Argument6,Type7,Argument7,Type8,Argument8,Type9,Argument9,Type10,Argument10 { ArgumentsNumber = 10 if Argument10 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument9 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument8 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument7 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument6 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument5 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument4 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument3 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument2 eq ArgumentsNumber = ArgumentsNumber-1 end if if Argument1 eq ArgumentsNumber = ArgumentsNumber-1 end if if ParametersNumber > 4 sub rsp,ParametersNumber*8 else sub rsp,0x20 end if mov rdx,[UEFISystemTable] mov rcx,[rdx+SystemTable.#Entry] mov rax,[rcx+#Interface#.#Function] if ArgumentsNumber > 0 if Argument1 eq if Type1 != UEFI_ARGUMENT_TYPE_INSTANCE_POINTER xor rcx,rcx end if else if Type1 eq UEFI_ARGUMENT_TYPE_INSTANCE_POINTER else if Type1 eq UEFI_ARGUMENT_TYPE_ADDRESS lea rcx,Argument1 else mov rcx,Argument1 end if end if end if end if if ArgumentsNumber > 1 if Argument2 eq 0 xor rdx,rdx else if Type2 eq UEFI_ARGUMENT_TYPE_ADDRESS lea rdx,Argument2 else mov rdx,Argument2 end if end if end if if ArgumentsNumber > 2 if Argument3 eq 0 xor r8,r8 else if Type3 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r8,Argument3 else mov r8,Argument3 end if end if end if if ArgumentsNumber > 3 if Argument4 eq 0 xor r9,r9 else if Type4 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r9,Argument4 else mov r9,Argument4 end if end if end if if ArgumentsNumber > 4 if Type5 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument5 mov qword[rsp + 8*4],r10 else mov qword[rsp + 8*4],r10 end if end if if ArgumentsNumber > 5 if Type eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument6 mov qword[rsp + 8*5],r10 else mov qword[rsp + 8*5],r10 end if end if if ArgumentsNumber > 6 if Type7 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument7 mov qword[rsp + 8*6],r10 else mov qword[rsp + 8*6],r10 end if end if if ArgumentsNumber > 7 if Type8 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument8 mov qword[rsp + 8*7],r10 else mov qword[rsp + 8*7],r10 end if end if if ArgumentsNumber > 8 if Type9 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument9 mov qword[rsp + 8*8],r10 else mov qword[rsp + 8*8],r10 end if end if if ArgumentsNumber > 9 if Type10 eq UEFI_ARGUMENT_TYPE_ADDRESS lea r10,Argument10 mov qword[rsp + 8*9],r10 else mov qword[rsp + 8*9],r10 end if end if call rax if ParametersNumber > 4 add rsp,ParametersNumber*8 else add rsp,0x20 end if } And after the migration (the name changed): Code: macro Call Entry*,Interface*,Function*,ParametersNumber*,Type1*,Argument1,Type2,Argument2,Type3,Argument3,Type4,Argument4,Type5,Argument5,Type6,Argument6,Type7,Argument7,Type8,Argument8,Type9,Argument9,Type10,Argument10 ArgumentsNumber = 10 match , Argument10 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument9 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument8 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument7 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument6 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument5 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument4 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument3 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument2 ArgumentsNumber = ArgumentsNumber-1 end match match , Argument1 ArgumentsNumber = ArgumentsNumber-1 end match if ParametersNumber > 4 sub rsp,ParametersNumber*8 else sub rsp,0x20 end if mov rdx,[Data.UEFI.SystemTable] mov rcx,[rdx+Virtual.UEFI.SystemTable.#Entry] mov rax,[rcx+Virtual.UEFI.#Interface#.#Function] if ArgumentsNumber > 0 match , Argument1 if Virtual.UEFI.ArgumentTypes.#Type1 != Virtual.UEFI.ArgumentTypes.InstancePointer xor rcx,rcx end if else if Virtual.UEFI.ArgumentTypes.#Type1 = Virtual.UEFI.ArgumentTypes.InstancePointer else if Virtual.UEFI.ArgumentTypes.#Type1 = Virtual.UEFI.ArgumentTypes.Address lea rcx,Argument1 else mov rcx,Argument1 end if end if end match end if if ArgumentsNumber > 1 match , Argument2 xor rdx,rdx else if Virtual.UEFI.ArgumentTypes.#Type2 = Virtual.UEFI.ArgumentTypes.Address lea rdx,Argument2 else mov rdx,Argument2 end if end match end if if ArgumentsNumber > 2 match , Argument3 xor r8,r8 else if Virtual.UEFI.ArgumentTypes.#Type3 = Virtual.UEFI.ArgumentTypes.Address lea r8,Argument3 else mov r8,Argument3 end if end match end if if ArgumentsNumber > 3 match , Argument4 xor r9,r9 else if Virtual.UEFI.ArgumentTypes.#Type4 = Virtual.UEFI.ArgumentTypes.Address lea r9,Argument4 else mov r9,Argument4 end if end match end if if ArgumentsNumber > 4 if Virtual.UEFI.ArgumentTypes.#Type5 = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument5 mov qword[rsp + 8*4],r10 else mov qword[rsp + 8*4],r10 end if end if if ArgumentsNumber > 5 if Virtual.UEFI.ArgumentTypes.#Type = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument6 mov qword[rsp + 8*5],r10 else mov qword[rsp + 8*5],r10 end if end if if ArgumentsNumber > 6 if Virtual.UEFI.ArgumentTypes.#Type7 = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument7 mov qword[rsp + 8*6],r10 else mov qword[rsp + 8*6],r10 end if end if if ArgumentsNumber > 7 if Virtual.UEFI.ArgumentTypes.#Type8 = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument8 mov qword[rsp + 8*7],r10 else mov qword[rsp + 8*7],r10 end if end if if ArgumentsNumber > 8 if Virtual.UEFI.ArgumentTypes.#Type9 = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument9 mov qword[rsp + 8*8],r10 else mov qword[rsp + 8*8],r10 end if end if if ArgumentsNumber > 9 if Virtual.UEFI.ArgumentTypes.#Type10 = Virtual.UEFI.ArgumentTypes.Address lea r10,Argument10 mov qword[rsp + 8*9],r10 else mov qword[rsp + 8*9],r10 end if end if call rax if ParametersNumber > 4 add rsp,ParametersNumber*8 else add rsp,0x20 end if end macro I tested into a minimal file how match work, but when I test if symbol is empty, the test always fail, look: Code: match , Potatoes display "Empty" end match I think It's because if you don't specifie an optional parameter, the symbol don't exist |
|||
13 Jan 2021, 23:29 |
|
revolution 14 Jan 2021, 05:09
Can we treat namespace as a path?
Code: namespace Some namespace Thing value = 0 end namespace namespace ThingElse var = ../Thing.value ; go back one level end namespace end namespace |
|||
14 Jan 2021, 05:09 |
|
Goto page Previous 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.