Results 1 to 19 of 19

Thread: Learning ASM

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    I have MASM32. It seems to be pretty good. Go to this site for compilers and tutorials. By the way, could you send me the code that you used to open/close your cd drive? Thanks.

  2. #2
    Guest
    Thank you very much

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  4. #4
    Guest
    damn, I dont know why I didnt ever try that URL before



    BTW Thanks!

    [Edited by denniswrenn on 08-20-2000 at 08:48 PM]

  5. #5

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Yeah, I've been through that one.

    I tend to find that you're better of with a book when it comes to ASM. (not that I'm an experienced ASM programmer) I also find that books cover the topic in much more depth and that has been very important to me so far in learning ASM.

    I got this book...

    http://www.amazon.com/exec/obidos/AS...470099-9752032



    [Edited by Paul282 on 08-21-2000 at 10:59 PM]
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    $73.00?!?!?! Jeez!! That's way too much for me!

  8. #8
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    I'm always happy to spend money on books. Net tutorials are good but if I buy a book I'm more inclined to sit down and actually learn the topic in depth.

    Sort of like an investment in myself, the payback comes when I ask for twice as much in my next job :-)

    It's worked well so far anyway, I'm not 30 yet, I didn't even finish school let alone go to college and I earn over US$100k a year in the IT industry!

    I have a problem with modesty though

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  9. #9
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516

    Wink

    It shines through like a supernova
    Courgettes.

  10. #10
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840








    can't even blame alcohol for that comment!



    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  11. #11
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    I'm posting this here, because it's such a petty question it isn't worthy of a new thread:

    Could somebody post just a little source code (ASM), because I'm really interested to see what it look like.

    Thyroid.
    Courgettes.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    From the MASM32 website:
    Code:
    ; ######################################################################### 
    
          .386 
          .model flat, stdcall 
          option casemap :none   ; case sensitive 
    
    ; ######################################################################### 
    
          include \masm32\include\windows.inc 
          include \masm32\include\user32.inc 
          include \masm32\include\kernel32.inc 
    
          includelib \masm32\lib\user32.lib 
          includelib \masm32\lib\kernel32.lib 
    
    ; ######################################################################### 
    
          ;============= 
          ; Local macros 
          ;============= 
    
          szText MACRO Name, Text:VARARG 
            LOCAL lbl 
              jmp lbl 
                Name db Text,0 
              lbl: 
            ENDM 
    
          m2m MACRO M1, M2 
            push M2 
            pop  M1 
          ENDM 
    
          return MACRO arg 
            mov eax, arg 
            ret 
          ENDM 
    
            ;================= 
            ; Local prototypes 
            ;================= 
            WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD 
            WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD 
            TopXY PROTO   :DWORD,:DWORD 
    
        .data 
            szDisplayName db "Template",0 
            CommandLine   dd 0 
            hWnd          dd 0 
            hInstance     dd 0 
    
        .code 
    
    start: 
            invoke GetModuleHandle, NULL 
            mov hInstance, eax 
    
            invoke GetCommandLine 
            mov CommandLine, eax 
    
            invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT 
            invoke ExitProcess,eax 
    
    ; ######################################################################### 
    
    WinMain proc hInst     :DWORD, 
                 hPrevInst :DWORD, 
                 CmdLine   :DWORD, 
                 CmdShow   :DWORD 
    
            ;==================== 
            ; Put LOCALs on stack 
            ;==================== 
    
            LOCAL wc   :WNDCLASSEX 
            LOCAL msg  :MSG 
    
            LOCAL Wwd  :DWORD 
            LOCAL Wht  :DWORD 
            LOCAL Wtx  :DWORD 
            LOCAL Wty  :DWORD 
    
            ;================================================== 
            ; Fill WNDCLASSEX structure with required variables 
            ;================================================== 
    
            mov wc.cbSize,         sizeof WNDCLASSEX 
            mov wc.style,          CS_HREDRAW or CS_VREDRAW \ 
                                   or CS_BYTEALIGNWINDOW 
            mov wc.lpfnWndProc,    offset WndProc 
            mov wc.cbClsExtra,     NULL 
            mov wc.cbWndExtra,     NULL 
            m2m wc.hInstance,      hInst 
            mov wc.hbrBackground,  COLOR_BTNFACE+1 
            mov wc.lpszMenuName,   NULL 
            mov wc.lpszClassName,  offset szClassName 
              invoke LoadIcon,hInst,500    ; icon ID 
            mov wc.hIcon,          eax 
              invoke LoadCursor,NULL,IDC_ARROW 
            mov wc.hCursor,        eax 
            mov wc.hIconSm,        0 
    
            invoke RegisterClassEx, ADDR wc 
    
            ;================================ 
            ; Centre window at following size 
            ;================================ 
    
            mov Wwd, 500 
            mov Wht, 350 
    
            invoke GetSystemMetrics,SM_CXSCREEN 
            invoke TopXY,Wwd,eax 
            mov Wtx, eax 
    
            invoke GetSystemMetrics,SM_CYSCREEN 
            invoke TopXY,Wht,eax 
            mov Wty, eax 
    
            szText szClassName,"Template_Class" 
    
            invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW, 
                                  ADDR szClassName, 
                                  ADDR szDisplayName, 
                                  WS_OVERLAPPEDWINDOW, 
                                  Wtx,Wty,Wwd,Wht, 
                                  NULL,NULL, 
                                  hInst,NULL 
            mov   hWnd,eax 
    
            invoke LoadMenu,hInst,600  ; menu ID 
            invoke SetMenu,hWnd,eax 
    
            invoke ShowWindow,hWnd,SW_SHOWNORMAL 
            invoke UpdateWindow,hWnd 
    
          ;=================================== 
          ; Loop until PostQuitMessage is sent 
          ;=================================== 
    
        StartLoop: 
          invoke GetMessage,ADDR msg,NULL,0,0 
          cmp eax, 0 
          je ExitLoop 
          invoke TranslateMessage, ADDR msg 
          invoke DispatchMessage,  ADDR msg 
          jmp StartLoop 
        ExitLoop: 
    
          return msg.wParam 
    
    WinMain endp 
    
    ; ######################################################################### 
    
    WndProc proc hWin   :DWORD, 
                 uMsg   :DWORD, 
                 wParam :DWORD, 
                 lParam :DWORD 
    
        .if uMsg == WM_COMMAND 
        ;======== menu commands ======== 
            .if wParam == 1000 
                invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL 
            .elseif wParam == 1900 
                szText TheMsg,"Assembler, Pure & Simple" 
                invoke MessageBox,hWin,ADDR TheMsg,ADDR szDisplayName,MB_OK 
            .endif 
        ;====== end menu commands ====== 
    
        .elseif uMsg == WM_CLOSE 
            szText TheText,"Please Confirm Exit" 
            invoke MessageBox,hWin,ADDR TheText,ADDR szDisplayName,MB_YESNO 
              .if eax == IDNO 
                return 0 
              .endif 
        .elseif uMsg == WM_DESTROY 
            invoke PostQuitMessage,NULL 
            return 0 
        .endif 
    
        invoke DefWindowProc,hWin,uMsg,wParam,lParam 
    
        ret 
    
    WndProc endp 
    
    ; ######################################################################## 
    
    TopXY proc wDim:DWORD, sDim:DWORD 
    
        shr sDim, 1      ; divide screen dimension by 2 
        shr wDim, 1      ; divide window dimension by 2 
        mov eax, wDim    ; copy window dimension into eax 
        sub sDim, eax    ; sub half win dimension from half screen dimension 
    
        return sDim 
    
    TopXY endp 
    
    ; ######################################################################## 
    
    end start
    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

  13. #13
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Hmmm. It's not as harsh as I thought it would be.

    Thanks, parksie.
    Courgettes.

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Having started to learn this morning, I can confidently say that it is definitely not as hard as people say.
    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

  15. #15
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Yeah, I was expecting something where you had to intercept all the mouse messaages and keyboard messages, and you had to create the window yourself and set the pixels yourself. It just seems like a primitive C++, though.
    Courgettes.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Not really. You do need to set up a window procedure and all that, but a basic program in C++ takes up about 25K, and that program I gave assembles into 5K, and uses NO DLLs WHATSOEVER. Also, when doing asm, you can optimise it by hand by method, because there are new, more efficient ways to do certain algorithms.
    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

  17. #17
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    bit of a reality check though. That's MASM32! which has quite a bit added to make it easier. to actually write your own code you'd need a better understanding of ASM in it's normal form.

    Here's hello world

    Code:
    
    title Hello World Program         (hello.asm)
    
    ; This program displays "Hello, world!"
    
    .model small
    .stack 100h
    .data
    message db "Hello, world!",0dh,0ah,'$'
    
    .code
    main proc
        mov  ax,@data
        mov  ds,ax
    
        mov  ah,9
        mov  dx,offset message
        int  21h
    
        mov  ax,4C00h
        int  21h
    main endp
    
    end main
    There is a lot to learn before you can really start. Don't get me wrong, what you learn about CPU's, registers and memory is valuable in any language. But you'd need to know basic ASM syntax before you used MASM32.

    You should be able to look at the above code and see it is only using 16 bit registers.

    Int 21h is a dos interrupt, but other than that you'd need understanding of the AX, DS and quite a few other register's functions. I've only been in this for a few months and have hardly written anything, but it's fascinating. The commands are one for one based on machine code!
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  18. #18
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Paul - thanks for that, I needed some example code to do this. Why is the string terminated with a '$' not '\0'?
    Also, when you write your program, do you need to worry about the register state before or after your program runs?
    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

  19. #19
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    The string is terminated with a '$' because INT 21h function 09h stops displaying characters once a '$' is reached.

    I really don't think you have to worry about register states before and after your application runs.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

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