0% found this document useful (0 votes)
54 views

Programmation 8086 Sous Programme PDF

This document contains code for two assembly language programs. The first program reads 9 numbers from the user, counts the number of ones and zeros, and displays the results. The second program reads 3 numbers, checks if they can form the sides of a triangle, and displays a success message if they can. Both programs demonstrate reading input, performing calculations, and displaying output using 8086 assembly language.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Programmation 8086 Sous Programme PDF

This document contains code for two assembly language programs. The first program reads 9 numbers from the user, counts the number of ones and zeros, and displays the results. The second program reads 3 numbers, checks if they can form the sides of a triangle, and displays a success message if they can. Both programs demonstrate reading input, performing calculations, and displaying output using 8086 assembly language.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Programmation 8086 sous programme

Exercice 3:

; multi-segment executable file template.

data segment
entry_msg db "Enter 9 numbers $"
numbers_array db 9 dup (?)
ones db ?
zeros db ?
one_msg db 10, 13, "Number of ones is: $"
zero_msg db 10, 13, "Number of zeros is: $"

ends

stack segment
dw 128 dup(0)
ends

code segment
read proc
mov ah, 09h
mov dl, offset entry_msg
int 21h

mov cx, 8
boucle_read:
mov ah, 01h
int 21h
sub al, 030h
mov [si], al
inc si
mov ah, 02h
mov dl, ','
int 21h
loop boucle_read
ret
read endp

countOnesAndZeros proc
mov dl, 0
mov bl, 0
mov cx, 8
boucle_countOnesAndZeros:
mov al, [si]
cmp al, 0
je zero_found
cmp al, 1
je one_found
back:
inc si
loop boucle_countOnesAndZeros
jmp exit_countOnesAndZeros

zero_found:
add bl, 1
jmp back

one_found:
add dl, 1
jmp back

exit_countOnesAndZeros:
mov ones, dl
mov zeros, bl
mov ah, 09h
mov dl, offset one_msg
int 21h
mov ah, 02h
mov dl, ones
add dl, 030h
int 21h
mov ah, 09h
mov dl, offset zero_msg
int 21h
mov ah, 02h
mov dl, zeros
add dl, 030h
int 21h
ret
countOnesAndZeros endp
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax

mov si, offset numbers_array


call read
mov si, offset numbers_array
call countOnesAndZeros

mov ax, 4c00h ; exit to operating system.


int 21h
ends

end start ; set entry point and stop the assembler.


Exercice 4:

; multi-segment executable file template.

data segment
entry_msg db "Enter 3 numbers: $"
tab db 3 dup (?)
success_msg db 10, 13, "The 3 sizes can form a triangle $"

ends

stack segment
dw 128 dup(0)
ends

code segment
read proc
mov ah, 09h
mov dl, offset entry_msg
int 21h
mov cx, 3
boucle:
mov ah, 01h
int 21h
sub al, 030h
mov [si], al
mov ah, 02h
mov dl, ','
int 21h
inc si
loop boucle
ret
read endp
condition_triangle proc
mov al, [si]
mov bl, [si+1]
mov cl, [si+2]

mov dl, bl
add dl, cl
cmp al, dl
ja exit
mov dl, al
add dl, bl
cmp cl, dl
ja exit
mov dl, al
add dl, cl
cmp bl, dl
ja exit
mov ah, 09h
mov dl, offset success_msg
int 21h

exit:
ret
condition_triangle endp
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax

mov si, offset tab


call read
mov si, offset tab
call condition_triangle
mov ax, 4c00h ; exit to operating system.
int 21h
ends

end start ; set entry point and stop the assembler.

You might also like