OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 6:29 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Assembler help
PostPosted: Wed Jan 15, 2003 11:48 am 
I'm currently reviewing assembly language from a book I have and I have sort of a question. This is what I trying to do:
Code:
Summing a list of numbers

The following example shows how register indirect and based addressing modes may be used to access individual elements of an array. We add a list of numbers together and store the result in a variable called sum:

mov bx,offset list  ; Get offset of list
mov ax,0             
mov al,[bx]           ; Get first number
add al,[bx+1]       ; Add second number
add al,[bx+2]       ; Add third number
add al,[bx+3]       ; Add fourth number
add al,[bx+4]       ; Add fifth number
mov sum,ax         ; Store the sum

list   db 10h, 20h, 40h, 2h, 5h
sum dw 0

This is source code for MASM. I using NASM and so it doesn't support the "offset" of the list.

What do they mean by the offset of the list? Could someone explain this to me. Is there a way around this problem? Is it even needed?

Thanks for the help in advance!


Top
  
 
 Post subject: Re:Assembler help
PostPosted: Wed Jan 15, 2003 2:24 pm 
It's not needed when assembling in NASM.

MASM:
Code:
mov eax, var    ; puts value at var into eax
mov eax, offset var    ; puts address of var into eax

NASM:
Code:
mov eax, [var]    ; puts value at var into eax
mov eax, var    ; puts address of var into eax


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group