Current location: Hot Scripts Forums » Programming Languages » Other Languages » Assembly Language multiplication


Assembly Language multiplication

Reply
  #1 (permalink)  
Old 04-29-07, 11:10 PM
Super Firey Dave Super Firey Dave is offline
New Member
 
Join Date: Apr 2007
Location: Brisbane, AU
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Assembly Language multiplication

I've recently started learning Assembly language and although it seems awfully tedious I'm making a bit of headway. I'm currently using a 6800 emulator found here http://www.hvrsoftware.com/6800emu.htm



I've made two subroutines charout and strout to enable output and everythings dandy.

My problem lies in that I'd like to be able to directly specify an x and y value for the string/char to be outputted on the 54x20 display.

The string buffer is at $FB00 and basically what I want to do is this:

output adjustment = (y * 54) + x
absolute output position = $FB00 + output adjustment

but I can't figure out how to do that

Hope that all made sense, and any help is greatly appreciated.

*EDIT*

Oh, I forgot to mention that x is a value between 0 and 53, and y is a value between 0 and 29

*END EDIT*

Last edited by Super Firey Dave; 04-29-07 at 11:28 PM.
Reply With Quote
  #2 (permalink)  
Old 04-30-07, 08:32 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
If your screen resolution gave you 80 bytes wide then you would use:
output adjustment = (y * 80) + x
absolute output position = $FB00 + output adjustment

And if your screen resolution gave you 160 bytes wide then you would use:
output adjustment = (y * 160) + x
absolute output position = $FB00 + output adjustment

You see the problem you are having is you are only looking at the matrix you have created and not the whole screen. If you remember the screen is one continuous string of memory locations. Therefore you have to count every memory location.
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 04-30-07, 09:35 AM
Super Firey Dave Super Firey Dave is offline
New Member
 
Join Date: Apr 2007
Location: Brisbane, AU
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure if you've misunderstood me.
It's an emulator, it has a fixed resolution of 54 by 20.

In either case, regardless of what it's doing how does one write the code to multiple something by 54 times?

I understand how to double something using a shift left but multiplying higher eludes me.
Reply With Quote
  #4 (permalink)  
Old 04-30-07, 10:00 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
You need to use a combination of shift (*2) and addition (or subtraction.) You could use straight addition (add 54 times), but this would be the slowest.

One quick possibility, shift 6 places (assuming I counted correctly) to multiply by 64, saving the x2 and the x8 values so that you can subtract them from the x64 value -

Z x 54 = Z x (64-10) = Z x (64-2-8) = Z x 64 - Z x 2 - Z x 8
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #5 (permalink)  
Old 04-30-07, 10:37 AM
Super Firey Dave Super Firey Dave is offline
New Member
 
Join Date: Apr 2007
Location: Brisbane, AU
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Oh thanks, that's a really good idea.
I hadn't thought of keeping the eight times and the two times values.

My second question is do I actually calculate it given the accumulators can only hold two hex values each making the largest number 225?
Obviously even a small y value such as 5 multiplied by 54 would go over this limit.
Reply With Quote
  #6 (permalink)  
Old 04-30-07, 01:05 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Thats where the carry and overflow bits come in.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
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
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
assembly language help lore00 Other Languages 6 04-24-05 12:22 AM


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