;***************************************************************************** ; This program is designed to demonstrate how use "debugger.inc" in an ; assembly language program. The files "debugger.inc" and "io32.inc" must be ; included (and should be in your working directory) in order for the program ; to assemble. ; ; NOTE: See the macro and procedure headers in "debugger.inc" and "io32.inc" ; for information on required parameters. ; ; Written by Joe Toone 3/3/2008 11:13:40 AM ;***************************************************************************** TITLE testdbg.asm CR equ 0dh ;ASCII 13d for carriage return LF equ 0ah ;ASCII 10d for line feed NEWLINE equ CR,LF ;Combine CR and LF for carriage return DOUBLESPC equ NEWLINE,LF ;Combine NEWLINE and LF for double space MAXSTR equ 256d ;Accept up to 256 character string .586 ;Allow for Pentium instrucitons .MODEL FLAT ;Flat memory model INCLUDE io32.inc ;Include the 32 bit I/O procedures INCLUDE debugger.inc ;Include the debugging procedures .STACK 4096h ;4K hex words for stack .DATA Intro BYTE 'This program demonstrates MACROs and PROCs available in ' BYTE '"debugger.inc".',DOUBLESPC,0 Prompt BYTE 'Please enter a string --> ',0 StrIn BYTE 80d dup(0) Num1 WORD 0abcdh Num2 DWORD 1234567890d Num3 DWORD 0abcdefh ;************************** Main Body of Program ***************************** ; The main body of the program is in the form of a REPEAT...UNTIL loop ; Requires : Nothing ; Process : Main Body - demonstrates various debugging tools ; Return : Nothing ;***************************************************************************** .CODE _main: lea esi, Intro ;point to intro strin call PrintString ; and go print it ;put some numbers in the registers mov eax,0abcdefh ; EAX = 0abcdefh mov ebx,65535d ; EBX = 65535d mov ecx,65535h ; ECX = 65535h mov edx,1a2b3c4dh ; EDX = 1a2b3c4dh call DumpRegs ; and show the registers Pause ;wait for a key press ;You may uncomment the next few lines ;one at the time to see the flags set ;or cleared. mul ebx ;set CF and OF ; clc ;clear CF ; stc ;set CF ; std ;set DF ; cld ;clear DF ; xor eax,eax ;set ZF ; cmp eax,1d ;clear ZF ; sub eax,0ffffffffh ;set SF ; mov al,0fh ;fill low order nibble of AL ; inc al ; and increment to set AF call DumpRegs ;show the registers Pause ;wait for key press ;Now do a memory dump lea esi,Intro ;starting address to dump mov ebx,1 ;size of data one byte mov ecx,256 ;number of units to dump call DumpMem ; go dump the memory Pause ;wait for key press mov ecx,8d ;set loop counter for 8 repititions mov eax,0ffffh ;set starting value for EAX mov ebx,0abcdh ; and EDX LoopTop:add eax,0fh ; add 0fh to EAX imul ebx,4 ; multiply in EBX only call DumpRegs ; display the registers ; Pause ; wait for key press loop LoopTop ; and continue the loop movzx eax,Num1 ;move 16 bit number into EAX call WriteHex ; and display it WriteSpace 4d ; and print 4 spaces mov al,0cdh ;mov AL 0abh call HexByte ; and display it WriteSpace 4d ; and print 4 spaces lea esi, Prompt ;point to user prompt call PrintString ; and go print it lea esi, StrIn ;point to string buffer call GetString ; and get the user input ShowString StrIn ;use debugger to show user string INVOKE ExitProcess, 0 ;Exit program with return code 0 Public _main ;Declare main as publicly accessible END ;End of Code Segment