Recent Posts

Pages: [1] 2 3 ... 10
2
16 bit DOS Programming / Re: a little help with my x86 assembly book
« Last post by ahmedES on Today at 03:19:36 PM »
thanks felipe , i compiled and linked it with these command and it worked
Code: [Select]
ml /c /omf  file.asm
link16  file.obj,,,,,
now i'm willing to convert it to 32-bit flat module and i have a question , what should i use instead of DOS system interrupts ?
3
16 bit DOS Programming / Re: a little help with my x86 assembly book
« Last post by felipe on Today at 02:45:52 PM »
This is 16 bit code.

Code: [Select]
;swap_bytes.asm
;-----------------------------------------------------------
.STACK
;-----------------------------------------------------------
.DATA
TEMP DB ?
RSLT DB 0DH, 0AH, 'BL = , BH = ',$                   ;$ sign is a delimiter meaning end of string
;-----------------------------------------------------------
.CODE
BEGIN PROC FAR 
MOV AX, @DATA               ;set up pgm ds
MOV DS, AX ;place the .DATA addr in ax
                   ;set up data seg addr for this pgm
                   
MOV BL,'A'                     ;assign values to bl and bh
MOV BH, 'B'
MOV TEMP, BL              ;store bl in temp area before swapping
MOV  BL, BH               ;swap registers
MOV   BH, TEMP               
MOV   RSLT + 7, BL            ;move registers to result area for display
MOV   RSLT + 15, BH
MOV  AH, 09H         ;print result, display string
MOV   DX, OFFSET RSLT       ;rslt addr must be in dx
INT   21H              ;a dos interrupt that uses
                           ;a fctn code in ah
BEGIN ENDP
END   BEGIN      ;start pgm at begin

You can use masm and a 16 bit linker. And maybe try to run the program in a DosBox emulator program (DosBox). But i don't recall the exactly syntax for the assembler (command lines options for the assembler and the linker).
Btw, welcome to the forum. If you want you can start to learn 32 bit assembly language and in this great forum (with the masm32 sdk package) you will get a great time!
4
16 bit DOS Programming / a little help with my x86 assembly book
« Last post by ahmedES on Today at 02:28:40 PM »
hi all
currently i'm reading "X86 Assembly Language and C Fundamentals" by Joseph Cavanagh and i have some questions that i cant find its answer in the book
first the author focused on c inline assembly, he also showed how to write it in only assembly but he dosent tell how to compile or link these assembly programm, he doesnt even tell which assembler we should use
here is the syntax of the first programm
Code: [Select]
;swap_bytes.asm
;-----------------------------------------------------------
.STACK
;-----------------------------------------------------------
.DATA
TEMP
DB ?
;$ sign is a delimiter meaning end of string
RSLT
DB 0DH, 0AH, 'BL = , BH = $'
;-----------------------------------------------------------
.CODE
BEGIN
PROC FAR
;set up pgm ds
MOV
AX, @DATA
MOV
DS, AX
;place the .DATA addr in ax
;set up data seg addr for this pgm
;assign values to bl and bh
MOV
BL,'A'
MOV
BH, 'B'
;store bl in temp area before swapping
MOV
TEMP, BL
;swap registers
MOV
BL, BH
MOV
BH, TEMP
;move registers to result area for display
MOV
RSLT + 7, BL
MOV
RSLT + 15, BH
;print result
MOV
AH, 09H
;display string
MOV
DX, OFFSET RSLT ;rslt addr must be in dx
INT
21H
;a dos interrupt that uses
;a fctn code in ah
BEGIN ENDP
END
BEGIN
;start pgm at begin

and it equlivant C code
Code: [Select]
#include "stdafx.h"
char main (void)
{
char temp;
char rslt1, rslt2;
//switch to assembly
_asm
{
MOV
BL, 'A'
MOV
BH, 'B'
//swap bytes
MOV
temp, BL
MOV
rslt1, BH
MOV
BH, temp
MOV
rslt2, BH
}
//print result
printf ("BL = %c, BH = %c\n", rslt1, rslt2);
return 0;
}
which memory mode this asm program written for ? how do i compile and link with masm ?
5
The Workshop / Re: In the gui path...
« Last post by felipe on Today at 02:19:34 PM »
I had been very bussy, but now i have more time to work on my codings. Here it is a premature version of what should be a more complete version of the next example program just based in the book. Remember, just based, is not a copy, it's just a guide.
The .exe is attached.

