Thread: assembly question

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    38

    assembly question

    plese can you help me in this question

    Given an array of two digits numbers with each digit is stored as a character, do the following:

    a. Write a function FINDMIN that will find the smallest number among a set of numbers.

    b. Write a function FINDMAX that will find the largest number among a set of numbers.

    c. Given the following array X=12,23,14,16, write a program that will use findmax and findmin functions. Remember X is an array of two digits numbers which are stored as characters and not numbers. That is, 12 is stored in two bytes as:32H in the most byte and 31H in the most byte

    i've written the code but my numbers are stored as a byte hex numbers how can it be stored as two bytes?

    this was the code i wrote:

    Code:
    DATA          SEGMENT
    X       db   12,23,14,16
    siz     db   4
    min     db   ?
    max     db   ?
    DATA         ENDS 
    
    CODE         SEGMENT
    ASSUME CS:CODE, DS: DATA
    
    START:
        MOV  AX,DATA ;data seg. initialization
        MOV  DS,AX
        MOV  ES,AX
    
    ;---- Functions Calling ----    
        call  FINDMIN
        call  FINDMAX
        INT  3 
     
    ;----- FINDMAX function --------
     FINDMax      proc          near
         lea  SI,X
         mov  cl,siz
         add  cl,1
    
     GR: mov  al,[SI]
         dec  cl
         cmp  cl,0
         jz   HI
    
    NEXT:inc   SI
         cmp   [SI],al
         jg    GR
         loop  NEXT
     
     HI: mov   max,al
         ret
     FINDMAX        endp 
     
    ;----- FINDMIN function -------- 
     FINDMIN      proc          near
    
         lea  SI,X
         mov  cl,siz
    
    LEE: mov  al,[SI]
         dec  cl
         cmp  cl,0
         jz   LO
    
    NEE: inc   SI
         cmp   [SI],al
         jl    LEE
         loop  NEE
     
     LO: mov   min,al
         ret
     FINDMIN      endp 
    
    CODE    ENDS
    END     START
    Last edited by kuwait; 11-28-2003 at 11:38 AM.
    please set free our POWs

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    For assembly questions, you might want to try here
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    38
    thank you
    please set free our POWs

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    X db "12231416"
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    38
    Thanks for all, I've solved the problem
    please set free our POWs

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assembly question
    By geek@02 in forum Tech Board
    Replies: 8
    Last Post: 08-11-2008, 06:48 AM
  2. Assembly Language Question
    By John_L in forum Tech Board
    Replies: 2
    Last Post: 03-13-2008, 07:44 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. C/C++ vs assembly: speed comparison
    By Just in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2002, 03:33 PM