in Search
     
Latest post 03-19-2007 1:44 AM by modchip. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-13-2007 8:09 AM

    Help me please in assembly

    Hi., is there anyone could help me about my project?! i have to code 5 dos commands written in assembly language. I dont know how, i am using tasm and tlink as my assembly and linker.. thanks..
    Jeric John Romero 4th yr-BS Information Technology Adamson University
    • Post Points: 35
  • 03-13-2007 8:18 PM In reply to

    • relsoft
    • Top 50 Contributor
    • Joined on 03-12-2007
    • Iloilo City
    • Posts 52
    • Points 815

    Re: Help me please in assembly

    What DOS commands?

    Hello
    • Post Points: 5
  • 03-13-2007 8:43 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    Re: Help me please in assembly

    Yes, please elaborate a bit more so that we could help you. :D Do you mean that you'll recreate 5 DOS commands using the asm from scratch - ex. DIR, COPY, FORMAT... ETC? It could also really help if you use MASM, because majority of us use this assembler.

    Filed under:
    • Post Points: 20
  • 03-13-2007 9:57 PM In reply to

    • cruizer
    • Top 10 Contributor
    • Joined on 12-14-2005
    • Singapore
    • Posts 944
    • Points 22,590

    Re: Help me please in assembly

    in the DOS world, MASM and TASM are of equal capability. it wouldn't matter if you use one or the other. TASM also has a MASM compatibility mode.
    http://devpinoy.org/blogs/cruizer
    Naglalayong buksan at palayain ang kamalayan ng Pinoy .NET developer
    • Post Points: 20
  • 03-15-2007 8:29 AM In reply to

    Re: Help me please in assembly

    @modchip

    yes, sir. DIR, COPY, DEL, DATE, .. Actually I have one, the exit command.. ehehe. I dont understand the lectures of our prof that's why I cannot program those command. If someone could give a could it's better but if no, its ok. If I cannot code that DOS commands, is it possible to include/call that??

     

    Jeric John Romero 4th yr-BS Information Technology Adamson University
    • Post Points: 20
  • 03-15-2007 8:48 AM In reply to

    • relsoft
    • Top 50 Contributor
    • Joined on 03-12-2007
    • Iloilo City
    • Posts 52
    • Points 815

    Re: Help me please in assembly

    Answer
    Well it's been a while... but here's what I could find from my old sources.. (uses DTA (data transfer address)


    .Model Medium, BASIC
    .386

    ;;;
    ;;; Disk Transfer Address 43 byte buffer.
    DTAstruct struc
    Reserved db 21 dup(?) ;20h reserved for subsequent search
    Attrib db ? ;File Attribute
    FileTime dw ? ;Yeah
    FileDate dw ? ;Right...
    FileSize dd ? ;guess...
    FileName db 13 dup(?) ;8char+.+type. followed by Hex0(20h)
    DTAstruct Ends


    .Data
    Align 2
    DTA DTAstruct<> ;huh?


    .Code

    Public xRelFindFile
    XRelFindFile Proc Uses Ds si es di,\
    MaskSeg:Word, MaskOff:Word, FileSeg:Word, FileOff:Word, Attribute: Word


    mov ds, MaskSeg
    mov si, MaskOff
    mov dl, ds:[si]
    or dl, dl
    jz @NextFile
    ;;
    ;;Int 21h Dta
    ;;ah=1ah
    ;;DS:DX= pointer to DTA in memory
    mov ax, @data ;DTA seg
    mov ds, ax
    mov dx, offset DTA
    mov ah, 1ah ;Set disk transfer addy
    xor al,al
    Int 21h ;do it

    ;;;ah= 4eh
    ;;;cx= attrib
    ;;;ds:dx =addy of the fiename
    ;;;Carry Flag=return value
    mov ds, MaskSeg
    mov dx, MaskOff
    mov cx, Attribute
    mov ax, 4e00h ;load subfunction and clear al
    Int 21h ;Fill DTA
    jc @Error
    jmp @WritetoString
    @NextFile:
    ;;;Find Next matching file
    ;;;ah=4fh
    ;;;don't touch dta
    ;;;for subsequent search ie. reserved
    mov ax, 4f00h ;load subfunction and clear al
    Int 21h ;Fill DTA
    jc @Error

    @WritetoString:

    mov ax, @data
    mov ds, ax
    mov si, offset DTA
    add si, 30 ;offset at filename in DTA type
    mov es, FileSeg
    mov di, FileOff
    mov cx,13
    @NextByte:
    mov al, ds:[si]
    or al,al
    jz @EndWrite
    mov es:[di],al
    inc si
    inc di
    dec cx
    jnz @nextByte

    @EndWrite:

    ;Fill DTA.Filename with 20h for subsequent search
    mov ax, @data
    mov es, ax
    mov di, offset DTA
    mov al, 20h
    add di, 30
    mov cx, 13
    rep stosb
    Ret

    @Error:
    mov es, FileSeg
    mov di, FileOff
    sub al,al
    Stosb
    Ret

    endp

    END


    Call that with "*.*" + attrib and you could simulate DIR.

    As for date you could prolly read the ROM BIOS at FFF5h, as cor copy, the only way I could think of right now is to read the source and do a direct byte by byte copy.



    Hello
    • Post Points: 5
  • 03-15-2007 8:56 AM In reply to

    • relsoft
    • Top 50 Contributor
    • Joined on 03-12-2007
    • Iloilo City
    • Posts 52
    • Points 815

    Re: Help me please in assembly

    Oh I found this old prog I made for some IT students...

    This is a stop clock but gets it's values from the system time. I have assembled this in TASM and Linked via TLINK.

    .model small ; data segment < 64k, code segment < 64k
    .stack 200h ; set up 512 bytes of stack space
    .386

    .data


    ;Constants
    time_row equ 8
    time_col equ 8


    ;Variables

    topline db 0dah, 38 dup(0c4h),0bfh
    midline db 0b3h, 38 dup(32),0b3h
    botline db 0c0h, 38 dup(0c4h),0d9h

    timebox db 0c9h, 12 dup(0cdh),0bbh
    db 0bah, 12 dup(" "), 0bah
    db 0bah, 12 dup(" "), 0bah
    db 0bah, 12 dup(" "), 0bah
    db 0c8h, 12 dup(0cdh),0bch

    ; 1 2 3 4
    ;1234567890123456789012345678901234567890112345678901234567890123456789012345678901"
    xtitle db "
    *** STOP WATCH ***"
    zerotime db "
    00:00:00:00$"

    inst db "
    [r] = resets timer"
    db "
    [p] = pauses timer"
    db "
    [q] = quits "

    attrib db 0

    msecs db 0
    secs db 0
    mins db 0
    hours db 0

    choice db 0
    ; 1 2 3 4
    ;1234567890123456789012345678901234567890112345678901234567890123456789012345678901"

    names db " Submitted by: "
    db " "
    db " "
    db " "
    db " "



    .code

    ;*****************************************************************
    PrintChar Macro aschar
    pusha
    mov al, aschar
    mov ah, 0ah
    mov bh, 00
    mov cx, 1
    int 10h
    popa
    EndM PrintChar

    ;*****************************************************************
    ;Prints a string on the screen
    Print Macro Message
    pusha
      xor ax,ax
      mov ah, 09h     ;print interrupt 21, 9
      lea dx, message      ;Load Effective Address(offset)
      int 21h        ;print it
      popa
    EndM Print
    ;*****************************************************************
    CursorOFF Macro
    pusha
    mov ah, 01 ;disable cursor
    mov cx, 2000h
    int 10h ;disable it baby
    popa
    EndM CursorOFF
    ;*****************************************************************
    CursorON Macro
    pusha
    mov ah, 01 ;enable cursor
    mov cx, 0005h
    int 10h ;enable it baby
    popa
    EndM CursorON
    ;*****************************************************************
    ;sets the cursor at row col
    Locate Macro row, col
    pusha
    mov ah, 02h        ;int 10, 2
    xor bx, bx ;bx should be zero
    mov dh, row        ;dh=row, dl = column
    mov dl, col
    int 10h        ;do it
    popa
    EndM Locate

    ;*****************************************************************
    ;reads the keyboad buffer
    Input Macro
      ;needs ax to be unused
      ;returns in AH the scancode
      ;returns in AL the asciicode
      mov ah, 10h ; check for input
      int 16h
    EndM Input

    ;*****************************************************************
    PrintChar Macro aschar
    pusha
    mov al, aschar
    mov ah, 0ah
    mov bh, 00
    mov cx, 1
    int 10h
    popa
    EndM PrintChar

    ;*****************************************************************
    ;needs: ES:BP >>> Pointer to string
    ;cx >> numchars
    PrintString macro row, col,attrib, numchars
    pusha
    mov ax, 1301h ;request display
    mov bl, attrib ;attrib
    mov bh, 0 ;page
    mov dh, row
    mov dl, col
    mov cx, numchars
    int 10h
    popa
    endm printstring


    ;*****************************************************************

    draw_box Macro
    local x_loop
    pusha
    mov attrib,00110100b
    lea bp, topline
    PrintString 0,0,attrib, 40
    lea bp, midline
    mov cx, 22
    xor ch,ch
    x_loop:
    PrintString cl,0,attrib,40
    loop x_loop
    lea bp, botline
    PrintString 23,0,attrib, 40
    popa
    endm draw_box


    ;*****************************************************************
    ;this waits for screen retrace/refresh or our demo being in ASM
    ;would as fast as an x-wing on steroids. :*)

    waitretrace proc
    mov dx,03dah ;0x3da9 vertical retrace port

    wret:
    in al,dx
    and al,08h    ; is vga in retrace?
    jnz wret
    wref:
    in al,dx
    and al,08h    ;is retrace finished?
    jz wref


    ret
    waitretrace endp

    ;*****************************************************************

    textmode proc
    mov ah, 00h ;set video mode
    mov al, 01h ;mode 40*25
    int 10h ;enter 80x25x16 mode
    ret
    textmode endp

    ;*****************************************************************
    ClearScreen Proc
      pusha        ;preserve general regs
      mov ax, 0600h      ;int 10, 6(scroll screen)
      mov bh, 0Fh      ;color white on Black
      mov cx, 0000      ;row0,col0
      mov dx, 1828h      ;25,80
      int 10h ;scroll(clear it)
      popa        ;restore regs
      ret
    ClearScreen Endp

    ;*****************************************************************
    ;*****************************************************************
    ;*****************************************************************
    ;*****************************************************************
    ;*****************************************************************
    ;*****************************************************************
    ;Main proggie

    start:
    mov ax,@data       ;data seg
    mov ds, ax
    mov es, ax

    call textmode     ;set to textmode
    CursorOff

    draw_box ;draw box
    lea bp, xtitle ;print the title
    printstring 3, 11, 10011110b,18


    mov dl,8 ;start row
    mov cx, 5 ;5 rows of inner box
    mov attrib, 00111110b
    lea bp, timebox ;address fo timebox
    timebox_loop:
    printstring dl, 12, attrib,14 ;print each line
    add bp, 14 ;add offset of len(line)
    inc dl ;inc column
    loop timebox_loop ;loop until cx = 0



    mov dl, 15
    mov attrib, 01010000b ;print [r]
    lea bp, inst
    printstring dl, 11, attrib,18
    add dl, 2 ;print [p]
    add bp, 18
    printstring dl, 11, attrib,18
    add dl, 2 ;print [q]
    add bp, 18
    printstring dl, 11, attrib,18


    mov msecs, 0 ;init all values to zero
    mov secs, 0
    mov mins, 0
    mov hours, 0

    timeloop:
    mov ah, 2ch ;get system time
    mov al, 00 ;ch = hours
    ;cl = minutes
    ;dh = seconds
    ;dl = hundreths of sec
    int 21h


    cmp msecs, dl ;msecs <> dl
    je go_on ;equal so don't do anything
    inc msecs ;increase msecs
    cmp msecs, 99 ;>99?
    jle no_add_secs ;no so dont increase seconds
    mov msecs,0
    inc secs
    no_add_secs:
    cmp secs, 59
    jle no_add_mins
    mov secs, 0
    inc mins
    no_add_mins:
    cmp mins, 59
    jle no_add_hours
    mov mins, 0
    inc hours
    no_add_hours:

    print_timer:

    xor ah, ah ;mov ah, 0
    mov al, hours ;put number of hours to al
    mov bl, 10 ;put 10 to bl
    div bl ;ax = ax /10 ah= rem, al= quotient
    or al, 30h ;covert to ascii
    or ah, 30h
    locate 10, 14 ;row 10, col 14
    printchar al ;quotient
    locate 10, 15 ;row 10, 15
    printchar ah ;print ramainder


    locate 10, 16
    printchar ":"

    ;;
    ; minutes
    ;

    xor ah, ah
    mov al, mins
    mov bl, 10
    div bl
    or al, 30h
    or ah, 30h
    locate 10, 17
    printchar al
    locate 10, 18
    printchar ah

    locate 10, 19
    printchar ":"


    ;seconds
    xor ah, ah
    mov al, secs
    mov bl, 10
    div bl
    or al, 30h
    or ah, 30h
    locate 10, 20
    printchar al
    locate 10, 21
    printchar ah

    locate 10, 22
    printchar ":"


    ;hundreths of a second
    xor ah, ah
    mov al, msecs
    mov bl, 10
    div bl
    or al, 30h
    or ah, 30h
    locate 10, 23
    printchar al
    locate 10, 24
    printchar ah


    go_on:

    mov ah, 01h ;check for keypress
    int 16h ;is a key waiting in the buffer?
    ;ah = scan code
    ;al = ascii
    jz timeloop ; no key pressed go back

    input

    ;;
    mov choice, al ;store ascii code
    cmp choice, "r" ;reset?
    je reset_timer ;yes so reset timer
    cmp choice, "p" ;pause?
    je pause_timer ;yes so pause it

    cmp choice, "q" ;quit?
    je exit ;yes so exit
    jmp timeloop ;valid input so return

    pause_timer:
    input ;pause
    jmp timeloop
    reset_timer:
    mov msecs, 0 ;set all vars to zero
    mov secs, 0
    mov mins, 0
    mov hours, 0
    locate 10, 14
    print zerotime
    input
    jmp timeloop
    exit:
    draw_box ;draw box
    mov dl, 8 ;start row
    mov attrib, 10011110b
    lea bp, names
    mov cx, 5
    name_loop:
    printstring dl, 9, attrib, 20 ;print 20 chars
    add bp, 20 ;next offset
    inc dl ;inc row
    loop name_loop ;go back until cx = 0
    input ;wait for key
    mov ah, 4ch
    mov al, 00h
    int 21h ;return to dos

    end start


    Hello
    • Post Points: 20
  • 03-19-2007 1:44 AM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    Re: Help me please in assembly

    Chris posted some source that is ALMOST close to the solution of your problem. Maybe you could pick up a thing or 2. Here's the link: http://devpinoy.org/forums/thread/8504.aspx Good luck! :D

    Filed under:
    • Post Points: 5
Page 1 of 1 (8 items)