assembly language program to separate even and odd numbers in 8086
.model small
.data
arr1 db 1,2,3,1,3,5,6,3,4,5
OddArr db 10 dup(?)
EvenArr db 10 dup(?)
OddAdd db 0
EvenAdd db 0
.code
mov ax,@data
mov ds,ax
LEA BX,arr1
LEA SI,OddArr
LEA DI,EvenArr
mov cx,10
mov dh,02
L1:
mov ah,00
mov al,[BX]
mov dl,al
div dh
cmp ah,00
je EVEN1
mov [DI],dl
add OddAdd,dl
INC DI
INC BX
Loop L1
jmp CAL
EVEN1:
mov [SI],dl
add EvenAdd,dl
INC SI
INC BX
Loop L1
CAL:
mov ax,0000
mov bx,0000
mov al,OddAdd
mov bl,EvenAdd
mov ax,4C00h
int 21h
end
4
2
.model small
.data
arr1 db 1,2,3,1,3,5,6,3,4,5
OddArr db 10 dup(?)
EvenArr db 10 dup(?)
OddAdd db 0
EvenAdd db 0
.code
mov ax,@data
mov ds,ax
LEA BX,arr1
LEA SI,OddArr
LEA DI,EvenArr
mov cx,10
mov dh,02
L1:
mov ah,00
mov al,[BX]
mov dl,al
div dh
cmp ah,00
je EVEN1
mov [DI],dl
add OddAdd,dl
INC DI
INC BX
Loop L1
jmp CAL
EVEN1:
mov [SI],dl
add EvenAdd,dl
INC SI
INC BX
Loop L1
CAL:
mov ax,0000
mov bx,0000
mov al,OddAdd
mov bl,EvenAdd
mov ax,4C00h
int 21h
end
Thank you!
2
0
Are there any code examples left?
New code examples in category Assembly
-
Assembly 2022-03-27 17:40:42 create your own macro in assembly language
-
Assembly 2022-03-22 20:55:01 printf format specifiers c
-
Assembly 2022-03-20 06:00:11 how to listen for changes on an ObservableMap
-
Assembly 2022-03-11 19:40:11 vundle vim-javascript
-
Assembly 2022-03-01 07:30:06 restart kde
-
Assembly 2022-02-24 11:00:40 assembly print
-
Assembly 2022-02-16 02:15:03 vim shortcuts keyboard code
-
Assembly 2022-02-12 22:50:25 hello world x64 assembly
-
Assembly 2022-02-02 18:11:11 cout boolalpha