Saturday 11 January 2014

Binary search

        MOV SI,3006
repeat: MOV AX,@3000
        MOV BX,@3002
        CMP AX,BX
        JG terminate:
        MOV DX,0
       ADD AX,BX
       MOV BX,2
       DIV BX
       MOV BX,@3004
       MOV CX,AX
      DEC CX
here:       ADD SI,2
      LOOP here:
      CMP BX,[SI]
     JG incrmid:
     JL decrmid:
     MOV DX,1
     JMP end:
incrmid: INC AX
     MOV @3000,AX
     JMP repeat:
decrmid: DEC AX
     MOV @3002,AX
     JMP repeat:
terminate:MOV DX,0
end :     INT 03

No comments:

Post a Comment