flat assembler
Message board for the users of flat assembler.

Index > Heap > paradox ?

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
So in the example revoltion gave:

mov ax,5 ; B8 05 00
mov bx,5 ; BB 05 00
add ax,bx ; 01 D8

the left handside are opcodes and the right handside are hex representation of machine codes ?
Post 23 Apr 2011, 11:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
If you put this into a text file:
Code:
mov ax,5
mov bx,5
add ax,bx    
and assemble it with fasm:
Code:
fasm roboticmehdi_stuff.asm    
fasm will then produce a binary file with 8 bytes:
Code:
B8 05 00 BB 05 00 01 D8    
Post 23 Apr 2011, 11:24
View user's profile Send private message Visit poster's website Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
i tried that and it really does the way you told revolution. but when i try to run it it says "bash: ./mhd_001: cannot execute binary file". why it can not be executed ? ( my operating system is ubuntu 10.10 )
Post 23 Apr 2011, 13:51
View user's profile Send private message Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
note: mhd_001 is the output file of fasm when it compiled mhd_001.asm
Post 23 Apr 2011, 13:52
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
If you want to run a program under an OS then you need to have an executable format output.
Code:
format elf    
Anyhow see the examples folder that comes with fasm to see what the sources look like for that.
Post 23 Apr 2011, 13:59
View user's profile Send private message Visit poster's website Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
Ok thanks. What is an interrupt? ( again i read in wikipedia but did not understand much ). Is it an instruction or a set of instructions that are executed when we call an interrupt? and if so where are they stored? are the OS dependent or CPU dependent ?
Post 30 Apr 2011, 08:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Interrupts are external events from other chips/devices. The chip/device alerts the CPU that it wants attention. The CPU then jumps to a programmer specified address and starts running the code there. Normally the interrupt code would determine which device is interrupting and take appropriate action before returning to the program that was running before the interrupt occurred.

Just like when your mother interrupts your game and tells you to take out the rubbish. You pause the game and take out the rubbish (yes you do, everyone obeys their mother). After you have finished taking out the rubbish you go back to the game and continue playing.
Post 30 Apr 2011, 08:15
View user's profile Send private message Visit poster's website Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
Is it possible to do things that interrupts do without actually calling an interrupt, using cpu instructions ? in hello world example( in fasm folder ) the interrupt "int 0x80" is used twise. what doest it do? what is the chip/device it uses ?
Post 30 Apr 2011, 08:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Oh, int 0x80 is a software instruction, from your code. And, yes, you can do anything and everything without using int, but it will make your job a lot harder. The OS has many inbuilt functions (called with int 0x80) that save you having to write the code yourself. If you want to avoid int then you have stop using the OS and do it all yourself because code running in a protected OS (like Linux) will force you to use interrupts to do "things" that affect the system.
Post 30 Apr 2011, 08:38
View user's profile Send private message Visit poster's website Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
how was the first assembler created, using row machine codes?
Post 30 Apr 2011, 20:03
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
roboticmehdi wrote:
how was the first assembler created, using row machine codes?

yes, but for your question there is a part thet is not asked xD

Imagen that you have an empty machine, with no assembler nor a compiler...
but you have a hex editor.
So you open the hex editor, and type machine could yourselve to create an assembler. Or a Hight level language... an assembler should be much easier.

Now you have an assembler. With him, you now create a Complier (C compiler) and start creating all kind of programs, paint, notepad, browser etc...




and the real question hear is, how was created that first hex editor if you not have created an asembler first xD

Here is the answer:

revolution wrote:

Front panel switches to input code. Manually assembled
Front panel switches to input an assembler. Manually assembled.


But i really don't now how it workes really, I guess never saw one of those ^^
Post 30 Apr 2011, 20:45
View user's profile Send private message Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
hey that makes sense Very Happy but i guess it must be really hard to make a hex editor using panel swithches manually Very Happy that is real programming !!
Post 30 Apr 2011, 20:58
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
roboticmehdi wrote:
hey that makes sense Very Happy but i guess it must be really hard to make a hex editor using panel swithches manually Very Happy that is real programming !!

perhaps they did directly some kind of simple assembler using the front switch panel. But yeas, this is the way it was done.
Post 01 May 2011, 13:23
View user's profile Send private message Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
As you already know i dont know assembly very well. But i now want to try to leran it. What do you suggest? My operating system is gnu/linux (ubuntu11.04) and MS-DOS. ( i am using both ). So far i have downloaded the fasm for linux but i want to download one for dos too. Where should i start leraning assembly ? Any suggestions?
Post 21 May 2011, 10:12
View user's profile Send private message Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
Oh by the way, my programming background is i would say, fine. My favourite compiler is turbo pascal 7.0. I am using it to write my own 3D engine. It supports 8086 and 80286 inline assembly. I sometimes copy/paste little assembly codes in my programs to speed things up.
Post 21 May 2011, 10:16
View user's profile Send private message Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
nobody ? Sad
Post 21 May 2011, 20:19
View user's profile Send private message Reply with quote
ctl3d32



Joined: 30 Dec 2009
Posts: 204
Location: Brazil
ctl3d32
There is http://win32assembly.online.fr/ for windows 32-bits assembly programming.
Post 22 May 2011, 00:20
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
You need to read carefully and to understand the FASM documentation and to play a lot with the examples.
Unfortunately, the materials for Linux assembly programming are not so much and most of them are for advanced assembly programmers.
Check every source you see here on the forum and ask questions.

The best approach is to begin some small (or middle) project with FASM and to learn on the fly. Don't be afraid to rewrite big portions of this project - important is the process, not the final goal.
Post 22 May 2011, 07:44
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
roboticmehdi



Joined: 20 Apr 2011
Posts: 22
roboticmehdi
revolution wrote:
Oh, int 0x80 is a software instruction, from your code. And, yes, you can do anything and everything without using int, but it will make your job a lot harder. The OS has many inbuilt functions (called with int 0x80) that save you having to write the code yourself. If you want to avoid int then you have stop using the OS and do it all yourself because code running in a protected OS (like Linux) will force you to use interrupts to do "things" that affect the system.


Hey revolution, i read your comments again and here you said if i want to avoid using int i should stop using OS. but how can i do programming without an OS ? maye you want to say that i should use real mode os like ms-dos instead of protected like windows or linux. ?
Post 06 Jun 2011, 22:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
roboticmehdi wrote:
Hey revolution, i read your comments again and here you said if i want to avoid using int i should stop using OS. but how can i do programming without an OS ? maye you want to say that i should use real mode os like ms-dos instead of protected like windows or linux. ?
You don't have to run an OS on your PC. You can just write an app directly and boot it up. I'm not saying it is easy, but it can be done. OSes are there to make many things both standard, and easier, for users (and programmers). It is simply personal preference if you wish to not use an OS, but your learning curve will likely be very steep.
Post 07 Jun 2011, 12:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.