flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > Debugger

Author
Thread Post new topic Reply to topic
Klod



Joined: 25 Nov 2003
Posts: 25
Location: Canada
Klod
Is there a debugger that runs under Menuet?
What debugging tools/practices are you people using?

_________________
Do not Assume, it makes an ASS out of U and ME!
Post 12 Oct 2004, 22:16
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
I'm using DEBUG.INC if needed. AFAIK no other tools available.
Post 12 Oct 2004, 23:29
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Klod



Joined: 25 Nov 2003
Posts: 25
Location: Canada
Klod
Could you give me an example on haow to?
Post 16 Oct 2004, 04:22
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
What for do you need an example??? It's just a set of macroses (don't use procedures directly, they won't save you flags and registers) which output something (string, decimal, hex, char) to debug board. The code is there (debug.inc), it's pretty self-explaining:
Code:
macro debug_print str
{
   local ..string, ..label

   jmp ..label
   ..string db str,0
  ..label:

   pushf
   pushad
   mov  edx,..string
   call debug_outstr
   popad
   popf
}

dps fix debug_print

macro debug_print_dec arg
{
   pushf
   pushad
   if ~arg eq eax
     mov  eax,arg
   end if
   call debug_outdec
   popad
   popf
}

dpd fix debug_print_dec

;---------------------------------
debug_outdec:           ;(eax - num, edi-str)
        push 10         ;2
        pop ecx         ;1
        push -'0'       ;2
    .l0:
        xor edx,edx     ;2
        div ecx         ;2
        push edx        ;1
        test eax,eax    ;2
        jnz .l0         ;2
    .l1:
        pop eax         ;1
        add al,'0'      ;2
        call debug_outchar ; stosb
        jnz .l1         ;2
        ret             ;1
;---------------------------------

debug_outchar:          ; al - char
   pushf
   pushad
   mov  cl,al
   mov  eax,63
   mov  ebx,1
   int  0x40
   popad
   popf
ret

debug_outstr:
   mov  eax,63
   mov  ebx,1
 @@:
   mov  cl,[edx]
   test cl,cl
   jz   @f
   int  40h
   inc  edx
   jmp  @b
 @@:
   ret


macro newline
{
  dps <13,10>
}

macro print message
{
  dps message
  newline
}

macro pregs
{
  dps "EAX: "
  dpd eax
  dps "   EBX: "
  dpd ebx
  newline
  dps "ECX: "
  dpd ecx
  dps "   EDX: "
  dpd edx
  newline
}

macro debug_print_hex arg
{
    pushf
    pushad
    if ~arg eq eax
      mov eax, arg
    end if
    call debug_outhex
    popad
    popf
}
dph fix debug_print_hex

debug_outhex:
    ;  eax - number
    mov   edx, 8
  .new_char:
    rol   eax, 4
    movzx ecx, al
    and   cl,  0x0f
    mov   cl,  [__hexdigits + ecx]
    pushad
    mcall 63, 1
    popad
    dec   edx
    jnz   .new_char
ret

__hexdigits:
  db '0123456789ABCDEF'    
Post 16 Oct 2004, 07:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Klod



Joined: 25 Nov 2003
Posts: 25
Location: Canada
Klod
thsnkd for your repley Mike.dld.
I must have overlooked the file debug.inc Embarassed

_________________
Do not Assume, it makes an ASS out of U and ME!
Post 18 Oct 2004, 17:14
View user's profile Send private message Reply with quote
profkid13



Joined: 21 Aug 2003
Posts: 111
profkid13
mike.dld wrote:
What for do you need an example??? It's just a set of macroses (don't use procedures directly, they won't save you flags and registers) which output something (string, decimal, hex, char) to debug board. The code is there (debug.inc), it's pretty self-explaining:
Code:
macro debug_print str
{
   local ..string, ..label

   jmp ..label
   ..string db str,0
  ..label:

   pushf
   pushad
   mov  edx,..string
   call debug_outstr
   popad
   popf
}

dps fix debug_print

macro debug_print_dec arg
{
   pushf
   pushad
   if ~arg eq eax
     mov  eax,arg
   end if
   call debug_outdec
   popad
   popf
}

dpd fix debug_print_dec

;---------------------------------
debug_outdec:           ;(eax - num, edi-str)
        push 10         ;2
        pop ecx         ;1
        push -'0'       ;2
    .l0:
        xor edx,edx     ;2
        div ecx         ;2
        push edx        ;1
        test eax,eax    ;2
        jnz .l0         ;2
    .l1:
        pop eax         ;1
        add al,'0'      ;2
        call debug_outchar ; stosb
        jnz .l1         ;2
        ret             ;1
;---------------------------------

debug_outchar:          ; al - char
   pushf
   pushad
   mov  cl,al
   mov  eax,63
   mov  ebx,1
   int  0x40
   popad
   popf
ret

