locked
what is wrong with my assembly code ?????? RRS feed

  • Question

  • what is wrong with my assembly code ??????

    org 100h

    mov cx,5 ; number of byte to input
    mov dl,0 ;intializing count
    first : mov ah,1 ;function for inputing values
    int 21h
    aaa ;adjusting ASCII
    cmp cx,5
    jz one ;save 1st value
    cmp cx,4
    jz two ;save 2nd value
    cmp cx,3
    jz three ;save 3rd value
    cmp cx,2 ;save 4th value
    jz four 
    cmp cx,1
    jz five ;save fifth value
    second : mov [1500],al ;save input at [ds:1500]
    cmp al ,1 
    jz prime ;"1" is a prime number 
    mov dh,al ;save al in dh
    step_2: mov al,dh
    mov ah,0 ;re-initializing input
    mov dh ,al
    dec [1500] ;"input-1"
    div [1500]
    mov bx ,[1500]
    cmp bx,2
    jz prime ;number is prime 
    jnz step_2
    last : mov ah ,2 ;display number of prime inputs
    int 21h
    hlt 
    one: mov [100] ,al ;save inputs in array starting [ds:100 ]
    jmp second 
    two :mov [101],al
    jmp second
    three :mov [102] ,al
    jmp second
    four :mov [103] , al
    jmp second 
    five :mov [104] ,al 
    jmp second 
    prime :inc dl
    not_prime : loop first 
    jmp last
    ret

    Additional Details

    objective of it is to :
    take 5 bytes as input from keyboard and save them in an array inside memory ,count the number of prime items and display their count on screen .
    when excuting im receiving a dialog box saying "PROGRAM HAS RETURNED CONTROL
    TO THE OPERATING SYSTEM" ... & then after i press "OK" button ... it says : "PROGRAM TERMINATED .RELOAD " 
    ***the dialog box appears when excution arrives the "jmp second" instruction ... :S
    • Moved by Max Meng Monday, December 24, 2012 9:04 AM (From:Visio General Questions and Answers for IT Professionals)
    Sunday, December 23, 2012 9:32 PM

Answers

All replies