Errors with code and don't know why

Getting errors when compiling the assembly code

Page 1 of 1

3 Replies - 1231 Views - Last Post: 25 November 2009 - 12:10 AM

#1 jdm   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 20-January 09

Errors with code and don't know why

Post icon  Posted 23 November 2009 - 09:28 PM

I'm new to assembly and I got this code that I'm working on and when I compile it in vs I get error message. I need some help to figure it out. Thanks for the help in advance.

Sincerely yours;

jdm

TITLE MASM Template						(main.asm)


INCLUDE Irvine32.inc
.data
x byte LABEL BYTE
x word LABEL WORD
X DWORD 12345678h,51432195h
str1 BYTE "Two double words are: (hex) ",0d
str2 BYTE "Sum of double words: (hex and dec) ",0d
str3 BYTE "Sum of words in 3 ways (hex and dec ",0d
str4 BYTE "Sum of bytes 1,3,5 and 7 (3 ways) in decimal ",0d

.code
main PROC
; first code adds displays the two double words
; in hex and adds them, displaying in both decimal and hex
mov edx, offset str1
call writestring
mov eax, x
call writehex
mov al,' '
call writechar
mov eax, x+4
call writehex
call crlf
add eax, x
mov ebx, eax
mov edx, offset str2
call writestring
call writehex
mov al, ' '
call writechar
mov eax,ebx
call writedec
call crlf
; we will add the four words using ptr, label, and offset
; make sure upper bytes of eax are zero before beginning
sub eax,eax
mov ax, xword
add ax, xword+2
add ax, xword+4
add ax, xword+6
mov edx,offset str3
call writestring
call crlf
call writehex
call crlf
call writedec
call crlf
mov ax,word ptr x
add ax,word ptr (x+2)
add ax,word ptr (x+4)
add ax,word ptr (x+6)
call writehex
call crlf
call writedec
call crlf
mov esi, offset x
mov ax, [esi]
add ax, [esi+2]
add ax, [esi+4]
add ax, [esi+6]
call writehex
call crlf
call writedec
call crlf
; code for adding bytes (done three ways) as
; make sure upper bytes of eax are zero before beginning
sub eax,eax
mov dx, offset str4
call writestring
call crlf
mov al, xbyte +1
add al, xbyte +3
add al, xbyte +5
add al, xbyte +7
call writehex
call crlf
call writeint
call crlf
mov al, byte ptr x+1
add al, byte ptr x+3
add al, byte ptr x+5
add al, byte ptr x+7
call writehex
call crlf
call writeint
call crlf
mov esi, offset x
mov al, [esi+1]
add al, [esi+3]
add al, [esi+5]
add al, [esi+7]
call writehex
call crlf
call writeint
call crlf
	exit
main ENDP

END main



Is This A Good Question/Topic? 0
  • +

Replies To: Errors with code and don't know why

#2 carltech   User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: Errors with code and don't know why

Posted 25 November 2009 - 12:07 AM

what was the error message and what do you need help with
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6703
  • View blog
  • Posts: 31,082
  • Joined: 10-May 07

Re: Errors with code and don't know why

Posted 25 November 2009 - 12:10 AM

View Postjdm, on 23 Nov, 2009 - 10:28 PM, said:

when I compile it in vs I get error message.

Assuming that vs is short for Visual Studios, I'm not sure that Visual Studios including an assembler.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Errors with code and don't know why

Posted 25 November 2009 - 12:10 AM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1