I keep getting operand size conflict errors when I run this program I cant seem to get it right!

Write an assembly language program that will use multiple precision arithmetic to add the following defined word (dw) numbers in defined 16-bit registers (like ax, bx, cx and dx). (hint: use immediate addressing – and don't forget to account for the carry information).

A8Eeh
6789h
CABBh
7777h

//
// Matthew Tye 101 36 654
// Multiple Precision Arithmetic with DW's
// 252A9

    
#include "stdafx.h"
#include <iostream>

using namespace std;


int main(int argc, char* argv[])
{
//  your properly formatted assembly language data here
	 unsigned short int loword = 0;
	 unsigned short int hiword = 0;
     unsigned short int ans1 = 0;
   

        __asm {
//  your syntatically correct assembly language code here
//  column alignment markers below (to guide you)
//      |       |               |
		
		sub      eax,eax			;zero out eax register
                sub      edx,edx			;zero out edx register
                mov     ax,A8EE			       ;move A8Ee into ax
		add	 ax,6789			;add 6789 to ax
		add	 ax,CABB		       ;add CABB to ax
		add	 ax,7777			;add 7777 to ax	
		adc      dx,00			          ;accumulate in dx any carries
		mov     loword,ax		       ;move ax into loword
		mov  	hiword,dx		       ;move dx into hiword



        }

    return(0);
}

You have to call ADC after each ADD. (The carry flag is only one bit deep.)

Hope this helps.

You have to call ADC after each ADD. (The carry flag is only one bit deep.)

Hope this helps.

i tried this, but i am assuming i am missing something else as i get the same error

sub     eax,eax			;zero out eax register
                      sub     edx,edx	     ;zero out edx register
                      mov     ax,A8EE			;move A8Ee into ax
		add		ax,6789			;add 6789 to ax
		adc     dx,00			;accumulate in dx any carries
		add		ax,CABB			;add CABB to ax
		adc     dx,00			;accumulate in dx any carries
		add		ax,7777			;add 7777 to ax	
		adc     dx,00			;accumulate in dx any carries
		mov     loword,ax		;move ax into loword
		mov  	hiword,dx		;move dx into hiword

Ah, yes, I forgot to address your question. Sorry. :$

unsigned int corresponds to EAX.
unsigned short corresponds to AX.
unsigned char corresponds to AL.

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.