flat assembler
Message board for the users of flat assembler.

Index > Main > Assembling/Linking From Linux to Mac and Windows

Author
Thread Post new topic Reply to topic
donn



Joined: 05 Mar 2010
Posts: 199
donn
Hi, just wondering the arguments I need, libraries, or any specific to Mac and Windows steps for assembling the 32 bit and 64bit versions text game app I wrote. It uses c library calls. Want the target machine to be a Mac version and a Windows version. Attached, you may find the source files. My current machine is Linux and the file works for my machine.


(note, the two previous separate threads are condensed here)


Description:
Download
Filename: Paths64.asm
Filesize: 11.02 KB
Downloaded: 169 Time(s)

Description:
Download
Filename: Paths32.asm
Filesize: 11.45 KB
Downloaded: 165 Time(s)

Post 02 Aug 2010, 02:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
Just to get you started here is a Window 32bit conversion. But you should also look at the fasm 'EXAMPLES' folder. It gives all the needed stuff to create basic programs like this.
Code:
format pe console
entry main

section '.data' data readable writeable

P1 db 'Hallo, soldier, what path would you like to take? That of a lost ancient Romantic? Or do you like a somewhat skilled monster, bent on revenge? Enter 1 for Romantic, 2 for Revenge.',10,0
A1 db 'A bird falls from a cloud down towards the swamp. Do you jump to protect the creature or call a winged scout to dive and catch it? Enter 1 for Jump, 2 for Call.',10,0
A2 db 'A bird falls closer and closer towards the bottom of the swamp. It has wronged you. Do you go elsewhere? Or do you grab it and hope it learns its lesson? Enter 1 for elsewhere, 2 for grab.',10,0
B11 db 'Oh no, why did you jump? Now the bird is alarmed and uses its remaining power to fly away, faster to the depths. What does this mean for you? I wish I was stronger. Or I never knew my dangerous potential? Enter 1 for strengthening, 2 for Potential.',10,0
B12 db 'Oh no, why did you call the scout? Now the bird is alarmed and uses its remaining power to fly away, faster to the depths. What does this mean for you? I wish I was stronger. Or I never knew my dangerous potential.',10,0
B21 db "Oh no, why did you walk away? Now the bird sneaks up behind you, because it was displaying fake injury and stings your neck. What does this mean for you? I wish I was stronger. Or, that bird is clever, I'm gonna have it teach me. Enter 1 for stronger, 2 for clever.",10,0
B22 db "Oh no, why did you try to teach it? The bird is too stubborn, fails to hear you, and stings you and flees. What does this mean for you? I wish I was stronger. Or, that bird is clever, I'm gonna have it teach me. Enter 1 for stronger, 2 for clever.",10,0
C111 db "You have the ability to grow. Do you like to improve? Yes. Or No. Enter 1 for Yes, 2 for No.",10,0
C211 db "You have the ability to grow. Do you like to improve? Yes. Or No. Enter 1 for Yes, 2 for No.",10,0
C212 db 'The bird is in the distance and you watch. Many lessons can be gained from observations. Do you like to improve? Yes. Or, No. Enter 1 for Yes, 2 for No.',10,0
C121 db 'You have the ability to grow. Do you like to improve? Yes. Or No. Enter 1 for Yes, 2 for No.',10,0
C122 db 'You have the ability to grow more benevolent. Do you want this? Yes. Or No. Enter 1 for Yes, 2 for No.',10,0
C221 db 'You have the ability to grow. Do you like to improve? Yes. Or No. Enter 1 for Yes, 2 for No.',10,0
C222 db 'The bird is in the distance and you watch. Many lessons can be gained from observations. Do you like to improve? Yes. Or, No. Enter 1 for Yes, 2 for No.',10,0
C112 db "This side of you doesn't have many benefits for you down the road, except for your focus. You can use it when you grow. Do you like to improve? Yes. Or, No. Enter 1 for Yes, 2 for No.",10,0
D1111 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your wisdom to? Or do you simply stay content from having improved and sharing your lessons? Enter 1 for Rest, 2 for Shared.',10,0
D1112 db 'Too bad, your dreams are out of reach. Do you figure out how to gain a new path? Or, do you try to see the truth?',10,0
D2111 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your power to? Or do you simply get your revenge? Enter 1 for Rest, 2 for Revenge.',10,0
D2112 db "Too bad, your agenda is then halted as you don't care about pushing on. Do you figure out how to gain a new path? Or, do you try to see the truth?",10,0
D2121 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your power to? Or do you simply get your revenge? Enter 1 for Rest, 2 for Revenge.',10,0
D2122 db "Too bad, your agenda is then halted as you don't care about pushing on. Do you figure out how to gain a new path? Or, do you try to see the truth?",10,0
D1211 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your wisdom to? Or do you simply stay content from having improved and sharing your lessons? Enter 1 for Rest, 2 for Shared.',10,0
D1212 db 'Too bad, your dreams are out of reach. Do you figure out how to gain a new path? Or, do you try to see the truth?',10,0
D1221 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your wisdom to? Or do you simply stay content from having improved and sharing your lessons? Enter 1 for Rest, 2 for Shared.',10,0
D1222 db 'Too bad, your dreams are out of reach. Do you figure out how to gain a new path? Or, do you try to see the truth?',10,0
D2211 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your power to? Or do you simply get your revenge? Enter 1 for Rest, 2 for Revenge.',10,0
D2212 db "Too bad, your agenda is then halted as you don't care about pushing on. Do you figure out how to gain a new path? Or, do you try to see the truth?",10,0
D2222 db "Too bad, your agenda is then halted as you don't care about pushing on. Do you figure out how to gain a new path? Or, do you try to see the truth? Enter 1 for Gain, 2 for See.",10,0
D1121 db 'Now, you are set to be rewarded. Do you rest in the company of those you spread your wisdom to? Or do you simply stay content from having improved and sharing your lessons? Enter 1 for Rest, 2 for Shared.',10,0
D1122 db 'Too bad, your dreams are out of reach. Do you figure out how to gain a new path? Or, do you try to see the truth?',10,0
D2221 db 'Too bad, your dreams are out of reach. Do you figure out how to gain a new path? Or, do you try to see the truth?',10,0
E db 'It is done.',10,0
ONE dd '1',0
TWO dd '2',0
AnswerFormat db '%d',0