Code: [Select]
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; This program was started by Felipe at 2017-12-12.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

.386
.model      flat,stdcall
option      casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\gdi32.inc
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\gdi32.lib



.data
align 1
claname     byte        "TEXT CLASS",0
wndname     byte        "A WEIRD TEXT-GRAPHIC (WHAT?) PROGRAM JUST FOR ALL OF YOU!",0
textmsg     byte        "Hello friends, this is a very simple program. You can see it, hate it or laught of it."
            byte        "It's your choice...                                                                   "
            byte        "I'm working with that old (may i say old?) book from Petzold, but i had to write this "
            byte        "before  i finish the example that i'm studying.                                       "
            byte        "In my opinion, or IMHO, GDI looks pretty cool stuff.                                  "
            byte        "I hope you can visualize this text closely to normal, since i'm not trying to adjust  "
            byte        "in the program nothing related to your system metrics. Sorry for that, you know i'm a "
            byte        "beginner.                                                                             "
            byte        "Hey, i had an idea!: From now on all my post and replies will be in a window program  "
            byte        "like this one, with my opinions hardcoded in a text like this...                      "
            byte        "You will have to download them and ...HAHAHAHA!!! You will hate me more, right?       "                                       
            byte        "Ok, no more jokes.                                                                    "


.data?
align 4
hmodule     dword       ?
wndclaex    dword       12 dup(?)                                                       ; The WNDCLASSEX structure.
hwnd        dword       ?
msgstru     dword       7 dup(?)                                                        ; The MSG structure.
hdc         dword       ?
paintstru   dword       12 dup(?)                                                       ; The PAINTSTRUCT structure. 


.code
align 4
start:
            push        NULL
            call        GetModuleHandle
            mov         hmodule,eax

            mov         dword ptr wndclaex[0],sizeof wndclaex
            mov         dword ptr wndclaex[4],CS_HREDRAW or CS_VREDRAW
            mov         dword ptr wndclaex[8],wndproc
            mov         dword ptr wndclaex[12],0
            mov         dword ptr wndclaex[16],0
            mov         wndclaex[20],eax
            push        500
            push        eax
            call        LoadIcon
            mov         wndclaex[24],eax
            push        IDC_ARROW
            push        NULL
            call        LoadCursor
            mov         wndclaex[28],eax
            push        WHITE_BRUSH
            call        GetStockObject
            mov         wndclaex[32],eax
            mov         dword ptr wndclaex[36],NULL
            mov         dword ptr wndclaex[40],offset claname   
            mov         dword ptr wndclaex[44],NULL

            push        offset wndclaex
            call        RegisterClassEx

            push        NULL
            push        hmodule
            push        NULL
            push        NULL
            push        CW_USEDEFAULT
            push        CW_USEDEFAULT
            push        CW_USEDEFAULT
            push        CW_USEDEFAULT
            push        WS_OVERLAPPEDWINDOW
            push        offset wndname       
            push        offset claname
            push        WS_EX_OVERLAPPEDWINDOW
            call        CreateWindowEx
            mov         hwnd,eax

            mov         esi,eax

            push        SW_SHOWNORMAL
            push        esi
            call        ShowWindow

            push        esi
            call        UpdateWindow

            mov         esi,offset msgstru


align 4
msgloop:

            push        0
            push        0
            push        NULL
            push        esi
            call        GetMessage
            cmp         eax,0
            jz          endmsglop

            push        esi
            call        TranslateMessage

            push        esi
            call        DispatchMessage

            jmp         msgloop


align 4
endmsglop:
           
            push        dword ptr[esi+8]
            call        ExitProcess


