EJERCICIOS EMU8086 LENGUAJE ENSAMBLADOR

EJERCICIOS: 

  • IMPRIME UNA CADENA
  • GENERE LA SIGUIENTE  SERIE  2,5,2,8,2,11,2,14,... 
  • GENERE LA SIGUIENTE  SERIEN 2,5,2,8,2,11,2,14
  • GENERE LA SIGUIENTE  ; SERIE 2, 5, 4, 8, 6, 11, 8, 14, 10, 17,...  
  • GENERE LA SIGUIENTE ; SERIE 1, 2, 3, 5, 5, 8, 7, 11, 9, 14,…
  • GENERE LA SIGUIENTE  SERIE 1, 2, 1, 5, 1, 8, 1, 11, 1, 14,…
  • GENERE LA SIGUIENTE  SERIE 0, 1, 2, 4, 4, 7, 6, 10, 8, 13 ...
  • FIBONACCI  NÚMEROS (0-999) (LEIDA de N POR TECLADO) 
  • DADO UN N NUMERO EN (DECIMALIMPRIMIR SU VALOR EN (BINARIO). 
  • GENERAR LOS N MULTIPLOS DE 5 (0-999)
  • Realice un programa que imprima su nombre n veces; donde 𝑛=𝑇𝑢 𝑒𝑑𝑎𝑑 ⁄ 2



SOLUCIONES:
  • IMPRIME UNA CADENA

data segment  
MENSAJE db "HOLA MUNDO$" ; TODA CADENA SE TERMINARA EN "escribe_tu_cadena..$"
ends
stack segment
    dw   128  dup(0)
ends
code segment
start:
    mov ax, data
    mov ds, ax
    mov es, ax
                      ; DX ES UN REGISTRO DE 16 BITS
  ;......................................            
    lea dx, MENSAJE  ;INSTRUCCION EN LA QUE EN DX ALMACENAMOS LA CADENA [MENSAJE]
    mov ah, 9        ;INSTRUCCION QUE IMPRIME LA CADENA
    int 21h          ;INTERRUPCION 21H       
  ;---------------------------------------    
    mov ax, 4c00h ; exit 
    int 21h    
ends
end start ;


  • GENERE LA SIGUIENTE SERIE: 2,5,2,8,2,11,2,14,...
;leida N desde teclado
; serien 2,5,2,8,2,11,2,14
SALTO_LINEA MACRO
        PUSH AX
        PUSH DX
        mov dl, 0dh
        mov ah, 02h
        int 21h
        ; salto de linea
        mov dl, 0ah
        mov ah, 02h
        int 21h
        POP DX
        POP AX

ENDM
espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    NN db 0 ;tamno n
    dig db 0
    aa db 0 ;unidad
    bb db 0 ;decena 
    impares db 02h
    espacio db " $"
    men1 db "INGRESE N = $"
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
    MOSTRAR_CADENA men1
    ;LEEMOS N-------------------------------------------------------
    bucle:
      call LEER ; en dig esta el numero ascii
      cmp dig,0Dh
      je salir2
      sub dig, 30h
      mov al,1010b
      mul NN
      add al,dig
      mov NN,al  ; en NN esta el numero fromado
    jmp bucle
    salir2:
    ;-------------------------------------------------------
    SALTO_LINEA
   
    add NN,01h ;le sumamos una unidad al numero
    mov cl,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp cl,NN ; n=3 -- i<n
        jge endfori
     
        mov ch,00h; di es 'j' ->j=0
        forj:
            cmp ch,cl  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                   
                    MOSTRAR_NUMERO 02h
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                    add impares,03h
                    imprimirNnum impares,aa,bb
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
            
           
            ;-------------------------------------------------------
            
            inc ch   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc cl
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;------------------------------********************----------------
    LEER:
      mov ah, 01h
      int 21h
      mov dig,al
    ret 

     
   
ends

end start ; set entry point and stop the assembler.

  • GENERE LA SIGUIENTE SERIEN 2,5,2,8,2,11,2,14
; serien 2,5,2,8,2,11,2,14
espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    n dw 05h ;tamno n
    aa db 0 ;unidad
    bb db 0 ;decena 
    impares db 02h
    espacio db " $"
    men1 db "N=5 $"
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
  
    MOSTRAR_CADENA men1
    add n,01h ;le sumamos una unidad al numero
    mov si,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp si,n ; n=3 -- i<n
        jge endfori
     
        mov di,00h; di es 'j' ->j=0
        forj:
            cmp di,si  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                   
                    MOSTRAR_NUMERO 02h
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                    add impares,03h
                    imprimirNnum impares,aa,bb
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
           
           
            ;-------------------------------------------------------
            
            inc di   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc si
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;exit
   
   
ends

end start ; set entry point and stop the assembler.


  • GENERE LA SIGUIENTE ; SERIE 2, 5, 4, 8, 6, 11, 8, 14, 10, 17,...


; SERIE 2, 5, 4, 8, 6, 11, 8, 14, 10, 17,... 

espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    n dw 05h ;tamno n
    aa db 0 ;unidad
    bb db 0 ;decena 
    impares db 02h
    espacio db " $"
    men1 db "N=5 $"
    pares db 00h
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
  
    MOSTRAR_CADENA men1
    add n,01h ;le sumamos una unidad al numero
    mov si,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp si,n ; n=3 -- i<n
        jge endfori
     
        mov di,00h; di es 'j' ->j=0
        forj:
            cmp di,si  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                    add pares,02h
                    imprimirNnum pares,aa,bb
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                    add impares,03h
                    imprimirNnum impares,aa,bb
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
           
           
            ;-------------------------------------------------------
            
            inc di   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc si
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;exit
   
   
ends

end start ; set entry point and stop the assembler.
  • GENERE LA SIGUIENTE ; SERIE 1, 2, 3, 5, 5, 8, 7, 11, 9, 14,…
; SERIE 1, 2, 3, 5, 5, 8, 7, 11, 9, 14

espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    n dw 05h ;tamno n
    aa db 0 ;unidad
    bb db 0 ;decena 
    impares3 db 02h
    espacio db " $"
    men1 db "N=5 $"
    impares2 db 01h
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
  
    MOSTRAR_CADENA men1
    add n,01h ;le sumamos una unidad al numero
    mov si,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp si,n ; n=3 -- i<n
        jge endfori
     
        mov di,00h; di es 'j' ->j=0
        forj:
            cmp di,si  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                    
                    imprimirNnum impares2,aa,bb
                    add impares2,02h
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                    
                    imprimirNnum impares3,aa,bb
                    add impares3,03h
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
           
           
            ;-------------------------------------------------------
            
            inc di   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc si
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;exit
   
   
ends

end start ; set entry point and stop the assembler.


  • GENERE LA SIGUIENTE SERIE 1, 2, 1, 5, 1, 8, 1, 11, 1, 14,…


; SERIE 1, 2, 1, 5, 1, 8, 1, 11, 1, 14,…

espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    n dw 05h ;tamno n
    aa db 0 ;unidad
    bb db 0 ;decena 
    impares3 db 02h
    espacio db " $"
    men1 db "N=5 $"
  
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
  
    MOSTRAR_CADENA men1
    add n,01h ;le sumamos una unidad al numero
    mov si,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp si,n ; n=3 -- i<n
        jge endfori
     
        mov di,00h; di es 'j' ->j=0
        forj:
            cmp di,si  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                    MOSTRAR_NUMERO 01h
                   
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                   
                    imprimirNnum impares3,aa,bb
                    add impares3,03h
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
           
           
            ;-------------------------------------------------------
             
            inc di   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc si
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;exit
   
   
ends

end start ; set entry point and stop the assembler.


  • GENERE LA SIGUIENTE SERIE 0, 1, 2, 4, 4, 7, 6, 10, 8, 13 ...


; SERIE 0, 1, 2, 4, 4, 7, 6, 10, 8, 13 ...


espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

MOSTRAR_NUMERO MACRO num
    PUSH AX
    PUSH DX
    mov dl,num
    add dl,30h
    mov ah,02h
    int 21h
    POP DX
    POP AX 
    
ENDM
imprimirNnum MACRO numm,uni,dece
        push ax
        push dx
        mov al,numm
        aam
        mov uni,al
        mov dece,ah
        ;Imprimos los tres valores empezando por decenas y unidades.
        mov ah,02h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        ;Termina programa
        pop dx
        pop ax
ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM



data segment
    sw db 00h
    n dw 05h ;tamno n
    aa db 0 ;unidad
    bb db 0 ;decena 
    pares db 00h
    espacio db " $"
    men1 db "N=5 $"
    pares2 db 01h
  
   

ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
   
  
    MOSTRAR_CADENA men1
    add n,01h ;le sumamos una unidad al numero
    mov si,00h   ; si es i=0 -- i<n=3
      
   
    fori:
        cmp si,n ; n=3 -- i<n
        jge endfori
     
        mov di,00h; di es 'j' ->j=0
        forj:
            cmp di,si  ;m=3   -- j<m
            jge endforj
            ;-------------------------------------------------------
                cmp sw,00h
                je sw0
                jne sw1
                  sw0:
                   
                    imprimirNnum pares,aa,bb
                    add pares,02h
                    mov sw,01h
                    espacioElineas espacio
                    jmp salir
                  sw1:
                   
                   
                    imprimirNnum pares2,aa,bb
                    add pares2,03h
                    espacioElineas espacio
                    mov sw,00h
                   
                  salir:
           
           
            ;-------------------------------------------------------
             
            inc di   ;j++
        jmp forj
          
           endforj:;por falso si ponemos esto fuera de exit
                   ; se repetira innitamente
           inc si
    jmp fori
    endfori:;por falso si ponemos esto fuera de exit
            ; se repetira innitamente
   
    ;exit
    mov ax, 4c00h ; exit to operating system.
    int 21h
    ;exit
   
   
ends

end start ; set entry point and stop the assembler.

  • FIBONACCI N= (0-9) Y MUESTRA LA SERIO CON NÚMEROS (0-999) (LEIDA de N POR TECLADO)



SALTO_LINEA MACRO
        PUSH AX
        PUSH DX
        mov dl, 0dh
        mov ah, 02h
        int 21h
        ; salto de linea
        mov dl, 0ah
        mov ah, 02h
        int 21h
        POP DX
        POP AX

ENDM
MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX 
ENDM
espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM  
imprimirNUM MACRO numm,uni,dece,cen
   
        push ax
        push dx      
        mov al,numm ; en F<-bl
        aam ;ajusta el valor en AL por: AH=23 Y AL=4
        mov uni,al ; Respaldo 4 en unidades
        mov al,ah ;muevo lo que tengo en AH a AL para poder volver a separar los números
        aam ; separa lo qe hay en AL por: AH=2 Y AL=3
        mov cen,ah ;respaldo las centenas en cen en este caso 2
        mov dece,al ;respaldo las decenas en dec, en este caso 3
        ;Imprimos los tres valores empezando por centenas, decenas y unidades.
        mov ah,02h
        mov dl,cen
        add dl,30h
        int 21h
        mov dl,dece
        add dl,30h
        int 21h
        mov dl,uni
        add dl,30h
        int 21h
        pop ax
        pop dx
ENDM
data segment
   NN db 0 ;tamno n
   men1 db "Digite N = $"
   aa db 0
   bb db 0
   cc db 0
   dig db 0
   espacio db " $"
  
   F db 1h
   aux db -1h
   a db 1h
   fibo db 0
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:

    mov ax, data
    mov ds, ax
    mov es, ax
   
    MOSTRAR_CADENA men1    
    ;LEEMOS N-------------------------------------------------------
    bucle:
      call LEER ; en dig esta el numero ascii
      cmp dig,0Dh
      je salir2
      sub dig, 30h
      mov al,1010b
      mul NN
      add al,dig
      mov NN,al  ; en NN esta el numero fromado
    jmp bucle
    salir2:
    ;-------------------------------------------------------
                
    SALTO_LINEA
      
     
      mov bl,F    ;bl<-F
      mov bh,a    ;bh<-a 
     
      mov cl,01h; cl iniciamos en 1
      while:
            cmp cl,NN     ;comparamos cl<=N
            jg finWhile ; si es salimos
            ;-----------------------------------------------
              ;Suma F= aux + a
               mov bl,aux
               add bl,bh
               ;mostramos
               mov fibo,bl
               imprimirNUM fibo,aa,bb,cc
               espacioElineas espacio
               ;Intercambio aux<-a & a<-F
               mov [aux],bh
               mov bh,bl
                  
            ;-----------------------------------------------                   
            inc cl   ;incremento de cl++
        
       jmp while  
       finWhile:

             
    mov ax, 4c00h
    int 21h
   
    LEER:
      mov ah, 01h
      int 21h
      mov dig,al
    ret
         
ends
end start
  • DADO UN N NUMERO EN (DECIMAL) IMPRIMIR SU VALOR EN (BINARIO).
   ;Dado un N numero en DECIMAL imprimir su valor en BINARIO.

data segment
  
      NN db 0
   dig db 0
   aux db 0

  
  
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax

    bucle:
      call leer3 ; en dig esta el numero ascii
      cmp dig,0Dh
      je salir
      sub dig, 30h
      mov al,1010b
      mul NN
     
      add al,dig
      mov NN,al
   
      jmp bucle
        
    mov ax, 4c00h ; exit to operating system.
    int 21h
   
    ;PROCESOS
       
    salir:
       call mostrar3
       mov ax, 4c00h
       int 21h
    ret
   
    mostrar3:
      mov cx,08h
      bucle2:
        rol nn,01h
        adc aux,00h
       
        mov dl, aux
        add dl,30h
        mov ah,02h
        int 21h
        mov aux,00h
        loop bucle2
    ret
       
    leer3:
      mov ah, 01h
      int 21h
      mov dig,al
    ret 

   
   
ends

end start ; set entry point and stop the assembler.


  • GENERAR LOS N MULTIPLOS DE 5 (0-999)


; generar los N multiplos de 5

espacioElineas MACRO cad2
        push ax
        push dx
        lea dx,cad2
        mov ah,09h
        int 21h
        pop dx
        pop ax   
ENDM

numN MACRO cadena
   
    push ax
    push dx
    lea dx,cadena
    mov ah,09
    int 21h
    pop dx
    pop ax
   
ENDM

multiplosDcinco MACRO n,S,caden,aa,bb,cc
    push ax
    push cx
       
    mov 00h,ax
    mov 01h,si
    
   
    mov cx,01h; cx iniciamos en 1 
   
                        
   while:
        cmp cx,n     ;comparamos cx<=N
        jg finWhile ; si es salimos
            ;-------------------------------------------------------
               espacioElineas caden 
              
               add S,05h
               imprimirNnum S,aa,bb,cc
             
              
             
               
            ;--------------------------------------------------------
        inc cx   ;incremento de cx++
    
   jmp while  
  
   finWhile:
   pop cx
   pop ax
ENDM

imprimirNnum MACRO numm,uni,dece,cen
        push ax
        push dx      
       
        mov al,numm ; num
        aam
       
        mov uni,al
        mov al,ah
       
        aam
        mov cen,ah
       
        mov dece,al
       
       
        ;Imprimos los tres valores empezando por centenas, decenas y unidades.
       
        mov ah,02h
       
        mov dl,cen
        add dl,30h ; se suma 30h a dl para imprimir el numero real.
        int 21h
       
        mov dl,dece
        add dl,30h
        int 21h
       
        mov dl,uni
        add dl,30h
        int 21h
       
        ;Termina programa

        pop dx
        pop ax
ENDM


data segment
      
      men1 db " N=15   $"
      men2 db " $" 
      nn dw 0fh
      aa db 0
      bb db 0
      cc db 0
      S db 0
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax

    numN men1
    multiplosDcinco nn,S,men2,aa,bb,cc
    mov ax, 4c00h ; exit to operating system.
    int 21h   
ends

end start ; set entry point and stop the assembler.

  • Realice un programa que imprima su nombre n veces; donde 𝑛=𝑇𝑢 𝑒𝑑𝑎𝑑 ⁄ 2


data segment
   N DB 14h
   nom db "JOSE ALFONSO RIVERA LIMA $"
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
    ;DIVISION-----------------------------------------------
    xor ax,ax ;limpiamos el registro ax.
    mov bl,02h ; 2
    mov al,N  ;el N
    div bl    ; divide AX/BX el resultado lo almacena en AX, el residuo queda en DX
  
    mov N,al  ; en AL esta el resultado de N/2 
    ;--------------------------------------------------
    mov cl,N
    mov ch,00h 
    bucle:
            lea dx,nom
            mov ah,09h
            int 21h

   
        cmp cx,00h
        sub cx,01h
    jnz bucle

   
    mov ax, 4c00h ; exit to operating system.
    int 21h   
ends

end start ; set entry point and stop the assembler.













Comentarios

  1. en el fibonacci da un numero antes del q es
    y hay un error cuando llega al numero 14...
    con respecto a los numeros les dejo bien orden aqui

    SALTO_LINEA MACRO
    PUSH AX
    PUSH DX
    mov dl, 0dh
    mov ah, 02h
    int 21h
    ; salto de linea
    mov dl, 0ah
    mov ah, 02h
    int 21h
    POP DX
    POP AX

    ENDM
    MOSTRAR_CADENA MACRO cad
    PUSH AX
    PUSH DX
    LEA DX,cad
    MOV AH,09H
    INT 21H
    POP DX
    POP AX
    ENDM
    espacioElineas MACRO cad2
    push ax
    push dx
    lea dx,cad2
    mov ah,09h
    int 21h
    pop dx
    pop ax
    ENDM
    imprimirNUM MACRO numm,uni,dece,cen

    push ax
    push dx
    mov al,numm ; en F<-bl
    aam ;ajusta el valor en AL por: AH=23 Y AL=4
    mov uni,al ; Respaldo 4 en unidades
    mov al,ah ;muevo lo que tengo en AH a AL para poder volver a separar los números
    aam ; separa lo qe hay en AL por: AH=2 Y AL=3
    mov cen,ah ;respaldo las centenas en cen en este caso 2
    mov dece,al ;respaldo las decenas en dec, en este caso 3
    ;Imprimos los tres valores empezando por centenas, decenas y unidades.
    mov ah,02h
    mov dl,cen
    add dl,30h
    int 21h
    mov dl,dece
    add dl,30h
    int 21h
    mov dl,uni
    add dl,30h
    int 21h
    pop ax
    pop dx
    ENDM
    data segment
    NN db 0 ;tamno n
    men1 db "Digite N = $"
    aa db 0
    bb db 0
    cc db 0
    dig db 0
    espacio db " $"

    F db 1h
    aux db -1h
    a db 1h
    fibo db 0
    ends

    stack segment
    dw 128 dup(0)
    ends

    code segment
    start:

    mov ax, data
    mov ds, ax
    mov es, ax

    MOSTRAR_CADENA men1
    ;LEEMOS N-------------------------------------------------------
    bucle:
    call LEER ; en dig esta el numero ascii
    cmp dig,0Dh
    je salir2
    sub dig, 30h
    mov al,1010b
    mul NN
    add al,dig
    mov NN,al ; en NN esta el numero formado
    jmp bucle
    salir2:
    ;-------------------------------------------------------

    SALTO_LINEA


    mov bl,F ;bl<-F
    mov bh,a ;bh<-a

    mov cl,0h; cl iniciamos en 0
    while:
    cmp cl,NN ;comparamos cl<=N
    jg finWhile ; si es salimos
    ;-----------------------------------------------
    ;Suma F= aux + a
    mov bl,aux
    add bl,bh
    ;mostramos
    mov fibo,bl
    imprimirNUM fibo,aa,bb,cc
    espacioElineas espacio
    ;Intercambio aux<-a & a<-F
    mov [aux],bh
    mov bh,bl

    ;-----------------------------------------------
    inc cl ;incremento de cl++

    jmp while
    finWhile:


    mov ax, 4c00h
    int 21h

    LEER:
    mov ah, 01h
    int 21h
    mov dig,al
    ret

    ends
    end start

    ResponderEliminar
  2. How to make money from betting - Work Tomakemoney
    How to make money from betting. - This article outlines 1xbet how to make money from betting. The idea is 인카지노 simple – the process งานออนไลน์ is to bet

    ResponderEliminar

Publicar un comentario

Entradas populares de este blog

Eliminar error 6000 en impresora Canon PIXMA MG2410 y MG2500 y MG2510