flat assembler
Message board for the users of flat assembler.

Index > Main > How to use FSAVE , FNSAVE in FASM

Author
Thread Post new topic Reply to topic
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 10:02
Example of code?
Post 03 Jun 2023, 10:02
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 03 Jun 2023, 10:07
Code:
fsave [state]
state:          db 512 dup (0)    
Post 03 Jun 2023, 10:07
View user's profile Send private message Reply with quote
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 10:26
Why size is 512. Maybe 94 or 108 bytes?


Last edited by 3D_FASM on 03 Jun 2023, 11:20; edited 1 time in total
Post 03 Jun 2023, 10:26
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 03 Jun 2023, 11:07
Just with a margin.

I showed you how to declare a buffer. And what length it should be - choose for yourself.

The point: since fasm1 does not have a data type of a suitable length for this command, it is necessary to make a label without specifying the length of the data. I.e., use the label directive or put : after label name.
Post 03 Jun 2023, 11:07
View user's profile Send private message Reply with quote
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 11:22
Ok. FNSAVE instruction writes 94 bytes of data when the CPU executes 16-bit code and 108 bytes of data when the CPU executes 32-bit code.

Code:
state: db 108 dup (0) 
...
     fsave [state]      
Post 03 Jun 2023, 11:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 03 Jun 2023, 11:29
We need a fiftyfourword size operand!
Code:
state d54w ?
fsave [state]
fsave fiftyfourword[0x1234]    
Post 03 Jun 2023, 11:29
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 03 Jun 2023, 11:32
revolution wrote:
We need a fiftyfourword size operand!
Cool. When did it appear? Why is there nothing about this in the documentation?
Code:
use64
fsave [state]
state d54w ?    

Code:
~ $ fasm test1.asm -m 102400
flat assembler  version 1.73.30  (102400 kilobytes memory)
test1.asm [3]:
state           d54w ?
processed: state d54w ?
error: illegal instruction.    

Code:
use32
fsave fiftyfourword [state]
state db 512 dup ?    

Code:
~ $ fasm test1.asm -m 102400
flat assembler  version 1.73.30  (102400 kilobytes memory)
test1.asm [2]:
fsave fiftyfourword [state]
processed: fsave fiftyfourword[state]
error: invalid operand.
    


Last edited by macomics on 03 Jun 2023, 11:39; edited 2 times in total
Post 03 Jun 2023, 11:32
View user's profile Send private message Reply with quote
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 11:35
Hm... why d54w ? why not d108b ?)

fiftyfourword - sounds too long.


Last edited by 3D_FASM on 03 Jun 2023, 11:35; edited 1 time in total
Post 03 Jun 2023, 11:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 03 Jun 2023, 11:35
macomics wrote:
Cool. When did it appear? Why is there nothing about this in the documentation?
Shh. Don't tell anyone. It is a secret.
Post 03 Jun 2023, 11:35
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 03 Jun 2023, 11:36
3D_FASM wrote:
Hm... why d54w ? why not d108b ?)
It follows the normal dw, dd, dq, d54w / word, dword, qword, fiftyfourword. Perfectly sensible.
Post 03 Jun 2023, 11:36
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 03 Jun 2023, 11:42
revolution, see above
Post 03 Jun 2023, 11:42
View user's profile Send private message Reply with quote
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 11:43
revolution wrote:
It follows the normal dw, dd, dq, d54w / word, dword, qword

Fine but db is skipped at start of this sequence:
db - 1 byte,
dw - 2 bytes,
dd - 4 bytes,
dq - 8 bytes
etc ...
Post 03 Jun 2023, 11:43
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 03 Jun 2023, 11:47
3D_FASM wrote:
Fine but db is skipped at start of this sequence:
db - 1 byte,
dw - 2 bytes,
dd - 4 bytes,
dq - 8 bytes
etc ...
He meant

db - define byte (1 byte)
dw - define word (2 bytes)
dd - define double word (4 bytes),
dq - define qquad word(8 bytes)
etc ...
d54w - define 54 * word (54*2 bytes = 108)
Post 03 Jun 2023, 11:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8397
Location: Kraków, Poland
Tomasz Grysztar 03 Jun 2023, 11:52
With fasmg's implementation you can use a sized label (but it works with unsized one as well, just like in fasm):
Code:
include 'cpu/p5.inc'

use32
fsave [state]

label state:108
rb 108    
Post 03 Jun 2023, 11:52
View user's profile Send private message Visit poster's website Reply with quote
3D_FASM



Joined: 11 May 2023
Posts: 24
3D_FASM 03 Jun 2023, 11:53
It seems to me that a byte is quite a normal and understandable unit of measurement instead word. This is by the way.
Post 03 Jun 2023, 11:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 03 Jun 2023, 12:35
3D_FASM wrote:
It seems to me that a byte is quite a normal and understandable unit of measurement instead word. This is by the way.
Talk to Intel about that. They started it. Smile
Post 03 Jun 2023, 12:35
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2626
Furs 03 Jun 2023, 18:04
Byte should've been called half word.
Post 03 Jun 2023, 18:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 03 Jun 2023, 23:07
Arm defines hwords as 16-bit. So byte should be quarter word.

But then there is confusion between quad word (4 x 32-bit) and quarter word (1/4 x 32-bit) Sad
Code:
my_data dq ? ; is this 8-bits or 128-bits?    
Post 03 Jun 2023, 23:07
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1150
Location: Russia
macomics 04 Jun 2023, 02:24
revolution wrote:
But then there is confusion between quad word (4 x 32-bit) and quarter word (1/4 x 32-bit) Sad
Code:
my_data dq ? ; is this 8-bits or 128-bits?     

Will have to make two definitions with different registers
Code:
my_data8   dq ?
my_data128 dQ ?    
Post 04 Jun 2023, 02:24
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4227
Location: vpcmpistri
bitRAKE 04 Jun 2023, 08:35
Furs wrote:
Byte should've been called half word.
Word was defined first - before byte. At first, word meant the native size of the machine - it could be 18-bit or 30-bit; whatever the machine used.

Byte came later, 5-bit bytes and it grew - "just a part of a word" - because it was shorter than typing character.

The power of two scheme came later. Once bytes became 8-bits, nibbles were needed, and before that there was a phase where everything was defined in octal - three bit thinking. 😀

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 04 Jun 2023, 08:35
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.