0

I'm learning Assembly and I really like the concepts of the bare PUSH and POP instructions. I really love the low level stuff. I have been following this tutorial and this is some of the code that you can make a simple .exe out of:

MOV AH,02   ; Function to output a char
MOV DL,"!"      ; Character to output
INT 21h ; Call the interrupt to output "!"
MOV AH,04Ch ; Select exit function
MOV AL,00   ; Return 0
INT 21h ; Call the interrupt to exit

The guy says you can assemble this code with A86, but when I whent to their site it seemed as If it was extinct and the program version only went up to Windows XP? Is there an A86 assembler for Windows 64 bit? What type of assembler uses these EXTREMELY simple instructions? (I don't really like MASM or FASM that much)

Thanks!

P.S. I have been reverse engineering programs with Olly DBG which is why I've been learning more about assembly, and hence learning about PUSH, POP, MOV, and INT.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
43.52.4D.
  • 950
  • 6
  • 14
  • 28
  • In my experience, most universities use MIPS for learning assembly. There are online assemblers and simulators, for example http://alanhogan.com/asu/assembler.php – TJD Aug 24 '12 at 00:47

2 Answers2

2

Well, the tutorial you are using is 16bit DOS code and that will not work on modern OS's. Learn 32bit Assembly and you will be better off.

x86 Assemblers.

MASM - Ok, you don't like it
FASM - Now your being too picky.
NASM 
YASM
RoASM
JWasm
GoASM

and a few others. If you don't like FASM, then you probably won't like the others either.

Gunner
  • 5,780
  • 2
  • 25
  • 40
  • Well I do like FASM better then the others...But I find it strange that code for FASM: .code start: invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK invoke ExitProcess,0 .end start Could be so different from the plain push and pop instructions... – 43.52.4D. Aug 24 '12 at 05:15
  • 1
    @43.52.4D. Look at the disassembly or the listing file or the definition of the `invoke` macro. You will find quite a few pushes inside `invoke` if there are parameters. – Alexey Frunze Aug 24 '12 at 07:31
  • Yeah, I've been been disassembling programs in Olly Dbg which is why I kinda wished that their was an assembly language closer to what I was looking at. Am I a programming masochist? Maybe... – 43.52.4D. Aug 24 '12 at 11:17
  • All the assembers nowadays allow use of the high level stuff. Invoke is just a macro. You don't have to use it. Use push/call, hell you could use direct opcodes instead of mnuemonics. What I write is what I see in a debugger so im not sure what your doing – Gunner Aug 24 '12 at 11:40
  • 1
    I would add that learning 16-bit assembler is largely a waste of time these days. For nostalgia reasons, a peek at it could be enlightening, but learning it is equivalent to learning Greek. This is due to vast hardware changes spanning three decades. For instance, 16-bit segmented RAM into 64k "pages" since 16 bits of addressability = 2^16 = 64k. It was up to the compiler (or assembly coder!) to handle paging! 32-bit uses a "flat" memory model, since 2^32 = 4GB. 16-bit won't run natively on newer Microsoft OS's either; have to run it in [DosBox](http://www.dosbox.com/) or similar. – rdtsc May 27 '15 at 03:01
0

A simple example.asm program which uses plain x86 instructions may look like this:

example PROGRAM Format=PE,Entry=WinMain:
         IMPORT MessageBoxA, Lib=user32.dll ; Declare used Windows functions.
         IMPORT ExitProcess, Lib=kernel32.dll
WinMain: PUSH 0                             ; Show MB_OK button in MessageBox.
         PUSH ="I'm the box caption."       ; Text in MessageBox title.
         PUSH ="I'm the example program!"   ; Text to show within MessageBox.
         PUSH 0                             ; MessageBox belongs to the desktop.
         CALL MessageBoxA                   ; Invoke Windows function.
         PUSH 0                             ; Errorlevel to terminate with.
         CALL ExitProcess                   ; Invoke Windows function. 
        ENDPROGRAM

It can be converted to example.exe by €ASM with command euroasm example.asm

If you abandon your plain assembly programming masochism and learn to use macros, as @Gunner recommends, they will encapsulate the boring repetitive stuff and allow you to concentrate on the actual assembly. Example which uses macro WinAPI will be much shorter:

example PROGRAM Format=PE,Entry=WinMain:
         INCLUDE winapi.htm
WinMain: WinAPI MessageBox,Lib=user32.dll,0,="I'm the example program!",="I'm the box caption.",0
         TerminateProgram 0
        ENDPROGRAM
vitsoft
  • 5,515
  • 1
  • 18
  • 31