Thursday, March 29, 2012

Finding the number of even and odd numbers in a given series in assembly language using 8086



ASSUME  CS:CODE, DS:DATA
DATA    SEGMENT
        ORG 5000H
SERIES  DB 35H,66H,11H,12H,22H,56H,8H,2H,1H,9H
COUNT   DB 0AH
ODDCOUNT DB 00H
EVENCOUNT DB 00H
DATA    ENDS
CODE    SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        LEA SI, SERIES
        MOV CL, COUNT
NEXT:   MOV AX, [SI]
        ROR AX, 01
        JNC EVENV
        INC ODDCOUNT
        JMP OTHER
EVENV:   INC EVENCOUNT
OTHER:  INC SI
        DEC CL
        JNZ NEXT
        MOV AH, 4CH
        INT 21H
CODE    ENDS
        END START


6 comments:

  1. Replies
    1. observe the line before the int 21h
      we are moving 4CH to the AH register and executing the INT 21H.
      INT 21H is the interrupt handler available in the DOS. Its behavior is dependent on the data available in various registers.
      The data available in AH register before executing INT 21H is 4CH.
      4CH indicates terminate the program with code.
      you can get more info at
      https://en.wikipedia.org/wiki/MS-DOS_API

      Delete

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...