flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DimonSoft 10 Dec 2020, 22:45
Actually, it’s possible to wrap these things into macros. For me the hardest (most dirty) piece was perhaps the one that chooses parameters for FAT16/FAT32 disks based on the tables from specification. Nothing hard logically but I wanted to have it done by preprocessor, so, after writing a few auxiliary macros, I got something along these lines:
Code: if_le nSectors, 8'400, 'Disk is too small for FAT16.' spc equ 2 if_g nSectors, 32'680, spc equ 4 if_g nSectors, 262'144, spc equ 8 if_g nSectors, 524'288, spc equ 16 if_g nSectors, 1'048'576, spc equ 32 if_g nSectors, 2'097'152, spc equ 64 if_g nSectors, 4'194'304, 'Disk is too large for FAT16.' Code: macro if_le x*, c*, action& \{ rept (((x) - (c) - 1) and (1 shl 63)) shr 63 \\{ action \\} \} macro if_g x*, c*, action& \{ rept (((c) - (x)) and (1 shl 63)) shr 63 \\{ action \\} \} Code: unpack VolumeID \# @Params, tpl,\ BPB_SecPerClus = spc,\ BPB_TotSec32 = nSectors,\ BPB_FATSz32 = (((nSectors) - 32) + (128 * spc)) / (128 * spc + 1),\ Params |
|||
![]() |
|
bitshifter 13 Dec 2020, 07:12
ok cool, thanks for the ideas
right now im playing with some constants and debugging them i adapted the 'display' example from fasm manual to help debug Code: macro trace trace_param* { display `trace_param # ': ' trace_bits = 32 repeat (trace_bits / 4) nibble_offset = % * 4 ;counts by 4, from 4 to N (4,8,12,16,20,24,28,32) nibble_value = '0' + ((trace_param shr (trace_bits - nibble_offset)) and 0Fh) if nibble_value > '9' nibble_value = nibble_value + 'A' - '9' - 1 end if display nibble_value end repeat display 13,10 } MEDIA_CYLINDERS_PER_DISK equ 1 trace MEDIA_CYLINDERS_PER_DISK MEDIA_HEADS_PER_CYLINDER equ 2 MEDIA_HEADS_PER_DISK equ (MEDIA_HEADS_PER_CYLINDER * MEDIA_CYLINDERS_PER_DISK) trace MEDIA_HEADS_PER_DISK MEDIA_TRACKS_PER_HEAD equ 80 MEDIA_TRACKS_PER_DISK equ (MEDIA_TRACKS_PER_HEAD * MEDIA_HEADS_PER_DISK) trace MEDIA_TRACKS_PER_DISK MEDIA_SECTORS_PER_TRACK equ 18 MEDIA_SECTORS_PER_DISK equ (MEDIA_SECTORS_PER_TRACK * MEDIA_TRACKS_PER_DISK) trace MEDIA_SECTORS_PER_DISK MEDIA_BYTES_PER_SECTOR equ 512 MEDIA_BYTES_PER_DISK equ (MEDIA_BYTES_PER_SECTOR * MEDIA_SECTORS_PER_DISK) trace MEDIA_BYTES_PER_DISK output: Code: flat assembler version 1.73.09 (16384 kilobytes memory) MEDIA_CYLINDERS_PER_DISK: 00000001 MEDIA_HEADS_PER_DISK: 00000002 MEDIA_TRACKS_PER_DISK: 000000A0 MEDIA_SECTORS_PER_DISK: 00000B40 MEDIA_BYTES_PER_DISK: 00168000 2 passes, 0.3 seconds, 1474560 bytes. |
|||
![]() |
|
bitshifter 13 Dec 2020, 07:31
@DimonSoft
I think you can simplify your macro's by using N shr 63 and 1 No need to mask before the shift, just do it later, saves one shift I would keep the mask for when 128bit comes along and breaks it |
|||
![]() |
|
DimonSoft 13 Dec 2020, 12:38
bitshifter wrote: @DimonSoft As far as I know, FASM internally has 65 bits whatever that means. There probably was another reason but I can’t remember it right now. Got your point, thanks, I’ll think about it. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.