SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
1
Nombre: Johnny Aragón. Fecha: 28 de Abril del 2015.
Pantallas de instalación EMU8086
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
2
Código Hola mundo en ensamblador.
; "hello, world!" step-by-step char-by-char way...
; this is very similar to what int 21h/9h does behind your eyes.
; instead of $, the string in this example is zero terminated
; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating
system)
name "hello"
org 100h ; compiler directive to make tiny com file.
; execution starts here, jump over the data string:
jmp start
; data string:
msg db 'Hello, world!', 0
start:
; set the index register:
mov si, 0
next_char:
; get current character:
mov al, msg[si]
; is it zero?
; if so stop printing:
cmp al, 0
je stop
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
3
; print character in teletype mode:
mov ah, 0eh
int 10h
; update index register by 1:
inc si
; go back to print another char:
jmp next_char
stop: mov ah, 0 ; wait for any key press.
int 16h
; exit here and return control to operating system...
ret
end ; to stop compiler.
this text is not compiled and is not checked for errors,
because it is after the end directive;
however, syntax highlight still works here.
Código Hola mundo en ensamblador en español.
; "hello, world!" step-by-step char-by-char way...
; this is very similar to what int 21h/9h does behind your eyes.
; instead of $, the string in this example is zero terminated
; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating
system)
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
4
name "hello"
org 100h ; compiler directive to make tiny com file.
; execution starts here, jump over the data string:
jmp start
; data string:
msg db 'Hela - Mundo!', 0
start:
; set the index register:
mov si, 0
next_char:
; get current character:
mov al, msg[si]
; is it zero?
; if so stop printing:
cmp al, 0
je stop
; print character in teletype mode:
mov ah, 0eh
int 10h
; update index register by 1:
inc si
; go back to print another char:
jmp next_char
stop: mov ah, 0 ; wait for any key press.
int 16h
; exit here and return control to operating system...
ret
end ; to stop compiler.
this text is not compiled and is not checked for errors,
because it is after the end directive;
however, syntax highlight still works here.
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
5
Código datos completos en ensamblador.
; "hello, world!" step-by-step char-by-char way...
; this is very similar to what int 21h/9h does behind your eyes.
; instead of $, the string in this example is zero terminated
; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating
system)
name "Johnny Alejandro Aragon Puetate, PUCE-SI, 28/04/2015, Compiladores"
org 100h ; compiler directive to make tiny com file.
; execution starts here, jump over the data string:
jmp start
; data string:
msg db 'Hela - Mundo!', 0
start:
; set the index register:
mov si, 0
next_char:
; get current character:
mov al, msg[si]
; is it zero?
; if so stop printing:
cmp al, 0
je stop
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
6
; print character in teletype mode:
mov ah, 0eh
int 10h
; update index register by 1:
inc si
; go back to print another char:
jmp next_char
stop: mov ah, 0 ; wait for any key press.
int 16h
; exit here and return control to operating system...
ret
end ; to stop compiler.
this text is not compiled and is not checked for errors,
because it is after the end directive;
however, syntax highlight still works here.
Código comparación de dos números en ensamblador.
name "flags"
org 100h
; this sample shows how cmp instruction sets the flags.
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
7
; usually cmp instruction is followed by any relative
; jump instruction such as: je, ja, jl, jae...
; it is recommended to click "flags" and "analyze"
; for better visual expirience before stepping through this code.
; (signed/unsigned)
; 4 is equal to 4
mov ah, 4
mov al, 4
cmp ah, al
nop
; (signed/unsigned)
; 4 is above and greater then 3
mov ah, 4
mov al, 3
cmp ah, al
nop
; -5 = 251 = 0fbh
; (signed)
; 1 is greater then -5
mov ah, 1
mov al, -5
cmp ah, al
nop
; (unsigned)
; 1 is below 251
mov ah, 1
mov al, 251
cmp ah, al
nop
; (signed)
; -3 is less then -2
mov ah, -3
mov al, -2
cmp ah, al
nop
; (signed)
; -2 is greater then -3
mov ah, -2
mov al, -3
cmp ah, al
nop
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
8
; (unsigned)
; 255 is above 1
mov ah, 255
mov al, 1
cmp ah, al
nop
; now a little game:
game: mov dx, offset msg1
mov ah, 9
int 21h
; read character in al:
mov ah, 1
int 21h
cmp al, '0'
jb stop
cmp al, '9'
ja stop
cmp al, '5'
jb below
ja above
mov dx, offset equal_5
jmp print
below: mov dx, offset below_5
jmp print
above: mov dx, offset above_5
print: mov ah, 9
int 21h
jmp game ; loop.
stop: ret ; stop
msg1 db "enter a number or any other character to exit: $"
equal_5 db " is five! (equal)", 0Dh,0Ah, "$"
below_5 db " is below five!" , 0Dh,0Ah, "$"
above_5 db " is above five!" , 0Dh,0Ah, "$"
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
9
Código que permita sumar 10 valores asignados a un vector
name "calc-sum"
org 100h ; directive make tiny com file.
; calculate the sum of elements in vector,
; store result in m and print it in binary code.
; number of elements:
mov cx, 10
; al will store the sum:
mov al, 0
; bx is an index:
mov bx, 0
; sum elements:
next: add al, vector[bx]
; next byte:
inc bx
; loop until cx=0:
loop next
; store result in m:
mov m, al
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
10
; print result in binary:
mov bl, m
mov cx, 8
print: mov ah, 2 ; print function.
mov dl, '0'
test bl, 11011111b ; test first bit.
jz zero
mov dl, '1'
zero: int 21h
shl bl, 1
loop print
; print binary suffix:
mov dl, 'b'
int 21h
mov dl, 0ah ; new line.
int 21h
mov dl, 0dh ; carrige return.
int 21h
; print result in decimal:
mov al, m
call print_al
; wait for any key press:
mov ah, 0
int 16h
ret
; variables:
vector db -8, 4, 8, 2, 1, 7, 6 ,1, -2, 5
m db 0
print_al proc
cmp al, 0
jne print_al_r
push ax
mov al, '0'
mov ah, 0eh
PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA
TRABAJO COMPILADORES EMU8086.
11
int 10h
pop ax
ret
print_al_r:
pusha
mov ah, 0
cmp ax, 0
je pn_done
mov dl, 10
div dl
call print_al_r
mov al, ah
add al, 30h
mov ah, 0eh
int 10h
jmp pn_done
pn_done:
popa
ret
endp

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Emulador emu8086
Emulador emu8086Emulador emu8086
Emulador emu8086
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
 
