1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

Max & Min Value in Memory Segment

Discussion in 'Microcontrollers' started by ahmadbakro, Jun 21, 2011.

  1. ahmadbakro

    ahmadbakro New Member

    Likes Received:
    0
    Trophy Points:
    1
    Hi..
    I hope this is the right place to post in.
    I have to write a program in assembly that searches for the largest and smallest values in a memory segment in one scan.
    The length of the segment is stored in : 20H
    The address of the first room of segment is stored in : 21H
    Then store Maximum Value in R6 and Minimum Value in R7.

    So far I all I came up with is the following code, but it doesn't seem to be working at all
    Any help is appreciated and thanks in advance >>>

    ;;; Random Test Values
    mov 20h,#32
    mov 21h,#24
    mov 22h,#56
    mov 23h,#38
    mov 24h,#30
    mov 25h,#62
    mov 26h,#24
    mov 27h,#36
    mov 28h,#78
    mov 29h,#10
    mov 2ah,#20

    MOV R5,#10
    MOV A,20H
    MOV R0,#21H
    MOV 01H,@R0
    CJNE A,01H,next
    next:JC AisSmaller
    MOV R6,A
    MOV A,@R0
    MOV R7,A
    SJMP agAIN
    AisSmaller:MOV R7,A
    MOV A,@R0
    MOV R6,A
    again:INC R0
    MOV A,@R0
    CJNE A,06H,new_min
    SJMP redo
    new_min:JC NEXP
    NEXP:CJNE A,07H,new_BIG
    SJMP redo
    new_BIG:JC again
    MOV R6,A
    redo: DJNZ R5,again

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    I however managed to write a program that can find the SMALLEST value ONLY

    ;;;;;;;;; Random Test Values
    MOV 21H,#7
    MOV 22H,#12
    MOV 23H,#5
    MOV 24H,#17
    MOV 25H,#2
    MOV 26H,#4
    MOV 27H,#1
    MOV 28H,#30
    MOV 29H,#10
    ;;;;;;;;;;;;;;;;;;;
    MOV R2,21H
    MOV R3,22H
    MOV R0,#22H

    repeat:INC R0
    MOV A,@R0
    CJNE A,03,NotEqual
    NotEqual:JNC cont
    MOV R3,A
    CONT: DJNZ R2,repeat
    MOV A,R3
    MOV R7,A
  2. ahmadbakro

    ahmadbakro New Member

    Likes Received:
    0
    Trophy Points:
    1
    Hellllllllllooooooooooooooo

    Is there any body here???

    Thanks
Loading...
: 8051, assembly

Share This Page