Author Topic: Example assembly translate to pascal  (Read 6233 times)

Offline muffys123

  • New Member
  • Posts: 1
Example assembly translate to pascal
« on: August 31, 2017, 07:17:32 PM »
SUB ESP,8
FLD [00F1CD80h]
FLD1
FADDP ST(1),ST(0)
FLD [00F1CD88h]
FADD [00F1CD90h]
SUB ESP,8
FSTP [ESP]
FSTP [ESP+8]
CALL 054008CCh
FLD [ESP]
FLD [00F1CD98h]
FSUB [ESP+0Ch]
FLD [00F1CD90h]
FMUL [00F1CD80h]
FADDP ST(1),ST(0)
FMULP ST(2),ST(0)
FADDP ST(1),ST(0)
FSTP [00F1CD80h]
ADD ESP,8
RET 8

Hello, I am trying to translate this assembler code for Intel 80386 to pascal. I am quite newbie with assembler.
Do you know some source, where are solved examples?

My question to this code:
How can I recognize parameters of procedure.
What exactly does St(1), ST(0) (I found, it will pop a stack ...)
First what I see that at the first line of the code that I have to subtract from ESP(Extended Stack Pointer). I guess some variable a value eight. Then I load from some Float number from absolute adress ...

 

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Example assembly translate to pascal
« Reply #1 on: August 31, 2017, 08:28:39 PM »
Hi muffys123,

If you're new to assembly language, this is not a good place to start. I don't think we'll be able to help you. I don't think there's enough information there to translate it to Pascal or anything else. It doesn't look to me as if it'll even run. You subtract 8 from the stack pointer twice, and only add it back once.

I would suggest that you go back to wherever you found that code, and ask there.

There's a tutorial on FPU programming here:
http://www.ray.masmcode.com/fpu.html
It's in Masm syntax, not Nasm. but I think that'll be the least of your worries. Really, this is not a good place to start!

Best,
Frank