PDA

View Full Version : assembly question



kuwait
11-28-2003, 06:27 AM
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:



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

Hammer
11-28-2003, 02:56 PM
For assembly questions, you might want to try here (http://www.flashdaddee.com/forums/)

kuwait
11-28-2003, 06:04 PM
thank you

WaltP
11-29-2003, 02:07 AM
X db "12231416"

kuwait
12-01-2003, 07:03 AM
Thanks for all, I've solved the problem:)