flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > SmartAssembler

Author
Thread Post new topic Reply to topic
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
I Am Working On An Assembler Written In Python, One Of It's Features Will Be The Conversion Between Different Assembler Syntax, And It's Own, Which Will Be Like HLA. Anyway I Was Just Wondering How I Should Have It Reference Memory, I Mean, When It Is Converting Between FASM And It's Own Syntax, What Would I Turn This Into?
Code:
mov [memorylocation], 5    
?
Post 14 Dec 2010, 01:13
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
Are you asking us what your "Own Syntax" should be for that instruction? Shouldn't it be your decision as to what your "Own Syntax" looks like?
Post 14 Dec 2010, 01:26
View user's profile Send private message Visit poster's website Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
Yes you're Correct Revolution I AM Asking You What It Should Be As I Currently Only Understand The Conversion Of Instructions With Registers Or The Stack, But I Haven't Successfully Converted Anything With Memory, And I Would Like Input From People Who Are More Experienced Than Myself With Assembly Programming
Post 14 Dec 2010, 01:29
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
Then I suggest your "Own Syntax" should be:
Code:
mov [memorylocation],5    
Without knowing anything about your "Own Syntax" I can't give a better answer. You will need to show us what your "Own Syntax" currently looks like.
Post 14 Dec 2010, 01:33
View user's profile Send private message Visit poster's website Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
Ok, As Far As My Own Syntax Goes It Is In The Spirit Of Procedural Languages Such As Python Or C/C++ In That An Add Instruction Such As:
Code:
add ah,al    

Would Become This:
Code:
add("ah", "al")    

Where The Registers Would Be Passed As Strings That Are Case Insensitive
But The Mnemonics ARE Case Sensitive.
You See For Each Mnemonic I Am Writing A Python Function That Takes As Input Whatever Operands That mnemonic Would Normally Take, As A String Or As A Number In The Case Of An Immediate Operand. I Just Don't Know How It Should Take A Memory Location Or How To Differentiate Between A Memory Location Or Immediate Instruction
Post 14 Dec 2010, 02:07
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
Coty



Joined: 17 May 2010
Posts: 554
Location: ␀
Coty
Code:
move("[memorylocation]" = 5d); 
    

_________________
http://codercat.org/
Post 14 Dec 2010, 02:12
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
In most HLLs memory locations are just variables:
Code:
memorylocation = 5    
Post 14 Dec 2010, 02:18
View user's profile Send private message Visit poster's website Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
It would Have to be passed as a python datatype as that is the language it is written in, how would i differentiate between a memory location and a Immediate value, for instance:
Code:
mov edi, memorylocation    

being:
Code:
mov("edi", "memorylocation")    

could be thought of as moving a string containing "memorylocation" to edi
but that is obviously not what we want, we want the location moved there, where as:
Code:
mov("edi", [memorylocation])    

would move a list to edi which in turn turns to:
Code:
mov("edi", "memorylocation")    

Causing the same differentiation problem as before, this is Not a bug it is a feature so that you could do this:
Code:
mov([eax,ebx],[4,5])    

which would turn into:
Code:
mov("eax", 4)
mov("ebx", 5)
    

Also instead of having a macro capability you would just use a python function:
Code:
def turnspeakeron():
    in("al", 0x61)
    or("al", 00000011b)
    out(0x61, "al")

def turnspeakeroff():
    in("al", 0x61)
    and("al", 11111100b)
    out(0x61, "al")

    
Post 14 Dec 2010, 02:21
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
revolution wrote:
In most HLLs memory locations are just variables:
Code:
memorylocation = 5    
Yes But In Assembler You Can Make A Label Which Can Then Be Referenced As A Memory Location So
Code:
label1:
    mov al,5
    jmp label3

label2:
    mov al, 6
    jmp label3

label3:
    cmp al,5
    jne label1
    je label2


    

This Is What I Need To Know How To Turn Into Machine Code, And How It Should Be Incorporated Into My Assembler's Syntax
Post 14 Dec 2010, 02:26
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
Quote:

Also instead of having a macro capability you would just use a python function:
Code:
def turnspeakeron():
    in("al", 0x61)
    or("al", 00000011b)
    out(0x61, "al")

def turnspeakeroff():
    in("al", 0x61)
    and("al", 11111100b)
    out(0x61, "al")

    

As opposed to:
Code:

macro speakeron
{
 IN      AL, 0x61        
    OR      AL, 00000011b
       OUT 0x61, AL
}

macro speakeroff
{
    IN      AL, 0x61        
    AND     AL, 11111100b
       OUT 0x61, AL
}
    
[/quote]
Post 14 Dec 2010, 02:27
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
C uses the "&" to get a pointer.
Code:
a = &variable    
Some HLL languages don't support pointers at all.
Post 14 Dec 2010, 02:39
View user's profile Send private message Visit poster's website Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
It is written in python, i Don't need to find the address of a variable, i need to make a label and record the location, and be able to jmp to it
Post 14 Dec 2010, 02:46
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3055
Location: vpcmipstrm
bitRAKE
Assembly allows pointer arithmetic. Without address support how will you implement jump tables or other such code?
Code:
jmp("eax")    
Post 14 Dec 2010, 08:45
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
masonswanson,

If You Do Really Need A Label, You Should Invent (Or Use Ready One) Syntactic Construct To Make One.
Code:
const ref here = loc $;    
Or Something Like That. Wink
Post 14 Dec 2010, 20:20
View user's profile Send private message Reply with quote
masonswanson



Joined: 17 Aug 2010
Posts: 51
masonswanson
Thanks But I Think I Am Going To Have It Use Something Like
Code:
Label("Labelname");
jmp("Labelname")
    

And then during the pass right before the last or the last pass it will compute where in the output "Labelname" would be, and adjust any reference to it then
Post 19 Dec 2010, 11:54
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.