Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 25th, 2007, 6:00 AM   #1
blitzmage_89
Newbie
 
Join Date: Jul 2007
Posts: 4
Rep Power: 0 blitzmage_89 is on a distinguished road
8088 assembly problem , half done need help

The problem :

An 8-byte ( 64-bit ) value is stored in a memory whose effective address is stored in CX. Another 8byte is stored in memory whose EA is DX. Write a function that adds the 2 8byte values and store the result to memory location whose effective address is stored in DI. Assume the most significant byte for each 8 byte value is stored in the highest memory location.
__________________
Can someone help me or provide the additional code needed? I made an assembly code in the past related to this but I can't figure out what to add to make it work
____________________--
Partial Code but not related to the problem above(Logic):
------------------------------...
MOV DS,AX
MOV ES,AX
MOV CX,2
MOV SI,0
L2: MOV AX,ALPHA[SI]
MOV BX,BETA[SI]
MOV DX,ALPHA[SI+2]
MOV DI,BETA[SI+2]
ADD BX , [TEMP]
ADD AX,BX
ADC DX,DI
MOV [TEMP],0
JNC L1
MOV [TEMP] , 1
L1:MOV wordptr RESULT [SI],AX
MOV wordptr RESULT [SI+2],DX
ADD SI , 4
LOOP L2
------------------------------...
Tnx guys , any help is appreciated!
blitzmage_89 is offline   Reply With Quote
Old Jul 25th, 2007, 7:28 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Looks to me like someone hasn't been doing their studies. The 8088 is an 8-bit processor; however, it has the ability to fetch 16-bit words from either even or odd addresses. This means you are going to have to add the 64-bit operands piecemeal. (See the carry flag.)

Since you'll probably want to address them with a pointer, you need to understand that your pointer will have to be made from a segment register and an offset address. This is NOT a combination that produces, when concatenated, a 32-bit address. You'll need to understand how the segmented address monstrosity works.

No one is going to write this for you (at least, it isn't likely). Presenting unrelated code is not considered much of an attempt at solving the problem. I would suggest you give it a shot. Post your commented code, then ask for help.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 25th, 2007, 8:14 AM   #3
blitzmage_89
Newbie
 
Join Date: Jul 2007
Posts: 4
Rep Power: 0 blitzmage_89 is on a distinguished road
yeah i think i know the logic , but how do you add values which are memory segmented? i mean just like in the problem , how would I get the value of CX since its only the effective address?
blitzmage_89 is offline   Reply With Quote
Old Jul 25th, 2007, 9:36 AM   #4
Random-Spirit
Unverified User
 
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0 Random-Spirit is an unknown quantity at this point
I don’t mean to be disrespectful to you Dawei but the 8088 is a 16bit processor with a 20bit address bus but only has an 8bit data bus. The 8086 has the full 16 bit data bus, but at the time 16bit memory was expensive so intel created the 8088 for the IBM PC.

You are quite correct that to address into the full 20bit range you have to use segmented memory addressing.

If memory serves me correctly (please feel free to correct me if I am wrong), to use segmented addressing you have a segment and an offset address. Both are 16bit values. The segment specifies funnily enough specifies the segment in memory. Each segment is 16bytes long. So to get the real address where a segment address points to you multiply the segment address by 16.

The offset address lets you address into the segment specified. If you add the offset to the physical address gained from the segment you can address anywhere in memory. It is also true that you can address any byte in memory up to 2^16 (65536) bytes beyond the start of the segment.

So a simple calculation: - We specify the segment to be segment 20 with an offset of 15. What is the physical address of that? Well its (20 x 16) + 15 = 335. So the general formula is (segment x 16) + offset = physical address. Now there is a simple way to do this in assembly. All you do is shift the segment address to the left by 4 places (same as a multiply by 16) and then add the offset.

There is a special syntax for specifying a segmented address. The address is written with four hex digits separated with a colon. In my previous example the syntax would be 0014:000F (20 is 14 in hex and 15 is F). Thinking about it more it is obvious to see that there is sometimes more than one way to specify a physical address with this scheme. If an offset has a value less than 16 then it is considered normalised.

I don’t have much experience with segmented addressing from assembly but that is what I learned when I did it from C with some special functions. This is the scheme used on the 8088/86, I am not sure if it is the same for the 80286 when it is in protected mode.
Random-Spirit is offline   Reply With Quote
Old Jul 25th, 2007, 11:00 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You are correct that it has 16-bit registers. Thus my statement that one could fetch 16-bit words. Processors are characterized by the width of their data bus, not their registers or address bus. If one wants the "16-bit" version, one uses the 8086. Don't try to teach me to suck eggs. I've written more assembler for that machine than you've written total code in your entire life.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 25th, 2007, 11:37 AM   #6
Random-Spirit
Unverified User
 
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0 Random-Spirit is an unknown quantity at this point
>Don't try to teach me to suck eggs

Not trying to, just trying to help out the OP. No disrespect was meant.

>. I've written more assembler for that machine than you've written total code in your entire life.

Yep, I am 20 and only been programming for four years and only in the last two have I started to really learn about programming (and I still know hardly anything). I am sorry if it looked like I was trying to discredit you, all I was doing was trying to explain segmented memory to the OP (which I sill don’t know if I was correct). I have done only very simple x86 assembler programming so I could not show any assembly examples. :-)
Random-Spirit is offline   Reply With Quote
Old Jul 25th, 2007, 6:04 PM   #7
blitzmage_89
Newbie
 
Join Date: Jul 2007
Posts: 4
Rep Power: 0 blitzmage_89 is on a distinguished road
umm yeah , i have a question , let's say i want to get a value pointed by CX , will MOV AX , [CX] work?
blitzmage_89 is offline   Reply With Quote
Old Jul 25th, 2007, 7:03 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It depends on the assembler you're using; different ones have different mnemonics. Do you not possess documentation for what you're using? If not, try Google, or at least be specific. Read the "How to Post a Question" thread, it highlights the importance of good information.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 25th, 2007, 7:14 PM   #9
Komodo
Hobbyist Programmer
 
Komodo's Avatar
 
Join Date: May 2005
Location: Scranton, PA
Posts: 112
Rep Power: 0 Komodo is an unknown quantity at this point
Send a message via AIM to Komodo Send a message via MSN to Komodo
DaWei is being nice today...
Komodo is offline   Reply With Quote
Old Jul 25th, 2007, 9:36 PM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Thanks for your recent germane contributions to the subjects posted. I might suggest that, on many systems, one can enter a debug mode and type in instructions with the appropriate mnemonics, and see if the registers and memory change as expected.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assembly Language DaWei Coder's Corner Lounge 0 Apr 26th, 2007 10:15 PM
management system problem l2u C# 4 Mar 19th, 2007 2:30 PM
Assembly, Assembler? v0id Assembly 15 May 4th, 2006 8:52 AM
Assembly without a compiler grimpirate Assembly 16 Sep 8th, 2005 6:07 AM
SPIM Assembly Programming Simulation Problem tsgrimey Assembly 1 Feb 9th, 2005 2:21 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC