ejercicios del emsamblador 8086

Download ejercicios del emsamblador 8086

If you can't read please download the document

Upload: javier-sandoval

Post on 23-Dec-2015

15 views

Category:

Documents


1 download

DESCRIPTION

ejercicios y ejemplor del lengiaje a bajo nivel -8086

TRANSCRIPT

;;;;; imprime una cadena (impcad)codigo segment assume cs:codigo, ds:datosentrada: mov ax, datos mov ds,ax mov dx, offset texto mov ah, 09h int 21h mov ah,4ch int 21hcodigo endsdatos segmenttexto db "esta cadena ha sido", 0ah, 0dh db "definida en un segmento de datos $"datos ends end entrada;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; imprime una cadena (men4)CODIGO2 SEGMENT ASSUME CS:CODIGO2, DS:CODIGO2ENTRADA2: MOV AX,CS MOV DS,AX MOV DX, OFFSET TEXTO2 MOV AH,09H INT 21H MOV AH,4CH INT 21HTEXTO2 DB "IMPRIME CADENA, VERSION 2 ", 0AH,0DH,"$"CODIGO2 ENDS END ENTRADA2;;;;;;;;;;;;;;;;;;;;;;;;;;; compara dos cadenas ingresadas x tecladodatos segment texto db "Ingrese cadena: $"noigual db "cadenas no son iguales $" siigual db "cadenas son iguales $" buf db 40 dup (?) buf1 db 40 dup (?)datos endscod segmentassume cs:cod , ds:datosini: mov ax,datos mov ds,axmov dx, offset textomov ah,09hint 21h mov ah,0ah mov dx,offset buf mov bx,dx mov byte ptr [bx],0fh int 21hmov cl,byte ptr [bx+1]mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dx, offset textomov ah,09hint 21h mov ah,0ah mov dx,offset buf1 mov si,dx mov byte ptr [si],0fh int 21h;mov al,byte ptr [si+1]cmp byte ptr [si+1],cljne no_igualadd bx,2add si,2repetir:; mov al,byte ptr[bx]mov dl,byte ptr[si]cmp byte ptr[bx],dljne no_igualinc siinc bxcmp buf1[si],0dhje igualjmp repetirigual:mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dx, offset siigualmov ah,09hint 21hjmp finno_igual:mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dx, offset noigualmov ah,09hint 21hfin: mov ah,4chint 21hcod ends end ini;;;;;;;;;;;;;;;;;;;; cuenta la cantidad de palabras datos segment texto db " Ingrese cadena: $" texto1 db " La cantidad de palabras en la cadenas son: $"buf db 180 dup (?)datos endscod segmentassume cs:cod , ds:datosini: mov ax,datos mov ds,axmov dx, offset textomov ah,09hint 21h mov ah,0ah mov dx,offset buf mov si,dx mov byte ptr [si],20h;32 int 21hmov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov cx,1add si,2bucle: mov al,byte ptr[si]inc sicmp buf[si],0dhje fincmp al,20hjne bucleinc cxjmp buclefin:mov dx, offset texto1mov ah,09hint 21hadd cx,48mov dl,clmov ah,2hint 21hmov ah,4chint 21hcod ends end ini;;;;;;;;;;;;;;;;;;;;;;compara con el 1,datos segment texto db "Ingrese numero de un digito comparado con 1: $" buf db 4 dup (?)datos endscod segmentassume cs:cod , ds:datosini: mov ax,datos mov ds,axmov dx, offset textomov ah,09hint 21h mov ah,0ah mov dx,offset buf mov si,dx mov byte ptr [si],2 int 21hmov ch,0 ;sub ch,chmov cl,[si+2]sub cl,"0"cmp cx,1jb menorja mayorje igual menor: mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dl,3chmov ah,2hint 21hmayor: mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dl,3ehmov ah,2hint 21hjmp finigual: mov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov dl,3dhmov ah,2hint 21hjmp finfin: mov ah,4chint 21hcod ends end ini;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;emite un mensaje ya definido en ; el segmento de datos (mensaje)datos segmenttexto db "esta cadena ha sido",0ah,0dh db "definida en un segmento d datos$"datos endscod segmentassume cs:cod , ds:datosini: mov ax,datosmov ds,axmov dx, offset textomov ah,09hint 21hmov ah,4chint 21hcod ends end ini;;;;;;;;;;;;;;;;;;;;;;;;;;;;; compara dos numeros ya definidoscodigo segmentassume cs:codigoinicio: mov ax,5mov bx,3cmp ax,bxje igualja mayorje igualjb menormayor: mov dl,3ehmov ah,2hint 21hjmp finigual: mov dl,3dhmov ah,2hint 21hjmp finmenor: mov dl,3chmov ah,2hint 21hfin: mov ah,4chint 21hcodigo ends end inicio ;;;;;;;;;;;;;;;;;;;;;;;; imprimir del 0-9 linea por linea(numeros)codigo segmentassume cs:codigoinicio: mov dl,30hmov ah,2hotra_vez: int 21hmov bl,dlmov dl,0ahint 21hmov dl,0dhint 21hmov dl,blcmp dl,39hje fininc dl jmp otra_vezfin: mov ah,4chint 21hcodigo ends end inicio ;;;;; ingresar un numero; y saber si es primo o no (primox)datos segmenttexto db "Ingrese numero: $"buf db 40 dup (?)num dw 0mensaje1 db "es primo",0ah,0dh,"$"mensaje2 db "no es primo",0ah,0dh,"$"datos endsprograma segment assume cs:programa, ds:datoscomienzo: mov ax,datos mov ds,axmov dx, offset textomov ah,09hint 21hmov ah,0ahmov dx,offset buf mov si,dx mov byte ptr [si],5 int 21hmov ah,02hmov dl,0ahint 21hmov dl,0dhint 21hmov cl,48mov ax,0mov dl,10mov bx,0add si,2bucle: mov al,byte ptr[si]sub al,cl; add bx,axinc sicmp byte ptr[si],0dhje finbmul dlmov bx,axmov ax,0jmp buclefinb: add bx,axmov ax,bx mov num,axmov bx,02hsiguiente: cmp bx,num je primo mov dx,0h mov ax,num div bx cmp dx,0h je no_primo inc bx jmp siguienteprimo: mov dx, offset mensaje1 mov ah,09h int 21h jmp finno_primo: mov dx,offset mensaje2 mov ah,09h int 21hfin: mov ah, 4ch int 21hprograma ends end comienzo;;imprimr letras de la a-f;prog2codigo segmentassume cs:codigoinicio: mov dl,41hmov ah,2hotra_vez: int 21hcmp dl,46hje fininc dljmp otra_vezfin: mov ah,4chint 21hcodigo ends end inicio ;;imprimir de a-g ;linea x linea (prog23)codigo segmentassume cs:codigoinicio: mov dl,41hmov ah,2hotra_vez: int 21hmov bl,dlmov dl,0ahint 21hmov dl,0dhint 21hmov dl,blcmp dl,47hje fininc dljmp otra_vezfin: mov ah,4chint 21hcodigo ends end inicio ;; raiz cuadrada de un ; numero ya definido (raiz)datos segment num dw 9raiz dw 0datos endsprograma segment assume cs:programa, ds:datoscomienzo: mov ax,datos mov ds,axsig: inc raizmov ax,raizmul axcmp ax,numjbe sigdec raizmov ax,raizadd al,30hmov dl,almov ah,2hint 21hfin: mov ah, 4ch int 21hprograma ends end comienzo