flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Replacement for rb |
Author |
|
LocoDelAssembly 15 May 2010, 21:01
Code: reserved = 0 macro rb bytes { reserved = reserved + bytes } struc rb count { label . byte at bss_base + reserved rb count } . . . ; bss area bss_base db reserved dup(?) Note however that every time rb is used it will end up in the bss_area (except when you use "times X rb Y", and some other circumstances where macros/strucs are skipped if exist). [edit] Quote: ; bss area |
|||
15 May 2010, 21:01 |
|
Tyler 16 May 2010, 21:37
Neither way(mine or CrazyOfTheAssembly's ) is working, I think it's something to do with the order things are processed. Using Loco's macro/struc posted above, the below code results in "grub_bss_end_addr" being equal to "grub_load_end_addr". Help please.
Code: grub_magic = 1BADB002h grub_flags = 10003h grub_checksum = -(grub_magic + grub_flags) grub_header_addr = grub_header grub_load_addr = grub_kbeginning grub_load_end_addr = grub_kend grub_bss_end_addr = grub_load_end_addr + reserved grub_entry_addr = kinit grub_mode_type = 1 grub_width = 80 grub_height = 25 grub_depth = 0 grub_header: dd grub_magic dd grub_flags dd grub_checksum dd grub_header_addr dd grub_load_addr dd grub_load_end_addr dd grub_bss_end_addr dd grub_entry_addr dd grub_mode_type dd grub_width dd grub_height dd grub_depth rb 1 |
|||
16 May 2010, 21:37 |
|
LocoDelAssembly 16 May 2010, 21:46
Tyler, you should not use "reserved" but something like "final_reserved" and place "final_reserved = reserved" in any place where no more rb's can happen after the execution of that assignation. Other possibility is to define "grub_bss_end_addr" at any place after the last rb, that way you could use "reserved" since it will be in its final value.
PS: Note that I wrote the macro and struc named "rb" because that is what you asked but yet I don't advice to do that. If you use it in a virtual block for some reason, it will also end up in the bss area. You should use a distinct name for this "reserve in bss area" as you'll probably will need the plain "rb" in the future (and not only for the "virtual" case). |
|||
16 May 2010, 21:46 |
|
Tyler 16 May 2010, 22:40
LocoDelAssembly wrote:
I guess I'll take your advice and use my original "reserve" macro. But why do you think that I should? This is for my (binary formatted) kernel rbs are going to take up disk space for no reason if I declare them Fasm's way, that's why I don't foresee using standard rbs. |
|||
16 May 2010, 22:40 |
|
LocoDelAssembly 16 May 2010, 23:03
No, rbs should not take more space even in binary format if them are placed at the end (or at least no instruction or initialized data follows the rb), if them do, then you just found a bug in fasm.
If you are completely sure rb's won't be used in anything that would interfere with this (local variables, declaration of structures that will occupy memory outside the bss area, etc.), then go ahead, otherwise I suggest a distinctive name for this special type of allocation. |
|||
16 May 2010, 23:03 |
|
Tyler 17 May 2010, 02:13
Putting the "grub_bss_end_addr = grub_load_end_addr + reserved" at the end of my source file worked. Thanks LocoDelAssembly.
|
|||
17 May 2010, 02:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.