Results 1 to 4 of 4

Thread: Assembly??? - hmmm..

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409

    Question

    Can anyone explain what assembly is(i heard it was a kind of low-level programing language),is it difficult,can it create standalone EXE files and in what application can i write asssembly.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    With asm, you are directly controlling the CPU at the instruction level, so you can create very small, very fast programs. You need something similar to MASM to write in assembly.

    Although you can write 'inline' asm into a C/C++ program. Have a look through some of the threads in the Assembly forum here for more details.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    I really want to learn ASM,
    here is an example of a VB Form that Yonaton Gave me, it writes ASM to a Com file, opens the CDROM Drive, then deletes the file.

    Code:
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   3195
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton cmdEject 
          Caption         =   "Command1"
          Height          =   495
          Left            =   1740
          TabIndex        =   1
          Top             =   1440
          Width           =   1215
       End
       Begin VB.DriveListBox drvList 
          Height          =   315
          Left            =   420
          TabIndex        =   0
          Top             =   900
          Width           =   3735
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    
    Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
    Private Const SYNCHRONIZE = &H100000
    Private Const PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
    Private Const INFINITE = &HFFFFFFFF
    
    Private Sub cmdEject_Click()
        Dim lProcessID As Long, hProcess As Long
        Dim bFile(1 To 17) As Byte, bFileNum As Byte, bDriveNum As Byte, sFileName As String
        ' 1 To 17 because the assembly code takes up 17 bytes of disk space.
        
        If Caption = "Busy..." Then Exit Sub
        Tag = Caption
        Caption = "Busy..."
        cmdEject.Enabled = False
        DoEvents ' Update caption
        
        ' First lets get the DriveNum.
        ' The upper case of the first word in drvList.Drive is A, or B, etc.
        ' ASCII codes: A = 65, B = 66, etc. Requested: A = 1, B = 2, etc.
        ' We just need to decrement 64 from the ASCII code.
        bDriveNum = Asc(UCase(Left(drvList.Drive, 1))) - 64
        
        ' mov ax, 440Dh
        ' "mov ax" = B8
        ' Then the source 440D in little-endian format: 0D 44
        ' "mov ax, 440Dh" = B8 0D 44
        bFile(1) = &HB8
        bFile(2) = &HD
        bFile(3) = &H44
        
        ' mov bx, DriveNum
        ' "mov bx" = BB
        ' Then the source DriveNum in little-endian format.
        ' Since DriveNum is a number between 1 and 26, its high byte will ALWAYS be zero.
        ' Since this is a little-endian system, first goes the low byte, then the high byte.
        ' So DriveNum can be expressed like this: [bDriveNum] 00
        ' "mov bx, DriveNum" = BB [bDriveNum] 00
        bFile(4) = &HBB
        bFile(5) = bDriveNum
        bFile(6) = &H0
        
        ' mov ch, 8
        ' "mov ch" = B5
        ' Then the source 8 is one byte... Just: 08
        ' "mov ch, 8" = B5 08
        bFile(7) = &HB5
        bFile(8) = &H8
        
        ' mov cl, 49h
        ' "mov cl" = B1
        ' Then the source 49 is again, one byte... Just: 49
        ' "mov cl, 49h" = B1 49
        bFile(9) = &HB1
        bFile(10) = &H49
        
        ' int 21h
        ' "int" = CD
        ' The interrupt 21h is just one byte: 21
        ' "int 21h" = CD 21
        bFile(11) = &HCD
        bFile(12) = &H21
        
        ' mov ax, 4C00h
        ' "mov ax" = B8
        ' Then the source 4C00 in little-endian format: 00 4C
        ' "mov ax, 4C00h" = B8 00 4C
        bFile(13) = &HB8
        bFile(14) = &H0
        bFile(15) = &H4C
        
        ' int 21h
        ' Didn't change since before: CD 21
        bFile(16) = &HCD
        bFile(17) = &H21
        
        ' Now that we are done with converting the source code to hex,
        ' we can save the data to a .com file and run it.
        sFileName = App.Path
        If Not Right(sFileName, 1) = "\" Then sFileName = sFileName & "\"
        sFileName = sFileName & "eject.com"
        
        bFileNum = FreeFile
        Open sFileName For Binary As bFileNum
            Put bFileNum, , bFile() ' Write Assembly data
        Close bFileNum
        
        lProcessID = Shell(sFileName, vbHide) ' Execute it, hidden from the user
        
        On Error Resume Next
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, lProcessID) ' Open the process
        If hProcess = 0 Then ' Already ended. Happens
            Call Kill(sFileName)
            Exit Sub
        End If
        Call WaitForSingleObject(hProcess, INFINITE) ' Wait for it to end
        Call CloseHandle(hProcess) ' Close the process handle
        
        Call Kill(sFileName) ' Destroy the file
        
        cmdEject.Enabled = True
        Caption = Tag
    End Sub
    paste that into a text file, and give it a .frm extension
    name is Form1 BTW.

  4. #4

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409

    Talking

    Thanks denniswrenn
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width