Write an assembly language program for finding out alleven numbers among 10 eight bit numbers
Question
Write an assembly language program for finding out all even numbers among 10 eight bit numbers
Solution
Here is a simple assembly language program that finds out all even numbers among 10 eight bit numbers. This program assumes that the numbers are stored in memory locations starting from the address 2000H.
ORG 2000H ; starting address of the numbers
DB 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 ; the numbers
ORG 3000H ; starting address of the program
MOV SI, 2000H ; load the starting address of the numbers into SI
MOV CX, 10 ; load the count of numbers into CX
NEXT_NUMBER:
MOV AL, [SI] ; load the current number into AL
AND AL, 01H ; AND the number with 01H to check if it's even
JNZ NEXT ; if the number is not even, jump to the next number
; if the number is even, print it (for simplicity, we'll just assume a print routine at address 4000H)
PUSH AX ; save AX
PUSH BX ; save BX
PUSH CX ; save CX
PUSH DX ; save DX
CALL 4000H ; call the print routine
POP DX ; restore DX
POP CX ; restore CX
POP BX ; restore BX
POP AX ; restore AX
NEXT:
INC SI ; increment SI to point to the next number
LOOP NEXT_NUMBER ; decrement CX and loop if CX is not zero
HLT ; halt the program
This program uses the AND instruction to check if the least significant bit of the number is 0, which means the number is even. If the number is not even, it jumps to the next number. If the number is even, it calls a print routine to print the number, and then jumps to the next number. The LOOP instruction is used to repeat the process for all 10 numbers.
Similar Questions
Write an assembly language program for finding out alleven numbers among 10 eight bit numbers
__________ converts the programs written in assembly language into machine instructions
write a program that performs bitwise AND between 7 and the number given by Alice and prints the result.
What is the largest integer number that a PLC counter function can reach if it uses a 16 bit register?
Write a TCL program to get the numbers in the range (given in arguments) which are only divisible by 3 and 7.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.