flat assembler
Message board for the users of flat assembler.
Index
> Windows > Printing Registers Value. What these values mean? |
Author |
|
JohnFound 27 Apr 2011, 14:05
I am not very sure how "printf" works, but I can't see how the values from variables "regEAX".... etc. are read and displayed by printf. There is no reference to these variables in the invoke clause of printf.
|
|||
27 Apr 2011, 14:05 |
|
fasmnewbie 27 Apr 2011, 14:24
JohnFound wrote: I am not very sure how "printf" works, but I can't see how the values from variables "regEAX".... etc. are read and displayed by printf. There is no reference to these variables in the invoke clause of printf. Oops, my bad. Actually I used my old example. Thank you for that! here is how the macro PrintRegs looks like Code: macro PrintRegs { invoke printf, prtGP, regEAX, regEBX, regECX, regEDX invoke printf, prtID, regEDI, regESI, regEBP, regESP invoke printf, prtSG, regCS, regDS, regSS } Thank you. |
|||
27 Apr 2011, 14:24 |
|
typedef 27 Apr 2011, 14:48
use ccall for printf not invoke, also for formatting try using unsigned int format specifier : %u.
enclose the dw/dd variables in square brackets when passing them to printf also. |
|||
27 Apr 2011, 14:48 |
|
revolution 27 Apr 2011, 14:57
typedef wrote: use ccall for printf not invoke ... |
|||
27 Apr 2011, 14:57 |
|
DOS386 06 May 2011, 01:39
> 1. Are the values printed were the real content of the registers
YES (but they are neither too global nor too persistent ) > Can't seem to find how to print the EIP Code: call @ff @@: pope eax mov dword [regEIP], eax Code: call @ff @@: pope dword [regEIP] _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
06 May 2011, 01:39 |
|
Fred 04 Jul 2011, 12:22
I tried this, and it's pretty neat now that I got it to work. One thing though... is it possible to show reg values as floats? Changing %u to %f only prints zeroes, not really sure what's wrong, or if it's even supposed to work.
|
|||
04 Jul 2011, 12:22 |
|
Picnic 04 Jul 2011, 14:15
fasmnewbie wrote:
Hi, Check out these examples. http://board.flatassembler.net/topic.php?p=13916#13916 http://board.flatassembler.net/topic.php?t=10183 http://board.flatassembler.net/topic.php?p=68658#68658 (DOS) Fred wrote: is it possible to show reg values as floats? Try this way Fred, Code: proc printfloat reg locals fmt db "%.2f",0 ans dq 0.0 endl pushad lea edx, [fmt] fild dword [reg] fstp qword [ans] cinvoke printf, edx, double [ans] popad ret endp [edit]polishing code a bit[/edit] Last edited by Picnic on 04 Jul 2011, 19:11; edited 1 time in total |
|||
04 Jul 2011, 14:15 |
|
Fred 04 Jul 2011, 15:53
That worked, thanks.
Why the qword? Edit: I also realized that I really wanted to do something else. I have a file that I load which contains floats. For example, 0.86599994 is stored as 2C B2 5D 3Fh. How do I get these "back to floats"? Do I have to convert them or is it simpler than that? |
|||
04 Jul 2011, 15:53 |
|
Picnic 04 Jul 2011, 20:24
It should be qword, printf f format requires 2 dwords.
|
|||
04 Jul 2011, 20:24 |
|
Fred 04 Jul 2011, 21:14
Aha, ok.
Knowing this, I solved my problem: Code: mov eax,[hstats] movss xmm0,[eax+136] cvtss2sd xmm0,xmm0 movsd [reg],xmm0 cinvoke printf,usefloat,double [reg] Where hstats is a pointer to some file data. Probably not the best solution, but hey, it works, haha. |
|||
04 Jul 2011, 21:14 |
|
garystampa 05 Jul 2011, 11:44
Hopefully they're not "random" values. But your program will affect what's in the registers.
|
|||
05 Jul 2011, 11:44 |
|
typedef 05 Jul 2011, 22:28
...1 year later...
garystampa resurrected an old post...lol |
|||
05 Jul 2011, 22:28 |
|
asmMe 18 Jul 2011, 13:33
Considering the fact that the OP only joined in March this year typedef, you may perhaps be looking at join dates and not post dates
|
|||
18 Jul 2011, 13:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.