8085 Assembly Program Help

Discussion in 'Assembly Language Programming (ALP) Forum' started by SephyKid, Jul 24, 2006.

  1. SephyKid

    SephyKid New Member

    Jul 24, 2006
    Likes Received:
    Trophy Points:
    I need help with an old 8085 Assembly Program - the purpose is to take a user input of a number between 0-255 (Does not check for user input error). It takes 8 inputs, and then displays the max, the min, and the average inputs.

    I have the following code so far, but it's only capable of taking a number any amount of digits long, 8 times. It (I believe) finds the max, but won't display it. Any help would be greatly greatly appreciated.

    org 100h
    BDOS equ 5
    boot equ 0
    keyin equ 1
    keyout equ 2
    sprint equ 9
    cr equ 0Dh
    lf equ 0Ah
    lxi sp,sp0
    lxi h,buff
    mvi B,8 ;the B register holds the counter for how many inputs the user has left
    lxi D,mess1 ;these three print the message at mess1, which is the program welcome message
    mvi C,sprint
    call BDOS
    lxi D,mess2 ;this piece prints the message at mess2 then jumps to getnum
    mvi C,sprint
    call BDOS
    jmp getnum
    start: lxi D,mess3 ;these three print the message at mess3, over and over
    mvi C,sprint
    call BDOS
    getnum: mvi c,keyin ;this piece gets user input, and reads a cr as the end of their input
    call BDOS
    cpi cr
    jz mem ;if a cr is found, it jumps to mem
    jnz getnum ;if no cr is found, it continues to take user input
    mem: mov M,A ;the user input is moved into memory
    inx H ;the buffer is increased by 1 for the next bit of user input to be stored into
    dcr B ;the counter is decremented
    mov A,M
    jz pre ;if the counter is 0, then the program moves on to next loop
    jnz start ;if the counter is not 0, the program takes more user input
    pre: dcr h
    mov E,A
    jmp next
    next: mov A,E
    mov E,A
    sub H
    jm hbig
    dcr h
    mov A,E
    jz print
    jp next
    hbig: mov A,H
    mov E,A
    dcr h
    jz print
    jnz next
    print: lxi D,mess5
    mvi c,sprint
    call BDOS
    mov E,A
    mvi C,keyout
    call BDOS
    jmp boot
    ;these next lines, mess1-mess6, are messages seen by the user
    mess1: db lf,cr,'Calculate averages, mins and maxes using this tool!',lf,cr,'$'
    mess2: db lf,cr,'Type in a number between 0-255: $'
    mess3: db lf,cr,'Type in another number between 0-255: $'
    mess4: db lf,cr,'The average number was: $'
    mess5: db lf,cr,'The highest number entered was: $'
    mess6: db lf,cr,'The lowest number entered was: $'
    buff: ds 40
    ds 25
    sp0 equ $
    End code

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice