Re: referring to segments other than DS - how?



Thanks Frank. Maybe you or someone else can help with this. Assuming I
only have 16-bit registers, and I've got a buffer in BSS, how do I write
the buffer to a file? If I understand correctly, function 40h / int 21h
needs the address of the buffer to be in DS:DX, so I have to move the BSS
segment to DS. However, my program is terminating on the int 21h below -
before even setting error code to AX or setting the Carry Flag.

(I have ES set to BSS below. label 'InputBuffer is an offset into BSS)

mov ax, 40h ; func. write array
mov bx, EncFileHandle ; file handle to bx
mov cx, 500 ; bytes to write from 3fh abv

mov di, es
mov ds, di ; set ds to es for inp.buffer

mov dx,OFFSET InputBuffer
int 21h ;terminates abrubtly here

cmp ax,0 ; did we write anything
je EmptyOutput

Only thing I can think is that EncFileHandle, which is a label to an
offset into the regular Data Segment (not BSS), causes it to screw up...
However, reading a file into this array in the same fashion, with 3Fh /
int 21h, didn't have a problem. If the function *is* interpreting
EncFileHandle to be in *BSS*, how the heck does anyone write to an
uninitialized buffer? !@#$%! :)

Again, I'm trying not to use 32-bit registers. Many thanks in advance.

there's a small typo:

mov ax, 40h ; func. write array

must be

mov ah, 40h ; func. write array
.



Relevant Pages

  • Re: referring to segments other than DS - how?
    ... only have 16-bit registers, and I've got a buffer in BSS, how do I write ... BSS segment to DS. ... OpenEncFile PROC ...
    (alt.lang.asm)
  • Re: Buffers in Assembly (NASM)
    ... can create a zero filled buffer in the bss section in NASM with this: ... it doesn't know what ".bss" means. ... In an uninitialized section, there's "nothing there", so it would be "conceptually impossible" for Nasm to zero it. ... mov al, 'N' ...
    (comp.lang.asm.x86)
  • Re: Buffers in Assembly (NASM)
    ... it doesn't know what ".bss" means. ... In other formats, this will ... Nasm to zero it. ... I'm basically just creating a buffer to write strings for functions ...
    (comp.lang.asm.x86)
  • Re: static char overflow
    ... > you can see your buffer is located at bss section and there isnt another ... There is no static heap section afterwards, ... entire dynamic heap is initialized after the .bss section, ... I heard that it can be exploited in old linux if it is ...
    (Vuln-Dev)
  • Re: Buffers in Assembly (NASM)
    ... can create a zero filled buffer in the bss section in NASM with this: ... The bss section is by definition not initialized by the program, ... But how do I zero out the buffer on the stack? ...
    (comp.lang.asm.x86)