Author Topic: Help me look at the process  (Read 15831 times)

shaohua1986

  • Guest
Help me look at the process
« on: December 27, 2007, 10:21:04 AM »
This is a process interrupted,I do not know where the error happen.
I run the process int windows-dos ,use nasmw hello.asm -0 hello.com,but have error!
"binary output format does not support segment base references"

but I have another question,who can write the Correct process for me !
org   0100h
[section .text]
        mov   ax,cs
        mov   ds,ax
        mov   es,ax

;   mov   ss,ax
;   mov   sp,04c00h

mov   ax,3580h ;get the interrupt address
   int 21h

mov [int1choff],bx ;save the interrupt address
   mov [int1chseg],es
   push ds

mov dx,newint80h ;set the new interrupt address
   mov ax,seg newint80h ; get the section address

mov ds,ax
   mov ax,2508h
   int 21h
   pop ds

int 80h

mov dx,[int1choff] ;Resumption
   mov ax,[int1chseg]
   mov ds,ax
   mov ax,2580h
   int 21h

mov ax,4c00h ;exit
   int 21h
newint80h:
   sti
   push ax
   push bx
   push cx
   call   DispStr
   iret

DispStr:
       mov   ax,BootMessage
       mov   bp,ax
       mov   cx,25
        mov   ax,01301h
       mov   bh,0h
   mov bl,0Ah
      mov   dl,0
      int   10h
      ret  

[section .data]
BootMessage:   db   "hello word! "
int1choff:    dw 0
int1chseg:    dw 0

nobody

  • Guest
Re: Help me look at the process
« Reply #1 on: December 27, 2007, 03:15:48 PM »
Yeah... you haven't got segments, as such, in a binary file. When dos loads a .com file, segregs are pointed to your one-and-only segment.


org   100h
section .text

push es
   mov   ax,3580h ;get the interrupt address
   int 21h

mov [int1choff],bx ;save the interrupt address
   mov [int1chseg],es
        pop es

mov dx,newint80h ;set the new interrupt address

mov ax,2508h
   int 21h
   pop ds

int 80h

mov dx,[int1choff] ;Resumption
   mov ax,[int1chseg]
        push ds
   mov ds,ax
   mov ax,2580h
   int 21h
        pop ds

mov ax,4c00h ;exit
   int 21h
newint80h:
   sti
   push ax
   push bx
   push cx
   call   DispStr
        pop cx  ; !!!
        pop bx
        pop ax
   iret

DispStr:
       mov   bp,BootMessage
       mov   cx, BootMessageLen
        mov   ax,01301h
       mov   bh,0h
   mov bl,0Ah
      mov dh, 10
      mov   dl,10
      int   10h
      ret  

[section .data]
BootMessage:   db   "this is dos, fool!"
BootMessageLen equ $ - BootMessage

int1choff:    dw 0
int1chseg:    dw 0


That's untested, completely off the top of my head. It'll never work! But it may get you closer. Your main problem (I think) was pushing registers in the isr and then iret'ing without poppin' em'!

See if that'll assemble, at least...

Best,
Frank

shaohua1986

  • Guest
Re: Help me look at the process
« Reply #2 on: December 28, 2007, 07:27:52 AM »
thank you for give me a hand!
now I use djgpp to write my process interrupted!
But I could work it correct now!
I am a new learner!
so I want you can jive me a right code that I can study!
the nasm Information was less!