align 4
wndproc:

            push        ebp
            mov         ebp,esp
         
            cmp         dword ptr[ebp+12],WM_PAINT
            jne         destroy

            push        offset paintstru
            push        hwnd
            call        BeginPaint
            mov         hdc,eax

            push        00e00000h                                                           ; Blue color for the text.
            push        eax
            call        SetTextColor

            mov         esi,offset textmsg
            xor         edi,edi                                                             ; The y coordinate.
            mov         ebx,12                                                              ; Number of lines.
           
         


align 4
allstri:
            push        86                                                                  ; Number of characters per line.
            push        esi                                                                 ; Line addresses.   
            push        edi                                                                 ; Y coordinate.   
            push        0                                                                   ; X coordinate.
            push        hdc
            call        TextOut
           
            add         edi,25                                                              ; Increase y coordinate.       
            add         esi,86                                                              ; Get the address of the next line of text.
            dec         ebx                                                                 ; Decrease the total of lines to print (draw).
            jnz         allstri                                                             ; Repeat until all the string are drawed.   
                               
            push        offset paintstru
            push        hwnd
            call        EndPaint

            xor         eax,eax

            mov         esp,ebp
            pop         ebp

            ret         16


align 4
destroy:

            cmp         dword ptr[ebp+12],WM_DESTROY
            jne         wnddefau
           
            push        0
            call        PostQuitMessage

            xor         eax,eax

            mov         esp,ebp
            pop         ebp

            ret         16


align 4
wnddefau:

            push        dword ptr[ebp+20]
            push        dword ptr[ebp+16]
            push        dword ptr[ebp+12]
            push        dword ptr[ebp+8]
            call        DefWindowProc

            mov         esp,ebp
            pop         ebp

            ret         16

            end         start

6
The Laboratory / Re: Hardware Enumerator [Beta Test]
« Last post by felipe on Today at 02:10:04 PM »
Wow! rastlin, looks pretty cool stuff.  :eusa_clap:
 
I will prove it on my machine (but i will not upload a picture of it...)  :biggrin:
7
The Laboratory / Re: Hardware Enumerator [Beta Test]
« Last post by Jokaste on Today at 02:04:29 PM »
8
The Campus / Re: Bass.dll problem
« Last post by LordAdef on Today at 11:26:23 AM »
thanks Ragdog!
I'll check it out.
Marinus was onto something very promising, I hope he gets it forwards.
9
UASM Assembler Development / Re: UASM 2.46 Release
« Last post by jj2007 on Today at 11:16:46 AM »
Thanks, John, I'll check it tomorrow :icon14:

My current code is here.
10
UASM Assembler Development / Re: UASM 2.46 Release
« Last post by johnsa on Today at 10:51:45 AM »
I'm on Windows 10 and it seems to work for me, there is more code however to complete the operation properly, i believe you need to apply the change..

something along these lines (and this also lists the required headers) :

Code: [Select]

#include "windows.h"
#include "wininet.h"
#include "shlobj.h"
#include "wchar.h"
#include <iostream>

void  SetWallpaper(LPCWSTR file){
    CoInitializeEx(0,COINIT_APARTMENTTHREADED);
    IActiveDesktop* desktop;
    HRESULT status =       CoCreateInstance(CLSID_ActiveDesktop,NULL,CLSCTX_INPROC_SERVER,IID_IActiveDesktop,(void**)&desktop);
    WALLPAPEROPT wOption;
    ZeroMemory(&wOption, sizeof(WALLPAPEROPT));
    wOption.dwSize=sizeof(WALLPAPEROPT);
    wOption.dwStyle = WPSTYLE_CENTER;
    status = desktop->SetWallpaper(file,0);
    wcout << status << endl;
    status = desktop->SetWallpaperOptions(&wOption,0);
    wcout << status << endl;
    status = desktop->ApplyChanges(AD_APPLY_ALL);
    wcout << status << endl;
    desktop->Release();
    CoUninitialize();
}
int wmain(int argc, wchar* argv[]){
    if(argc<=1){
        wcout << "use: " << argv[0] <<" path_to_pic.bmp" <<endl;
    }else{
        wchar_t* file = argv[1];
        SetWallpaper(file);
    }
    getchar();
    return 0;
}

Pages: [1] 2 3 ... 10