SlideShare a Scribd company logo
Trabajo de compiladores
Nombre: Mauricio Muñoz
Nivel: 5
Ejercicio 1
Ejercicio 2
name "flags"
org 100h
; this sample shows how cmp instruction sets the flags.
; 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
; (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, '3'
jb below
ja above
mov dx, offset equal_3
jmp print
below: mov dx, offset below_3
jmp print
above: mov dx, offset above_3
print: mov ah, 9
int 21h
jmp game ; loop.
stop: ret ; stop
msg1 db "ingrese un numero para comparar o un caracter para salir: $"
equal_3 db " es igual a 3", 0Dh,0Ah, "$"
below_3 db " es menor que 3" , 0Dh,0Ah, "$"
above_3 db " es mayor que 3!" , 0Dh,0Ah, "$"
Ejercicio 3
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
; print result in binary:
mov bl, m
mov cx, 8
print: mov ah, 2 ; print function.
mov dl, '0'
test bl, 10000000b ; 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 9, 8, 7, 6, 5, 4, 5, 2, 1, 0
m db 0
print_al proc
cmp al, 0
jne print_al_r
push ax
mov al, '0'
mov ah, 0eh
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

More Related Content

What's hot

Looping in C
Looping in CLooping in C
Looping in C
Prabhu Govind
 
Richard practica nº2.php
Richard  practica nº2.phpRichard  practica nº2.php
Richard practica nº2.phprichardrq
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
yap_raiza
 
What is python
What is pythonWhat is python
What is pythonEU Edge
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
Aditi Bhushan
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-1603021543447b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
Branislav Simandel
 
Control flow in c
Control flow in cControl flow in c
Control flow in c
thirumalaikumar3
 
CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1
Buxoo Abdullah
 
Caligrafia para desenvolvedores
Caligrafia para desenvolvedoresCaligrafia para desenvolvedores
Caligrafia para desenvolvedoresDiogo Ribeiro
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
Lin Yo-An
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajangJaricka Angelyd Marquez
 
Emuladores
EmuladoresEmuladores
EmuladoresBayoch
 
Emulador emu8086
Emulador emu8086Emulador emu8086
Emulador emu8086
Gabriel Solano
 
TDD, a starting point...
TDD, a starting point...TDD, a starting point...
TDD, a starting point...
Francesco Fullone
 
PHP distribuído e paralelo: multithread + stream sockets
PHP distribuído e paralelo: multithread + stream socketsPHP distribuído e paralelo: multithread + stream sockets
PHP distribuído e paralelo: multithread + stream sockets
Diana Ungaro Arnos
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
Alex Toapanta
 
What JS? Itself
What JS? ItselfWhat JS? Itself
What JS? Itself
Lucio Martinez
 

What's hot (20)

Looping in C
Looping in CLooping in C
Looping in C
 
Richard practica nº2.php
Richard  practica nº2.phpRichard  practica nº2.php
Richard practica nº2.php
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
What is python
What is pythonWhat is python
What is python
 
Django debugging
Django debuggingDjango debugging
Django debugging
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-1603021543447b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
 
Control flow in c
Control flow in cControl flow in c
Control flow in c
 
CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1
 
C tutoria input outputl
C tutoria input outputlC tutoria input outputl
C tutoria input outputl
 
Caligrafia para desenvolvedores
Caligrafia para desenvolvedoresCaligrafia para desenvolvedores
Caligrafia para desenvolvedores
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
 
Emuladores
EmuladoresEmuladores
Emuladores
 
Emulador emu8086
Emulador emu8086Emulador emu8086
Emulador emu8086
 
TDD, a starting point...
TDD, a starting point...TDD, a starting point...
TDD, a starting point...
 
PHP distribuído e paralelo: multithread + stream sockets
PHP distribuído e paralelo: multithread + stream socketsPHP distribuído e paralelo: multithread + stream sockets
PHP distribuído e paralelo: multithread + stream sockets
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
 
What JS? Itself
What JS? ItselfWhat JS? Itself
What JS? Itself
 

Similar to Algoritmos ensambladores

Emulador de ensamblador emu8086
Emulador de ensamblador emu8086Emulador de ensamblador emu8086
Emulador de ensamblador emu8086
Marco Muñoz
 
Marco acosta emu
Marco acosta emuMarco acosta emu
Marco acosta emuPUCESI
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
Fabricio Galárraga
 
Ensamblador emu 8086
Ensamblador emu 8086Ensamblador emu 8086
Ensamblador emu 8086
edualex93echeverria
 
[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
Nora Youssef
 
Lab report assembly
Lab report assemblyLab report assembly
Lab report assembly
Syed Ahmed Zaki
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
Dr. Girish GS
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
warda aziz
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותlizliziz
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותlizliziz
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותlizliziz
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL BasicRon Liu
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
NBACriteria2SICET
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
 
Short Introduction To "perl -d"
Short Introduction To "perl -d"Short Introduction To "perl -d"
Short Introduction To "perl -d"
Workhorse Computing
 
Format String Exploitation
Format String ExploitationFormat String Exploitation
Format String Exploitation
UTD Computer Security Group
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersGiovanni924
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
Shankar D
 

Similar to Algoritmos ensambladores (20)

Emulador de ensamblador emu8086
Emulador de ensamblador emu8086Emulador de ensamblador emu8086
Emulador de ensamblador emu8086
 
Assembler
AssemblerAssembler
Assembler
 
Marco acosta emu
Marco acosta emuMarco acosta emu
Marco acosta emu
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
 
Ensamblador emu 8086
Ensamblador emu 8086Ensamblador emu 8086
Ensamblador emu 8086
 
[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
 
Lab report assembly
Lab report assemblyLab report assembly
Lab report assembly
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניות
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניות
 
פרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניותפרק 6 המחסנית ותת תכניות
פרק 6 המחסנית ותת תכניות
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
 
Short Introduction To "perl -d"
Short Introduction To "perl -d"Short Introduction To "perl -d"
Short Introduction To "perl -d"
 
Format String Exploitation
Format String ExploitationFormat String Exploitation
Format String Exploitation
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
 

Recently uploaded

How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 

Recently uploaded (20)

How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 

Algoritmos ensambladores

  • 1. Trabajo de compiladores Nombre: Mauricio Muñoz Nivel: 5 Ejercicio 1
  • 2. Ejercicio 2 name "flags" org 100h ; this sample shows how cmp instruction sets the flags. ; usually cmp instruction is followed by any relative ; jump instruction such as: je, ja, jl, jae...
  • 3. ; 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)
  • 4. ; 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 ; (unsigned) ; 255 is above 1 mov ah, 255 mov al, 1 cmp ah, al nop
  • 5. ; 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, '3' jb below ja above mov dx, offset equal_3 jmp print below: mov dx, offset below_3 jmp print above: mov dx, offset above_3 print: mov ah, 9 int 21h jmp game ; loop.
  • 6. stop: ret ; stop msg1 db "ingrese un numero para comparar o un caracter para salir: $" equal_3 db " es igual a 3", 0Dh,0Ah, "$" below_3 db " es menor que 3" , 0Dh,0Ah, "$" above_3 db " es mayor que 3!" , 0Dh,0Ah, "$" Ejercicio 3 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
  • 7. ; 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 ; print result in binary: mov bl, m mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 10000000b ; test first bit. jz zero
  • 8. 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
  • 9. ret ; variables: vector db 9, 8, 7, 6, 5, 4, 5, 2, 1, 0 m db 0 print_al proc cmp al, 0 jne print_al_r push ax mov al, '0' mov ah, 0eh 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
  • 10. add al, 30h mov ah, 0eh int 10h jmp pn_done pn_done: popa ret endp