Answers rb 2

section '.text' code executable

main:
;Init
        push ebp
 mov ebp,esp
;Opus

SectionP1:              ;PRINT INITIAL MSG
Push P1
xor eax, eax
call [printf]
add esp, 4

Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 4

SectionCMP1:
cmp byte[Answers], 1
je SectionA1
cmp byte[Answers], 2
je SectionA2

SectionA1:
Push A1
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP2

SectionA2:
Push A2
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP3

SectionCMP2:
cmp byte[Answers], 1
je SectionB11
cmp byte[Answers], 2
je SectionB12

SectionCMP3:
cmp byte[Answers], 1
je SectionB21
cmp byte[Answers], 2
je SectionB22

SectionB11:
Push B11
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP4

SectionB12:
Push B12
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP5

SectionB21:
Push B21
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP6

SectionB22:
Push B22
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP7

SectionCMP4:
cmp byte[Answers], 1
je SectionC111
cmp byte[Answers], 2
je SectionC112

SectionCMP5:
cmp byte[Answers], 1
je SectionC121
cmp byte[Answers], 2
je SectionC122

SectionCMP6:
cmp byte[Answers], 1
je SectionC211
cmp byte[Answers], 2
je SectionC212

SectionCMP7:
cmp byte[Answers], 1
je SectionC221
cmp byte[Answers], 2
je SectionC222

SectionC111:
Push C111
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP8

SectionC112:
Push C112
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP9

SectionC121:
Push C121
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP10

SectionC122:
Push C122
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP11

SectionC211:
Push C211
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP12

SectionC212:
Push C212
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP13

SectionC221:
Push C221
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP14

SectionC222:
Push C222
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionCMP15

SectionCMP8:
cmp byte[Answers], 1
je SectionD1111
cmp byte[Answers], 2
je SectionD1112

SectionCMP9:
cmp byte[Answers], 1
je SectionD1121
cmp byte[Answers], 2
je SectionD1122

SectionCMP10:
cmp byte[Answers], 1
je SectionD1211
cmp byte[Answers], 2
je SectionD1212

SectionCMP11:
cmp byte[Answers], 1
je SectionD1221
cmp byte[Answers], 2
je SectionD1222

SectionCMP12:
cmp byte[Answers], 1
je SectionD2111
cmp byte[Answers], 2
je SectionD2112

SectionCMP13:
cmp byte[Answers], 1
je SectionD2121
cmp byte[Answers], 2
je SectionD2122

SectionCMP14:
cmp byte[Answers], 1
je SectionD2211
cmp byte[Answers], 2
je SectionD2212

SectionCMP15:
cmp byte[Answers], 1
je SectionD2221
cmp byte[Answers], 2
je SectionD2222

SectionD1111:
Push D1111
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1112:
Push D1112
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1121:
Push D1121
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1122:
Push D1122
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1211:
Push D1211
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1212:
Push D1111
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1221:
Push D1221
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD1222:
Push D1222
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2111:
Push D2111
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2112:
Push D2112
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2121:
Push D2121
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2122:
Push D2122
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2211:
Push D2211
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2212:
Push D2212
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2221:
Push D2221
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionD2222:
Push D2222
xor eax, eax
call [printf]
add esp, 4
Push Answers
Push AnswerFormat
xor eax, eax
call [scanf]
add esp, 8
jmp SectionE

SectionE:
Push E
xor eax, eax
call [printf]

;End
        mov esp, ebp
        pop ebp
        ret

section '.idata' import data readable

    dd      0,0,0,RVA msvcrt_name,RVA msvcrt_table
      dd      0,0,0,0,0

       msvcrt_table:
           scanf   dd      RVA _scanf
          printf  dd      RVA _printf
                 dd      0

       msvcrt_name     db      'MSVCRT.DLL',0

        _scanf  db      0,0,'scanf',0
     _printf db      0,0,'printf',0    
Post 02 Aug 2010, 05:27
View user's profile Send private message Visit poster's website Reply with quote
donn



Joined: 05 Mar 2010
Posts: 199
donn
hey thanks revolution thats nice, looked at the examples. I'll look at them over the course of a few weeks. And may need to reference them down the road. I think for 64bit, its
Code:
format pe64 console    
, an example used that.

I attached a 64-bit Win version (.asm not exe cause exe wont attach), but am unable to test it at the moment. Looked at the differences in 32-bit linux and win, its making sense. Dont really understand all of the idata section, like i dont know what rva means, this is all probably to load the scanf and printf code from libraries, in windows its .dlls?

Great, again nice of u, more to tackle down the road.

Denat


Description:
Download
Filename: Paths64.asm
Filesize: 11.19 KB
Downloaded: 172 Time(s)

Post 12 Aug 2010, 03:25
View user's profile Send private message 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.