Pages: [1]
|
 |
|
Author
|
Topic: Masm32 debugger (Read 9535 times)
|
pps
Member
 
Posts: 29
|
When i wa using tasm i was having turbo debuger and i could see the results in memory. Here in masm i can't find something like this. I have the following code ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ include \masm32\include\masm32rt.inc ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
comment * ----------------------------------------------------- Build this console app with "MAKEIT.BAT" on the PROJECT menu. ----------------------------------------------------- *
.data? value dd ?
.data item dd 0 sir DW 1,2,3
.code
start: ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
call main inkey exit
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
main proc
cls mov si,0 mov bx,sir[si+4] mov ax,sir[si+2] mov sir[si+4],ax mov ax,sir[si] mov sir[si+2],ax mov sir[si],bx
ret
main endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end start
This cod assamble, link and generate the exe file but as you can see the result can't be seen. I shoult permute the values to the left, and i think it does. In tasm works fine but here i can't see the result. Added code tags
|
|
« Last Edit: November 11, 2010, 08:41:31 AM by MichaelW »
|
Logged
|
|
|
|
MichaelW
Global Moderator
Member
    
Gender: 
Posts: 5161
|
The code you posted is not 16-bit DOS code. Was it supposed to be, or should I move this to the Campus? Instead of using a debugger to view the results, you can display the results from the code by adding something like this: movzx eax, sir print str$(eax),13,10 movzx eax, sir+2 print str$(eax),13,10 movzx eax, sir+4 print str$(eax),13,10
|
|
|
Logged
|
eschew obfuscation
|
|
|
pps
Member
 
Posts: 29
|
what is movzx? i tought it was mov only... Why isn't it 16 bit? I use only ax, bx and words not eax or doubles...? I will try that, tanks!
|
|
|
Logged
|
|
|
|
MichaelW
Global Moderator
Member
    
Gender: 
Posts: 5161
|
It's not 16-bit code because it uses a 32-bit segment word size and a 32-bit memory model. Here are the first three statements in masm32rt.inc: .486 ; create 32 bit code .model flat, stdcall ; 32 bit memory model option casemap :none ; case sensitive
You can verify this by trying to assemble a statement that tries to move a 32-bit address into a 16-bit register: mov ax, OFFSET sir For which ML will return: error A2022: instruction operands must be the same size Specifying SI in the indirect memory operands works because ML is actually encoding the instruction to use ESI. And the only reason that you are getting away with the: mov si, 0 Instead of: mov esi, 0 Is that ESI is initially zeroed.
|
|
|
Logged
|
eschew obfuscation
|
|
|
pps
Member
 
Posts: 29
|
sorry. I didn't knew that... what shoult I include for a 16 bit code?
|
|
|
Logged
|
|
|
|
dedndave
|
the masm32 library doesn't support 16-bit code nor does link.exe - you have to use link16.exe, instead attached is a zip that has all the stuff to try both 
|
|
|
Logged
|
|
|
|
pps
Member
 
Posts: 29
|
Ok, i got the ideea. I saw ur examples, and i solved some problems but i have some more. I should say that i started to make all the programs or problems(this is how we call them) that i have in masm32. One problem is the next one. It works fine in tasm(16-bit) but here i have an error on mov ax,@DATA the code: ;x=x-y+|x-|y|| TITLE pr11 .MODEL SMALL .STACK 256 .DATA x dw 5h y dw 4h .CODE mov ax,@DATA mov ds,ax
mov bx,offset x mov ax,[bx+2] cmp ax,0 jge salt1 neg ax salt1: neg ax add ax,[bx] cmp ax,0 jge salt2 neg ax salt2: sub ax,[bx+2] add ax,[bx] mov [bx],ax
mov ax,4c00h int 21h END
|
|
|
Logged
|
|
|
|
dedndave
|
that should work under masm although - i have experienced something like it - lol @DATA is actually an alias for DGROUP DGROUP should be defined when .DATA is expanded in a SMALL model program you might try _DATA or DGROUP _DATA is the actual name of the data segment and DGROUP is DGROUP, without aliasing also - the END directive should reference the program entry point - that may be the culprit start: mov ax,@DATA . . . END start make sure you are using the right command line (i.e. batch file) to assemble @DATA and the /coff switch aren't likely to get along well
|
|
|
Logged
|
|
|
|
FORTRANS
Member
    
