jueves, 31 de enero de 2019

miércoles, 30 de enero de 2019

Ensambladores online

Practica #2 
Código:
; Simple example
; Writes Hello World to the output

JMP start
hello: DB "ALONDRA!" ; Variable
       DB 0 ; String terminator

start:
MOV C, hello    ; Point to var
MOV D, 232 ; Point to output
CALL print
        HLT             ; Stop execution

print: ; print(C:*from, D:*to)
PUSH A
PUSH B
MOV B, 0
.loop:
MOV A, [C] ; Get char from var
MOV [D], A ; Write to output
INC C
INC D
CMP B, [C] ; Check if end
JNZ .loop ; jump if not

POP B
POP A
RET

Código:
section .text
global _start       ;must be declared for using gcc
_start:                     ;tell linker entry point
mov edx, len    ;message length
mov ecx, msg    ;message to write
mov ebx, 1     ;file descriptor (stdout)
mov eax, 4     ;system call number (sys_write)
int 0x80        ;call kernel
mov eax, 1     ;system call number (sys_exit)
int 0x80        ;call kernel

section .data

msg db 'Alondra Salazar!',0xa ;our dear string
len equ $ - msg ;length of our dear string


Código:
;nasm 2.11.08

section .data
    hello:     db 'Alondra Salazar',10    ; 'Hello world!' plus a linefeed character
    helloLen:  equ $-hello             ; Length of the 'Hello world!' string

section .text
global _start

_start:
mov eax,4            ; The system call for write (sys_write)
mov ebx,1            ; File descriptor 1 - standard output
mov ecx,hello        ; Put the offset of hello in ecx
mov edx,helloLen     ; helloLen is a constant, so we don't need to say
                     ;  mov edx,[helloLen] to get it's actual value
int 80h              ; Call the kernel

mov eax,1            ; The system call for exit (sys_exit)
mov ebx,0            ; Exit with return code of 0 (no error)
int 80h;


Emu8086
Código:


 Código:
.MODEL tiny
NAME "Hola a todos"

.DATA
dato db "Hola mundo", 0Dh,0Ah,24h
dato2 db "Como estas?$"

.CODE
INICIO:
mov dx, OFFSET dato
mov ah,09
int 21h

mov ah,0
int 16h
mov dx, OFFSET dato2
mov ah,09
int 21h
ret
END


martes, 29 de enero de 2019

Ensamblador de x86 para DOS

Practica 1.
En este programa despliega 2 mensajes en pantalla con el programa "emu8086"

Código:

.MODEL SMALL
.STACK
.DATA
CADENA1 DB 'HOLA MUNDO.$'
CADENA2 DB 'ALONDRA SALAZAR.$'
.CODE
PROGRAMA:
MOV AX,@DATA
MOV DS,AX
MOV DX,OFFSET CADENA1
MOV AH,9
INT 21H

MOV DX,OFFSET CADENA2
MOV AH,9
INT 21H 
END PROGRAMA 

Pantalla:


Practica #5 Unidad2

org 100h include 'emu8086.inc' mov si, 0 ;ponemos si en 0 comienzo: mov al, msg2[0] ;copiar la primera letra de la p...