Current location: Hot Scripts Forums » Programming Languages » Other Languages » Please help with assembly language!


Please help with assembly language!

Reply
  #1 (permalink)  
Old 11-19-08, 08:21 PM
Sh0gun Sh0gun is offline
New Member
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Hey guys, just came across this site by goggling. I'm in a grade 12 computer engineering course and i've been out of class with a stomach flu for almost 2 weeks. I've come back and I'm way behind but the marks for midterms are submitted friday. I really want to try getting the bulk of this done so it doesn't make my mark look so bad on my mid term report card. I was wondering if anyone on here could help me with it.

neway, so you have something to help with once you read this

Right now im writing a program that will take three seperate hex numbers as input and and then output the average of those numbers in hex.

So far what im going through in my head is this.

Converting ASCII to HEX

It take in my input
I subtract 30 from my input
If my input it greater then nine, then i subtract 7 more
if not then i jump to the next step
add up my values, (store them?) into cl or something
divide them by 3
convert to decimal

this is what i have so far.

mov ah, 01 ;Preparing for input
int 21
mov al, dl ;moving input
SUB dl,30 ;subtract 30 from dl
CMP al,09 ;compare al
JLE 0110 ;if it less then or equal to 9 then jump to 0110
SUB dl,07 ;subtract 7 from dl


I am subtracting the 7 because in hex it goes 1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11,12 and I dont want letters included.
So far if i am correct, this will take my input and convert it into a usable hex #. Now i want to know how to store them in the same registry so i can divide by the number of inputs to find the average.

Last edited by Nico; 11-20-08 at 02:22 AM. Reason: Merged.
Reply With Quote
  #2 (permalink)  
Old 12-26-08, 03:44 PM
Phattytatty Phattytatty is offline
New Member
 
Join Date: Dec 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
you could just add them all together then divide them by how many there were for instance...




mov al,7
mov ah,8
mov bl,6
mov bh,7
mov cl,3
mov ch,4
mov dl,1
mov dh,0

;now add everything together
add al,ah
add al,bl
add al,bh
add al,cl
add al,ch
add al,dl
add al,dh

; now everything is in the very bottom of the eax register. al... you have to make ;some modifications to make it work with the 16 bit resgisters sence we just used ;8 bit.

sub ah,ah
mov bl,8 ;put 8 in here so because thats what you need to divide by
div bl ; AL = how many times it went in to it AH = remainders


; hope this helps ya dunno if its in time tho
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
assembly language anupamsr Hot Scripts Forum Questions, Suggestions and Feedback 9 12-31-08 10:45 AM
How to build a binary tree in assembly language? phingphing Other Languages 0 11-04-08 07:15 AM
Debounce switch using assembly language Laravinya Other Languages 0 04-29-07 03:37 PM
Assembly Language question jessicayan Other Languages 1 02-13-07 03:07 PM
Assembly language help please psi3000 Other Languages 0 03-25-06 09:21 PM


All times are GMT -5. The time now is 03:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.