Gender: 
Posts: 1147
Imagine
|
Hi,
Your code assembled fine with MASM 5.0. So Dave may have found your problem.
Regards,
Steve N.
|
|
|
Logged
|
|
|
|
pps
Member
 
Posts: 29
|
i tried with DGROUP and _DATA, nothing. i tried with segments and the same. If in include masm32rc.inc it works but have a problem on mov bx,offset x... here is the changed code ;x=x-y+|x-|y|| TITLE pr11 .MODEL SMALL .STACK 256 data segment x dw 5h y dw 4h data ends cod segment assume ds:data, cs:cod start:
mov ax,DATA mov ds,ax
mov bx,offset x mov ax,[bx+2] cmp ax,0 jge salt1 neg ax salt1: neg ax add ax,[bx] cmp ax,0 jge salt2 neg ax salt2: sub ax,[bx+2] add ax,[bx] mov [bx],ax
mov ax,4c00h int 21h cod ends END start
|
|
|
Logged
|
|
|
|
Magnum
|
Since you are using Tasm, here is some Tasm code. It's fairly well commented and demonstrates a lot of things that Tasm uses. ; SHRED1.ASM Ver 1i B/W version ; (c) Copywrong 1996 - 2004 ; Tasm code ; ***** FILE is NOT recoverable !!!! **** ; ; Supports Long Filenames ; Works in Win XP in a DOS box, with short or long filenames ; ; Shreds a 331 Meg file in 80 secs on an AMD K-6 475 MHz ; ; Overwrite a file with zero bytes, truncates it to zero bytes, ; set file time and date to 12:59:58 pm 1/1/80, ; renames it and then deletes it. ; Single files only. (For Safety) ; ; Use SHORT (8.3) FILENAME when file is a LFN ; Ex. C:\PROGRA~1\VERYLO~1.ASM ; ; Works across drives, handles periods in the path names ; ; Help from Stealth, Raymond, Bitrake, Rudy Weiser, Frank Kotler, ; Fauzan Mirza, Robert Redelmeier, QvasiModo, and others ; .MODEL SMALL .386 .stack 200h
.data? ; can contain ONLY un-initialized data, keeps executable small random db 64000 dup(?) file_name db 128 dup(?) ; DOS maximum path length storage db 150 dup(?) .data
handle dw ? file_size dd ? name_size dw ?
; Direct video writes, shows right after Version number !! ; prompt db 13,10,13,10,9,'File Shredder Ver. 1h' ,13,10 db 13,10,9,'(c) Copyright 1996 - 2004',13,10 db 13,10,9,'IF YOU USE THIS PROGRAM, OVERWRITTEN FILES',13,10 db 13,10,9,'WILL BE GONE FOR GOOD. THIS PROGRAM CAUSES',13,10 db 13,10,9,'PERMANENT DATA LOSS. YOU HAVE BEEN WARNED!!',13,10 db 13,10,9,'Use SHORT (8.3) FILENAME when file is a LFN.',13,10 db 13,10,9,'Use full path when not in current DIR/DRIVE',13,10 db 13,10,9,'Usage: C:\PROGRA~1\FILENAME.ASM',13,10,13,10 db 13,10,9,'File name to SHRED --> $'
not_there db 13,10,13,10,13,9,'File not present.',13,10,'$' emsg2 db 13,10,13,10,'Error moving file pointer.',13,10,'$' emsg3 db 13,10,13,10,'Error writing to file.',13,10,'$' done_msg db 13,10,13,10,'File has been shredded.',13,10,'$' eraser_name db 'àáâãäåæç.',0
.code
start: mov ah,15 ; clear the screen int 10h mov ah,0 int 10h
mov ax,@data mov ds,ax mov es,ax ; need for LFN functions mov bx,00h ; write zeros into memory
zero_out: ; Set memory to zero mov [random + bx],00h inc bx cmp bx,64000 jnz zero_out mov dx, offset prompt mov ah,9 int 21h mov file_name,128 ; max characters in input mov dx,offset file_name; get filename mov ah,0ch ; flush keyboard buffer mov al,0ah ; buffered keyboard input int 21h mov cl,[file_name + 1] ; how many bytes read in add cl,2 ; find position after last character mov ch,00 mov si,cx ; move count to index register mov [name_size],cx ; save size mov file_name[si],00 ; make into ASCII string ; Change any read-only attribute
change: lea dx,file_name + 2 mov ax,4301h mov bl,01h ; set attributes ;Bitfields for file attributes: (CX register) ;Bit(s) Description (Table 01420) ; 7 shareable (Novell NetWare) ; 7 pending deleted files (Novell DOS, OpenDOS) ; 6 unused ; 5 archive ; 4 directory ; 3 volume label ; execute-only (Novell NetWare) ; 2 system ; 1 hidden ; 0 read-only mov cx,00000000b ; remove read-only attribute int 21h
;INT 21 - Windows95 - LONG FILENAME - CREATE OR OPEN FILE ; AX = 716Ch ; BX = access mode and sharing flags (see #01782,also AX=6C00h); ; CX = attributes ; DX = action (see #01781) ; DS:SI -> ASCIZ filename
open_it:
mov ax,716Ch ; create file xor cx,cx ; file attributes
; file access modes (bits) BX register ; 000 read-only ; 001 write-only ; 010 read-write ; 100 read-only, do not modify file's last-access time
; Bitfields for Windows95 long-name open action: DX Register ; Bit(s) Description (Table 01781) ; 0 open file (fail if file does not exist) ; 1 truncate file if it already exists (fail if file does not exist) ; 4 create new file if file does not already exist (fail if exists) ; Note: the only valid combinations of multiple flags are bits 4&0 and 4&1
mov bx,00000001b ; access mode - write only mov dx,00000001b ; open file lea si,file_name + 2 ; sets the file name int 21h mov [handle],ax ; Save file handle jnc short get_size ; No errors, go on no_file: mov dx,offset not_there; Get error message jmp error ; and go display/exit get_size: mov ax,4202h ; Set file pointer mov bx,[handle] ; for this file xor cx,cx ; relative to end of file xor dx,dx ; offset 0 bytes int 21h jnc save_size err2: mov dx,offset emsg2 ; Get error message jmp error ; and go display/exit
save_size: mov word ptr [file_size],ax ; Save low word of file size mov word ptr [file_size + 2],dx ; Save high word
mov ax,4200h ; Move file pointer mov bx,[handle] ; for this file xor cx,cx ; relative to beginning of file xor dx,dx ; offset 0 bytes int 21h jc err2 ; Errors: go handle
next_bunch: mov cx,64000 ; Assume 64,000 bytes or more ; left to do
sub word ptr [file_size],cx ; Is there ? - subtract it sbb word ptr [file_size + 2],0 ; from saved file size
jae wipe ; There were 64,000 bytes or ; more left mov cx,word ptr [file_size] ; Get number of bytes left add cx,64000 ; back CX (undo subtraction)
wipe: mov ah,40h ; Write file mov bx,[handle] ; Handle lea dx,random ; Write the random bytes int 21h jnc check_size ; No errors, go on
err3: mov dx,offset emsg3 ; Get appropriate error message jmp error ; and go display/exit
check_size: cmp ax,cx jnz err3 cmp ax,64000 ; Full 64,000 bytes written, je next_bunch ; yes, go check for more jmp SHORT $+2 ; short delay cuz sometimes ; file isn't renamed ; mov bx,[handle] ; close file mov ah,3eh int 21h
trunc:
; Truncate file to zero bytes
mov ah,3ch ; truncate file to zero bytes mov cx,0 mov dx,offset file_name + 2 int 21h mov bx,[handle] ; close file mov ah,3eh int 21h ; Store the path
scan: lea si,[file_name + 2] xor cx,cx mov di,si mov cx,[name_size]
mov al,'\' add di,cx std ; scan from right to left dec di repne scasb jnz short no_path ; No slash is present add cx,1 ;
no_path: mov di,offset storage cld ; change directions and scan rep movsb ; from left to right mov al,00 stosb ; make path ASCIZ ;STOP ; Add on eraser_name to end of storage
add_eraser:
mov cx,[name_size] mov si,cx lea di,storage mov al,00 ; stops at the byte after the "00" repnz scasb dec di ; backup one
xor cx,cx mov si,offset eraser_name mov cx,9 ; # of characters rep movsb
; Rename and delete file (LFN)
rename: mov dx,offset file_name + 2 ; old file name mov di,offset storage mov ax,7156h ; LFN support int 21h
; Change file date and time
mov ax,716Ch ; open file xor cx,cx ; file attributes
; file access modes (bits) FOR BX Register ; 000 read-only ; 001 write-only ; 010 read-write ; 100 read-only, do not modify file's last-access time ; set bit 14 - commit file after every write operation
mov bx,00000000000000010b ; access mode (R/W) mov dx,1 ; open file lea si,storage ; sets the file name int 21h mov bx,ax ; save file handle push bx
mov ax,5701h ; change file date ; BITS 5-10 are minutes, 11-15 are hours mov cx,677dh ; 12:59:58 pm 110011101111101b ; ; BITS 0-4 are day, 5-8 are month, 9-15 (year - 1980) mov dx,021h ; 1/1/80 0000000000100001b int 21h
pop bx
;INT 21 U - DOS 4.0+ - COMMIT FILE ; AH = 6Ah ; BX = file handle
mov ah,6ah ; make sure this file is written to disk int 21h
mov ah,3eh ; close file int 21h
; INT 21 - Windows95 - LONG FILENAME - DELETE FILE ; AX = 7141h ; DS:DX -> ASCIZ long name of file to delete
mov dx,offset storage ; delete file mov ax,7141h xor si,si int 21h ; idea from Fauzan Mirza xor ax,ax ; Zero out file_name mov di,offset storage + 2 mov cx,150 rep stosb
finito: mov ah,9 mov dx,offset done_msg int 21h mov ax,4c00h ; Set errorlevel to 0 int 21h error: mov ah,9 int 21h mov ax,4c01h ; Set errorlevel to 1 int 21h
end start
Have a great day, Andy http://intouch.org/magazine/daily-devotionalhttp://www.happynews.com
|
|
|
Logged
|
Have a great day, Andy
|
|
|
dedndave
|
ok - let's get you where you can assemble - lol
the program you posted assembles fine for me (although, you should stay with @DATA) so, you are probably using a different linker or batch file than i am
here is how i have my system set up
1) i have installed masm32 as C:\masm32
2) in the masm32 folder, a subfolder is created called bin (C:\masm32\bin) this is where executables go, including batch files make sure you have A16.BAT and LINK16.EXE in that folder i have attached a zip than contains all the files you need note: my copy of A16.BAT has been modified to create assembler listings
3) there is an environment variable called PATH this variable is likely already created, and includes a few to several path-names these paths are seperated by a semicolon somewhere in that variable, you want to add C:\masm32\bin seperated from the other paths with semicolons
a) My Computer - Properties Advanced tab Environment Variables button the bottom window is for System variables - this is the best place to add this path find the Path variable in that list and modify it as mentioned above
4) in the masm32 folder, i have created a woking folder named Asm (C:\masm32\Asm) this is where i play around with programs that are too small to require a project folder of their own place the ASM file in that folder open a console window and change to that directory from there, you should be able to use A16 to assemble 16 bit programs:
A16 MyProg
the .ASM file extension is not required
from there, you may use a debugger to step through the program i have included SymDeb.exe place it in the masm32\bin folder, as well
SymDeb MyProg.exe
after that, you may use the "T" command to step through the program - "Q" to exit
note: in the attached archive, i have included your program i have changed it to use .DATA, .CODE, and @DATA
|
|
|
Logged
|
|
|
|
|
Pages: [1]
|
|
|
 |