flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
windwakr 01 Jul 2009, 03:13
DS would be the segment the buffer is in, si would be the offset to buffer.
1 POST TO 2^8 posts! |
|||
![]() |
|
GhostXoPCorp 01 Jul 2009, 03:18
hows about
mov [DS:SI], buffer? if not can you explain how what you said works p.s. what wrong with my posts? |
|||
![]() |
|
windwakr 01 Jul 2009, 03:21
GhostXoPCorp wrote:
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.... |
|||
![]() |
|
GhostXoPCorp 01 Jul 2009, 03:25
how can i set ds to be the segment to the buffer?
|
|||
![]() |
|
windwakr 01 Jul 2009, 03:27
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 |
|||
![]() |
|
GhostXoPCorp 01 Jul 2009, 03:29
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 |
|||
![]() |
|
windwakr 01 Jul 2009, 03:37
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: |
|||
![]() |
|
GhostXoPCorp 01 Jul 2009, 03:40
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 |
|||
![]() |
|
windwakr 01 Jul 2009, 03:41
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.
|
|||
![]() |
|
LocoDelAssembly 01 Jul 2009, 03:42
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. |
|||
![]() |
|
GhostXoPCorp 01 Jul 2009, 03:50
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 ![]() thanks _________________ Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.