debug_outstr:
   mov  eax,63
   mov  ebx,1
 @@:
   mov  cl,[edx]
   test cl,cl
   jz   @f
   int  40h
   inc  edx
   jmp  @b
 @@:
   ret


macro newline
{
  dps <13,10>
}

macro print message
{
  dps message
  newline
}

macro pregs
{
  dps "EAX: "
  dpd eax
  dps "   EBX: "
  dpd ebx
  newline
  dps "ECX: "
  dpd ecx
  dps "   EDX: "
  dpd edx
  newline
}

macro debug_print_hex arg
{
    pushf
    pushad
    if ~arg eq eax
      mov eax, arg
    end if
    call debug_outhex
    popad
    popf
}
dph fix debug_print_hex

debug_outhex:
    ;  eax - number
    mov   edx, 8
  .new_char:
    rol   eax, 4
    movzx ecx, al
    and   cl,  0x0f
    mov   cl,  [__hexdigits + ecx]
    pushad
    mcall 63, 1
    popad
    dec   edx
    jnz   .new_char
ret

__hexdigits:
  db '0123456789ABCDEF'    



fasm1.56 doesnt want's to compile this:
Code:
mcall 63, 1    
is this a bug or me being dum? Confused btw, is debug.inc distributed elsewhere than here on this forum?
Post 20 Oct 2004, 12:15
View user's profile Send private message Reply with quote
Ivan Poddubny



Joined: 21 Sep 2003
Posts: 32
Location: Yaroslavl, Russia
Ivan Poddubny
Quote:
fasm1.56 doesnt want's to compile this:
Code:
mcall 63, 1


Replace it with
Code:
mov eax, 63
mov ebx, 1
int 0x40
    


BTW Debug.inc is distributed with RE#8.
Post 20 Oct 2004, 14:14
View user's profile Send private message Visit poster's website Reply with quote
profkid13



Joined: 21 Aug 2003
Posts: 111
profkid13
Ivan Poddubny wrote:
Quote:
fasm1.56 doesnt want's to compile this:
Code:
mcall 63, 1


Replace it with
Code:
mov eax, 63
mov ebx, 1
int 0x40
    


i know, but why doesnt the shorter code works?
let me gues, its a function in the macros.inc distibuted with re#8? Very Happy
Quote:
BTW Debug.inc is distributed with RE#8.

ah, thats why i couldnt find it Razz
Post 20 Oct 2004, 14:41
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
It's mine and Ivan's macroses to code Menuet applications easier:
Code:
macro mpack dest, hsrc, lsrc { ; Ivan Poddubny
 if (hsrc eqtype 0) & (lsrc eqtype 0)
  mov dest, (hsrc) shl 16 + lsrc
 else
  if (hsrc eqtype 0) & (~lsrc eqtype 0)
   mov dest, (hsrc) shl 16
   add dest, lsrc
  else
   mov dest, hsrc
   shl dest, 16
   add dest, lsrc
  end if
 end if
}

macro __mov reg,a,b { ; mike.dld
 if (~a eq)&(~b eq)
  mpack reg,a,b
 else if (~a eq)&(b eq)
  mov reg,a
 end if
}

macro mcall a,b,c,d,e,f { ; mike.dld
 __mov eax,a
 __mov ebx,b
 __mov ecx,c
 __mov edx,d
 __mov esi,e
 __mov edi,f
 int   0x40
}    

You can find them in MACROS.INC file from russian distro (RE#8).
EXAMPLE.ASM becomes:
Code:
  use32
  org    0x0

  db     'MENUET01'
  dd     0x01
  dd     START
  dd     I_END
  dd     0x100000
  dd     0x100000
  dd     0x0
  dd     0x0

include 'MACROS.INC'

START:

red:

    call draw_window

still:
    mcall 10

    cmp  eax,1
    je   red
    cmp  eax,2
    je   key
    cmp  eax,3
    je   button

    jmp  still

  key:
    mcall 2

    mov  [Music+1], ah

    mcall 55, eax, , , Music

    jmp  still

  button:
    mcall 17

    cmp   ah, 1
    jne   still

  .exit:
    mcall -1

draw_window:
    mcall 12, 1
    mcall 0,<200,200>,<200,50>,0x02AABBCC,0x805080D0,0x005080D0
    mcall 4,<8,8>,0x10DDEEFF,header,header.size
    mcall  ,<8,30>,0,message,message.size
    mcall 8,<200-19,12>,<5,12>,1,0x6688DD
    mcall 12, 2
    ret

Music:
  db  0x90, 0x30, 0

lsz message,\
  en,'Press any key...',\
  fr,'Pressez une touche...'

lsz header,\
  en,'EXAMPLE APPLICATION',\
  fr,"L'exemplaire programme"

I_END:    
Post 20 Oct 2004, 18:58
View user's profile Send private message Visit poster's website 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 can attach files in this forum
You can download files in this forum


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

Website powered by rwasa.