flat assembler
Message board for the users of flat assembler.

Index > DOS > Where is error ? program do not run.

Author
Thread Post new topic Reply to topic
mastek



Joined: 29 Jun 2006
Posts: 17
mastek 20 Aug 2006, 17:28
Hello guys. I am beginner. I am learning ASM. I changed usedpmi fasm example. But messages are not displaying now. Where is my error ? I could not find.

Code:
----     usedpmi.asm    ---- (changed - my example)

format MZ
heap 0                                  ; no additional memory

segment loader use16

        push    cs
        pop     ds

        mov     ax,1687h
        int     2Fh
        or      ax,ax                   ; DPMI installed?
        jnz     error
        test    bl,1                    ; 32-bit programs supported?
        jz      error
        mov     word [mode_switch],di
        mov     word [mode_switch+2],es
        mov     bx,si   ; allocate memory for DPMI data
        mov     ah,48h
        int     21h
        jc      error
        mov     es,ax
        mov     ax,1
        call    far [mode_switch]       ; switch to protected mode
        jc      error

        mov     cx,1
        xor     ax,ax
        int     31h             ; allocate descriptor for code
        mov     si,ax
        xor     ax,ax
        int     31h             ; allocate descriptor for data
        mov     di,ax
        mov     dx,cs
        lar     cx,dx
        shr     cx,8
        or      cx,0C000h
        mov     bx,si
        mov     ax,9
        int     31h     ; set code descriptor access rights
        mov     dx,ds
        lar     cx,dx
        shr     cx,8
        or      cx,0C000h
        mov     bx,di
        int     31h     ; set data descriptor access rights
        mov     ecx,main
        shl     ecx,4
        mov     dx,cx
        shr     ecx,16
        mov     ax,7            ; set descriptor base address
        int     31h
        mov     bx,si
        int     31h
        mov     cx,0FFFFh
        mov     dx,0FFFFh
        mov     ax,8            ; set segment limit to 4 GB
        int     31h
        mov     bx,di
        int     31h

        mov     ds,di
        mov     es,di
        mov     fs,di
        mov     gs,di
        push    si
        push    dword start
        retfd

    error:
        mov    esi,hata
        mov       dl,al
        mov       ah,2
        mov       ax,4CFFh
        int       21h

  mode_switch dd ?

segment main use32

  start:
        mov     esi,hello
    .loop:
        lodsb
        or      al,al
        jz      .done
        mov     dl,al
        mov     ah,2
        mov     ax,4C00h
        int     21h
        jmp     .loop
    .done:

        mov     ax,4C00h
        int     21h

  hello db 'Hello from protected mode!',0Dh,0Ah,0
  hata  db 'Error : No DPMI Server',0Dh,0Ah,0
    
Post 20 Aug 2006, 17:28
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 25 Aug 2006, 03:14
hello,
well im somewhat sure you have some mispellings like:

Code:
start:
mov esi,hello
.loop:
lodsb
or al,al
jz .done
mov dl,al
mov ah,2
mov ax,4C00h
int 21h
jmp .loop
.done:

mov ax,4C00h
int 21h 
    


the interesting part is
Code:
mov ax,4C00h
int 21h
jmp .loop
.done:
    

dos function exit with error code: 00h
then jump to .loop

i think you could fix these easily

hm and there are some things different in protected mode than in dos mode, for example you can only use interrupts that can be called from protected mode, unless you do some trick, and call 16 bit interrupt routines.
Post 25 Aug 2006, 03:14
View user's profile Send private message Visit poster's website Reply with quote
mastek



Joined: 29 Jun 2006
Posts: 17
mastek 25 Aug 2006, 07:32
Thank you Matrix.
Post 25 Aug 2006, 07:32
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 30 Aug 2006, 23:29
np, mastek
did you figure out the problem, made it working?
Post 30 Aug 2006, 23:29
View user's profile Send private message Visit poster's website Reply with quote
mastek



Joined: 29 Jun 2006
Posts: 17
mastek 05 Sep 2006, 21:17
I tryed fix this part. But I could not do and I locked my system Smile
Asm is hard and I am beginner Sad

I want add message "no dpmi server" but i could not be.
Post 05 Sep 2006, 21:17
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 05 Sep 2006, 21:28
i think that you cannot call real-mode int 21h directly from protected mode
Post 05 Sep 2006, 21:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.