ICP - Lecture 9
ICP - Lecture 9ICP - Lecture 9
ICP - Lecture 9
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
 
Perl In The Command Line
Perl In The Command LinePerl In The Command Line
Perl In The Command Line
 
Lecture05(control structure part ii)
Lecture05(control structure part ii)Lecture05(control structure part ii)
Lecture05(control structure part ii)
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
 
Looping in C
Looping in CLooping in C
Looping in C
 
Java Programming: Loops
Java Programming: LoopsJava Programming: Loops
Java Programming: Loops
 
Knee-deep in C++ s... code
Knee-deep in C++ s... codeKnee-deep in C++ s... code
Knee-deep in C++ s... code
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
2 data and c
2 data and c2 data and c
2 data and c
 
Java Programmin: Selections
Java Programmin: SelectionsJava Programmin: Selections
Java Programmin: Selections
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
 
Cracking for beginners - copy (2)
Cracking for beginners - copy (2)Cracking for beginners - copy (2)
Cracking for beginners - copy (2)
 
Loops
LoopsLoops
Loops
 
Logging in JavaScript - part-2
Logging in JavaScript - part-2Logging in JavaScript - part-2
Logging in JavaScript - part-2
 
for loop in java
for loop in java for loop in java
for loop in java
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
 

Similar a Emulador de ensamblador EMU8086

Similar a Emulador de ensamblador EMU8086 (20)

Compiladores emu8086
Compiladores emu8086Compiladores emu8086
Compiladores emu8086
 
