flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Dex4u 20 Mar 2006, 17:12
I would be interested in more info on your " basic-like language" as we are looking for something like this for a asm OS me and a group of programmers are making.
We have a fasm and retroforth port, but are looking at ways to add high language support, for beginners etc. Thanks. |
|||
![]() |
|
bogdanontanu 20 Mar 2006, 17:31
You are NOT creating the stack frame corectly.
Study how HLL languages like C and PAscal do create it. This is TASM syntax but FASM has some HLL like macros that create similar or relatively close syntax: Code: My_PROC PROC STDCALL USES esi,edi ARG @@a_src:dword, @@a_dest:dword LOCAL @@tmp_data:dword mov esi,[@@a_src] mov edi,[@@_dest] mov eax,[esi+ SRC_STRUC.member_01] mov [@@tmp_data],eax ret ENDP Arguments are stored at EBP + some offset (figure out the value as an exercise) LOCAL variables are stored at EBP - some offset ESP is placed below LOCAL variables So any pushes/pops will not affect them. You must not change EBP once the stack frame is created. The trick is to use EBP as a fixed reference point on the stack, that is why it is called "a frame": something above and somethiong below a fixed point.... You have an error into your stack frame above and this generates your confusion ![]() |
|||
![]() |
|
bogdanontanu 20 Mar 2006, 17:48
Just in case, the corect frame creation goes like this:
Code: ; prologue push ebp mov ebp,esp add esp, size_of_local variables ; your code here ; epilogue mov esp,ebp pop ebp ret size_of_arguments Or the shorter version using enter and leave |
|||
![]() |
|
Kain 21 Mar 2006, 18:30
>add esp, size_of_local variables
Slight slip here, Bogdan means: sub esp, size_of_local variables IMO, it's almost always better to let a well tested macro create the stack frame. I've run into many problems with easy to miss minor errors of this sort when creating my own frames, plus you get the added bonus of not having to manually calculate the offsets. |
|||
![]() |
|
Plue 22 Mar 2006, 13:58
Kain wrote: >add esp, size_of_local variables Dex4u, the compiler is not written in asm, it only outputs asm. _________________ Roses are red Violets are blue Some poems rhyme And some don't. |
|||
![]() |
|
Dex4u 22 Mar 2006, 18:39
Plue wrote: Dex4u, the compiler is not written in asm, it only outputs asm. |
|||
![]() |
|
Chewy509 22 Mar 2006, 22:47
Dex4u wrote:
The simply solution would be to rewrite the compiler in it's own language, and since the compiler outputs asm, then you get your asm source for the compiler! (Just like what I'm working on, with the current b0 compiler. I'm about 70% of the way through now). |
|||
![]() |
|
Dex4u 22 Mar 2006, 23:57
Yes that would be good, if not i need a basic or pascal compiler written in fasm.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.