Está en la página 1de 29

Universidad Mayor de San Simón

Taller de Programación en Bajo Nivel


http://bnivel.webs.com

PROGRAMACIÓN AVANZADA
INTRODUCCIÓN A FASM

Niels Saavedra Tapia


niels.saavedra@gmail.com
Cochabamba, Noviembre 2014
INTRODUCCIÓN
“There are three reasons for using assembly
language: speed, speed, and more speed”
‒ Randall Hyde
HISTORIA DE LOS REGISTROS EN x86
• Año 1960: 8080
– Registro A de 8 bits
• Año 1980: 8086
– Registro AX de 16 bits
• Año 1985: 80386
– Registro EAX de 32 bits
• Año 2000: x86_64
– Registro RAX de 64 bits
• Año 2013: Intel Xeon Phi
– Registros de 512 bits (criptografia, ip6, qw flotante)
HLL vs. ASM
(Fuente: IRVINE, Assembly Language for x86 Processors – 2011)


ASSEMBLY ≠ ASSEMBLER
(Fuente: NPTEL, Compiler Desing) programa
Lenguaje Ensamblador: Lenguaje Máquina:
Assembly Language Machine Code (bytecode)
Lenguaje basado en Lenguaje en que trabaja la
mnemónicos/comandos que computadora, comandos
permite escribir un código y datos almacenados en
fuente en bajo nivel. sistema binario/hexa.

Ensamblador: Assembler
Programa que se encarga de ensamblar o convertir
el código fuente en código máquina.
TIPOS DE LENGUAJE ENSAMBLADOR
• Intel y AMD
– x86 Assembly Language
– MASM: Macro Assembler (Microsoft)
– FASM: Flat Assembler (Tomasz Grysztar)
– NASM: Netwide Assembler (Simon Tatham)
– TASM: Turbo Assembler (Borland)
– [otros...]
– x64 Assembly Language
TIPOS DE LENGUAJE ENSAMBLADOR
• MAC (Apple)
– OS X Assembler
• Android
– ARM Assembly
• Microprocesarores
– 6800 de Motorola (Microprocesadores I)
– 68K de Motorola (Microprocesadores II)
• Microcontroladores
– PIC de Microchip (Diseño de Sistemas Digitales I)
– AVR de Atmel
IDE: WinAsm Studio
FASM
FASM: FLAT ASSEMBLER

• high speed
• size optimizations
• macro abilities
• operating system portability
– x86, x86-64
– Windows, Linux
VERSIONES DE FASM: WHAT’S NEW?
• version 1.71.22 (Sep 28, 2014)
[-] Format MZ no longer allows the table of relocations to overflow.

• version 1.71.21 (May 27, 2014)


[-] Fixed a bug in the 64-bit floating points value converter.

• version 1.71.20 (Feb 27, 2014)


[-] Fixed a bug in the backward patching of PE fixups.

• version 1.71.19 (Feb 09, 2014)


[-] Corrected some of the range errors in intermediate passes to be
correctly resolvable.

• version 1.71.18 (Feb 02, 2014)


[+] Added "irpv" directive.
ÚLTIMA VERSIÓN DE FASM
(NOVIEMBRE 2015)

flat assembler 1.71.22 for Windows


size: 999 kilobytes
last update: 08 Oct 2014 14:36:22 UTC

http://flatassembler.net/download.php
INSTALACIÓN DE FASM
• No se instala

• Sólo descomprimir y
copiar a la raíz del
disco C la carpeta:

fasmw17122
IDE: FASMW
c:\fasmw17122\FASMW.EXE
EJEMPLO
pa01_message_box.asm
pa01_message_box.asm
• El programa invoca una función de Windows:
– Invoke MessageBox, ...

• La función MessageBox recibe parámetros:


– NULL …… handle
– ‘mensaje’ …… mensaje
– ‘titulo’ …… texto
– MB_OK …… estilo
WIN32.HLP
Microsoft® Win32® Programmer's Reference

• La programación en Windows con FASM requiere


utilizar funciones gráficas del sistema operativo
mediante una API denominada:
– C:\fasmw17122\INCLUDE\win32ax.inc
• Toda la documentación para esto está en el archivo:
– ...\win32.hlp (descargar aparte)
• Desde Windows 7 para arriba hay que instalar:
– Windows6.1-KB917607-x86.msu (32 bits)
– Windows6.1-KB917607-x64.msu (64 bits)
RECOMENDACIONES
SITIOS WEB RECOMENDADOS
• FASM Official Message Board
– http://board.flatassembler.net/
– foro oficial de Flat Assembler
• Stack Overflow
– http://stackoverflow.com/
– buscar con tags: asm, fasm, assembler, etc.
• Abre los Ojos al Ensamblador
– http://www.abreojosensamblador.net/Productos/A
OE/html/Pags/Cap20.html/
CLASES DE AYUDANTÍA

← 2P
← EF
← SI

Enviar consultas y código para depurar a:


niels.saavedra@gmail.com
MATERIAL DE LA CLASE DE HOY
• TPBN_NOV_2014
– ejemplos\
– slides\
– WIN32_HELP\
– flat-assembler_OCT_2014.zip
FIN

También podría gustarte