flat assembler
Message board for the users of flat assembler.

Index > Main > DS:SI point to buffer

Author
Thread Post new topic Reply to topic
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
how would i do that, i have had a qeustion like this in my head for a while now and i want to know how to do that?

here what i thought it to be

point buffer to ds:si

mov ds, si
mov si, buffer

is that it? if not can some one explain how that al works to me please?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 01 Jul 2009, 03:09
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
DS would be the segment the buffer is in, si would be the offset to buffer.



1 POST TO 2^8 posts!
Post 01 Jul 2009, 03:13
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
hows about
mov [DS:SI], buffer?
if not can you explain how what you said works

p.s. what wrong with my posts?
Post 01 Jul 2009, 03:18
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
GhostXoPCorp wrote:

p.s. what wrong with my posts?



mov ds, si


What is si before this move?
You set up si properly below that, but you're not setting up DS right. You need to set ds to the segment that "buffer" is in.


2^8 Posts Woo....

_________________
----> * <---- My star, won HERE
Post 01 Jul 2009, 03:21
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
how can i set ds to be the segment to the buffer?
Post 01 Jul 2009, 03:25
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Well, it depends on what you're doing, if the buffer is in the same area as your code you'd just do:

push cs
pop ds
Post 01 Jul 2009, 03:27
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
could you give me an example of pointing the buffer to DS:SI
i am learning vesa and came upon this and i want to know how to do this, this is another reason why i am asking
Post 01 Jul 2009, 03:29
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Sorry, I'm not the best person to be explaining this.

This sets up both DS:SI and ES:DI and would transfer buffer1's contents to buffer2.(Theres nothing to tranfer though, just showing the set up.)

Code:
org 100h

push cs           ;buffer is in the code segment, so set ds up right
pop ds
mov si,buffer1

push cs           ;buffer is in the code segment, so set es up right
pop es
mov di,buffer2

mov cx,1000
rep movsb ;Move DS:SI to ES:DI and increase both si and di

jmp $

buffer1:
rb 1000
buffer2:          
    

_________________
----> * <---- My star, won HERE
Post 01 Jul 2009, 03:37
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
thanks though, i will look this over a couple times, thanks

so if i use ds, i have to pop ds and the same for es, i pop es
an use cs if the buffer is used in the code
Post 01 Jul 2009, 03:40
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Ya, or you could do mov ds,ax....where ax has the value to put into ds. You can't directly put a value into the segment registers.
Post 01 Jul 2009, 03:41
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Three methods (not necessarily all):
Code:
; Memory allocated via Int21

mov ah, $48
mov bx, (BUFFER_SIZE + 15) / 16 ; DOS allocates paragraphs, i.e., multiples of 16 bytes
int $21
jc  ERROR
mov ds, ax
mov si, 0 ; The returned segment is always pointing to the beginning of the allocated block    


You have the pointer stored in some dword variable:
Code:
lds si, [pointer]    


You have a multi-segment executable:
Code:
format MZ
entry main:start

segment main
start:

mov ax, bss
mov ds, ax
mov si, buffer

; Also
lds si, dword [pointer]

; More code here

pointer dw buffer, bss

segment bss

buffer rb 256    


You have to understand however that once you set DS then nearly all instructions will refer to the segment where the buffer is located. In general you may want to use ES segment for this instead and use segment overrides like "mov [es:si], al". But, of course this all depends of your code, this is just a warn.
Post 01 Jul 2009, 03:42
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp
thanks you guys, if i hadnt of asked this question, i would of never of had known it on my own



windwakr:
Quote:
Sorry, I'm not the best person to be explaining this.


yeah, if you are explaining this to some one with no fasm experience, but to some one like me who has been learning fasm for a while, this is as good as an explanation of this can get Smile
thanks

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 01 Jul 2009, 03:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.