2013년 3월 15일 금요일

[asm]DTA


DTA - Disk Transfer Area (partially undocumented)

 DTA contains data, of which the first 21 bytes (00-15h) are known
 as being "reserved for DOS use on subsequent find next calls"

     Offset Size    Description

 00   byte attribute of search (undocumented)
 01   byte drive used in search  (undocumented)
 02  11bytes search name used (undocumented)
 0D   word directory entry number (0 based, DOS 3.x+, undoc.)
 0F   word starting cluster number of current directory
   zero for root directory (DOS 3.x+, undocumented)
 11   word reserved (undocumented)
 13   word starting cluster number of current directory
   zero for root directory (DOS 2.x+, undocumented)
 15   byte attribute of matching file
 16   word file time  (see FILE ATTRIBUTES)
 18   word file date  (see FILE ATTRIBUTES)
 1A   word file size
 1E 13bytes ASCIIZ filename and extension in the form NAME.EXT
   with blanks stripped


 - fields of DTA change dependent upon function call in progress
 - the DTA cannot span a 64K segment boundary
 - for compatibility with CP/M the default DTA is at offset 80h
   in the PSP;  this area is also used for the command tail. To
   avoid collision, set another DTA (INT 21,1A) or preserve the
   command tail before using FCB function calls

 - see  INT 21,4E  INT 21,1A  INT 21,2F

2013년 3월 13일 수요일

[asm]win32 helloworld

.386
.MODEL flat, stdcall
.STACK 4096


;include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib


STD_OUTPUT_HANDLE EQU -11

GetStdHandle PROTO,
  nStdHandle:DWORD

WriteConsole EQU 

ExitProcess PROTO,
 dwExitCode:DWORD

.data
consoleOutHandle dd ?
bytesWritten   dd ?
message db "Hello World", 13, 10, 0

.code
ProcStrLength PROC USES edi,
    ptrString:PTR BYTE
 mov edi, ptrString
 mov eax, 0
L1:
 cmp byte ptr [edi], 0
 je  L2
 inc edi
 inc eax
 jmp L1
L2: ret
procStrLength ENDP

ProcWriteString proc
 pushad

 INVOKE procStrLength, edx
 cld

 INVOKE WriteConsole,
     consoleOutHandle,
     edx,
     eax,
     offset bytesWritten,
     0
 
 popad
 ret
procWriteString endp

main PROC
 INVOKE GetStdHandle, STD_OUTPUT_HANDLE

 mov [consoleOutHandle], eax

 mov edx, offset message

 INVOKE procWriteString

 INVOKE ExitProcess, 0

main ENDP

END main



compile ml /c /coff link link /subsytem:console

2013년 3월 8일 금요일

2013년 3월 7일 목요일

[asm]win32api

masm32 다운로드
.386
.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
 HelloWorld db "Hello World!", 0
.code
start:
 invoke MessageBox, NULL, addr HelloWorld, addr HelloWorld, MB_OK
 invoke ExitProcess, 0
end start
ml /c /coff hellowin.asm link /subsystem:windows hellowin.obj