[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
Algoritmos ensambladores
Algoritmos ensambladoresAlgoritmos ensambladores
Algoritmos ensambladores
 
Taller Ensambladores
Taller EnsambladoresTaller Ensambladores
Taller Ensambladores
 
Marco acosta emu
Marco acosta emuMarco acosta emu
Marco acosta emu
 
Oracle pl sql
Oracle pl sqlOracle pl sql
Oracle pl sql
 
030 cpp streams
030 cpp streams030 cpp streams
030 cpp streams
 
Emu8086
Emu8086Emu8086
Emu8086
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
Intro to OpenMP
Intro to OpenMPIntro to OpenMP
Intro to OpenMP
 
05 Jo P May 07
05 Jo P May 0705 Jo P May 07
05 Jo P May 07
 
Input-output
Input-outputInput-output
Input-output
 
BOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPTBOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPT
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
Lab manual mp
Lab manual mpLab manual mp
Lab manual mp
 

Más de Jhon Alexito

Más de Jhon Alexito (12)

Web host ntp
Web host ntpWeb host ntp
Web host ntp
 
Historia de usuario proyecto ntp
Historia de usuario proyecto ntpHistoria de usuario proyecto ntp
Historia de usuario proyecto ntp
 
Trabajo flex byson
Trabajo flex bysonTrabajo flex byson
Trabajo flex byson
 
Análisis sintáctico ascendente descendente
Análisis sintáctico ascendente   descendenteAnálisis sintáctico ascendente   descendente
Análisis sintáctico ascendente descendente
 
Python compiladores
Python compiladoresPython compiladores
Python compiladores
 
Decompiladores
DecompiladoresDecompiladores
Decompiladores
 
Mapa compiladores
Mapa compiladoresMapa compiladores
Mapa compiladores
 
Doc1
Doc1Doc1
Doc1
 
Doc1
Doc1Doc1
Doc1
 
Doc1
Doc1Doc1
Doc1
 
Doc1
Doc1Doc1
Doc1
 
INTRODUCCIÓN COMPILADORES
INTRODUCCIÓN COMPILADORESINTRODUCCIÓN COMPILADORES
INTRODUCCIÓN COMPILADORES
 

Último

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 

Último (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

Emulador de ensamblador EMU8086

  • 1. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 1 Nombre: Johnny Aragón. Fecha: 28 de Abril del 2015. Pantallas de instalación EMU8086
  • 2. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 2 Código Hola mundo en ensamblador. ; "hello, world!" step-by-step char-by-char way... ; this is very similar to what int 21h/9h does behind your eyes. ; instead of $, the string in this example is zero terminated ; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating system) name "hello" org 100h ; compiler directive to make tiny com file. ; execution starts here, jump over the data string: jmp start ; data string: msg db 'Hello, world!', 0 start: ; set the index register: mov si, 0 next_char: ; get current character: mov al, msg[si] ; is it zero? ; if so stop printing: cmp al, 0 je stop
  • 3. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 3 ; print character in teletype mode: mov ah, 0eh int 10h ; update index register by 1: inc si ; go back to print another char: jmp next_char stop: mov ah, 0 ; wait for any key press. int 16h ; exit here and return control to operating system... ret end ; to stop compiler. this text is not compiled and is not checked for errors, because it is after the end directive; however, syntax highlight still works here. Código Hola mundo en ensamblador en español. ; "hello, world!" step-by-step char-by-char way... ; this is very similar to what int 21h/9h does behind your eyes. ; instead of $, the string in this example is zero terminated ; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating system)
  • 4. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 4 name "hello" org 100h ; compiler directive to make tiny com file. ; execution starts here, jump over the data string: jmp start ; data string: msg db 'Hela - Mundo!', 0 start: ; set the index register: mov si, 0 next_char: ; get current character: mov al, msg[si] ; is it zero? ; if so stop printing: cmp al, 0 je stop ; print character in teletype mode: mov ah, 0eh int 10h ; update index register by 1: inc si ; go back to print another char: jmp next_char stop: mov ah, 0 ; wait for any key press. int 16h ; exit here and return control to operating system... ret end ; to stop compiler. this text is not compiled and is not checked for errors, because it is after the end directive; however, syntax highlight still works here.
  • 5. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 5 Código datos completos en ensamblador. ; "hello, world!" step-by-step char-by-char way... ; this is very similar to what int 21h/9h does behind your eyes. ; instead of $, the string in this example is zero terminated ; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating system) name "Johnny Alejandro Aragon Puetate, PUCE-SI, 28/04/2015, Compiladores" org 100h ; compiler directive to make tiny com file. ; execution starts here, jump over the data string: jmp start ; data string: msg db 'Hela - Mundo!', 0 start: ; set the index register: mov si, 0 next_char: ; get current character: mov al, msg[si] ; is it zero? ; if so stop printing: cmp al, 0 je stop
  • 6. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 6 ; print character in teletype mode: mov ah, 0eh int 10h ; update index register by 1: inc si ; go back to print another char: jmp next_char stop: mov ah, 0 ; wait for any key press. int 16h ; exit here and return control to operating system... ret end ; to stop compiler. this text is not compiled and is not checked for errors, because it is after the end directive; however, syntax highlight still works here. Código comparación de dos números en ensamblador. name "flags" org 100h ; this sample shows how cmp instruction sets the flags.
  • 7. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 7 ; usually cmp instruction is followed by any relative ; jump instruction such as: je, ja, jl, jae... ; it is recommended to click "flags" and "analyze" ; for better visual expirience before stepping through this code. ; (signed/unsigned) ; 4 is equal to 4 mov ah, 4 mov al, 4 cmp ah, al nop ; (signed/unsigned) ; 4 is above and greater then 3 mov ah, 4 mov al, 3 cmp ah, al nop ; -5 = 251 = 0fbh ; (signed) ; 1 is greater then -5 mov ah, 1 mov al, -5 cmp ah, al nop ; (unsigned) ; 1 is below 251 mov ah, 1 mov al, 251 cmp ah, al nop ; (signed) ; -3 is less then -2 mov ah, -3 mov al, -2 cmp ah, al nop ; (signed) ; -2 is greater then -3 mov ah, -2 mov al, -3 cmp ah, al nop
  • 8. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 8 ; (unsigned) ; 255 is above 1 mov ah, 255 mov al, 1 cmp ah, al nop ; now a little game: game: mov dx, offset msg1 mov ah, 9 int 21h ; read character in al: mov ah, 1 int 21h cmp al, '0' jb stop cmp al, '9' ja stop cmp al, '5' jb below ja above mov dx, offset equal_5 jmp print below: mov dx, offset below_5 jmp print above: mov dx, offset above_5 print: mov ah, 9 int 21h jmp game ; loop. stop: ret ; stop msg1 db "enter a number or any other character to exit: $" equal_5 db " is five! (equal)", 0Dh,0Ah, "$" below_5 db " is below five!" , 0Dh,0Ah, "$" above_5 db " is above five!" , 0Dh,0Ah, "$"
  • 9. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 9 Código que permita sumar 10 valores asignados a un vector name "calc-sum" org 100h ; directive make tiny com file. ; calculate the sum of elements in vector, ; store result in m and print it in binary code. ; number of elements: mov cx, 10 ; al will store the sum: mov al, 0 ; bx is an index: mov bx, 0 ; sum elements: next: add al, vector[bx] ; next byte: inc bx ; loop until cx=0: loop next ; store result in m: mov m, al
  • 10. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 10 ; print result in binary: mov bl, m mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 11011111b ; test first bit. jz zero mov dl, '1' zero: int 21h shl bl, 1 loop print ; print binary suffix: mov dl, 'b' int 21h mov dl, 0ah ; new line. int 21h mov dl, 0dh ; carrige return. int 21h ; print result in decimal: mov al, m call print_al ; wait for any key press: mov ah, 0 int 16h ret ; variables: vector db -8, 4, 8, 2, 1, 7, 6 ,1, -2, 5 m db 0 print_al proc cmp al, 0 jne print_al_r push ax mov al, '0' mov ah, 0eh
  • 11. PONTIFICIA UNIVERSIDAD DEL ECUADOR - SEDE IBARRA TRABAJO COMPILADORES EMU8086. 11 int 10h pop ax ret print_al_r: pusha mov ah, 0 cmp ax, 0 je pn_done mov dl, 10 div dl call print_al_r mov al, ah add al, 30h mov ah, 0eh int 10h jmp pn_done pn_done: popa ret endp