News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Starting from the ground up

Started by j00n, February 17, 2011, 02:48:12 AM

Previous topic - Next topic

j00n

I'm reading the included help files and instead of making new threads for every small question I figured I would just post them all in one thread

mostly clarifying small stuff so i'm not just assuming

like I said these are all questions based off the included help files and whatever i'm not quite sure about

here are a few things i'm wondering about so far




mystr1 db 12, 0                                     ; 8 bits         1 = 4 bits    2 = 4 bits
mystr2 dw 1234, 0                        ; 16 bits
mystr3 dd 1234567890, 0                     ; 32 bits       

why is mystr3 possible I thought it could only hold 4 bytes, what is the extra 90?





mystr4 db "111111111111111111111111111111", 0              ; why can this be a long string
mystr5 dw "11", 0                        ; but this cannot ?




    mov al,  [esi]   ; copy byte at address in ESI into AL

    do these square brackets specifically mean byte at this location?    so [ebx] and bl would be the same thing?


dedndave

1234567890 is a decimal value - in hex, it would be 499602D2h
the maximum unsigned value for a dword is 4294967295 (decimal)
mystr4 db "111111111111111111111111111111", 0              ; why can this be a long string
mystr5 dw "11", 0                        ; but this cannot ?

it can be - it just doesn't happen to be
the DB directive assigns bytes
strings like these are essentially arrays of bytes - and can be any practical length
note that, because they are in quotes, they are ASCII bytes - if you looked at those ones in binary, they'd be 31h's

yes - brackets indicate that the register is an address (sometimes refered to as a pointer or index)

FORTRANS

Quote from: dedndave on February 17, 2011, 02:58:29 AM
yes - brackets indicate that the register is an address (sometimes refered to as a pointer or index)

Hi Dave,

   That is if you use it as it is intended.  You (I) can screw things
up if you (I) get careless.  MASM can be a bit strange at times.
Misuse of brackets can cause strange results that are (to me)
unexpected.  Address 111 in the following is the way it would be
normally used.  Address 10E shows what would probably be an
error in code that I would write.

Cheers,

Steve N.

Quote
Microsoft (R) Macro Assembler Version 6.14.8444          02/17/11 08:36:54
test25b.asm                       Page 1 - 1
... <Snip>
0102  B8 007B                 MOV     AX,123
0105  B8 007B                 MOV     AX,[123]
0108  A1 007B                 MOV     AX,DS:[123]
...
010E  B8 011E R              MOV     AX,[Payload]
...
0111  A1 0157 R              MOV     AX,[RESULT]
...
011E            Payload:
011E  0B 64 8D 7F 32 D2        db 00bh, 064h, 08dh, 07fh, 032h, 0d2h, 015h,\ ;
...
0157 011E R         RESULT  DW      Payload
...

dedndave

in GoAsm, they use brackets on labels - maybe that should be your choice, Steve   :bg
i use brackets only on registers, usually
however, if i have a label and an offset, i may put the offset inside
        mov     eax,VectorTable[ebx-MINOFFSET]

FORTRANS

Hi Dave,

   I think most programmers are like you and tend not to
use brackets around variable names.  And using them on
registers works in a relatively sane manner.  I ended up
doing it to try and tell the difference between variables and
constants defined in an EQUate.  Then I know what to look
for when the bugs bite.  And in my example above you will
get the exact same results without the brackets.  But that
is probably a different topic.

  j00n, dedndave is probably right about usage for beginners.
Sorry for any added confusion.

Regards,

Steve

j00n

Trackbar issues...

I created a trackbar using this in WM_CREATE

invoke CreateWindowEx,0,ADDR TrackbarClass,addr trackbar1,WS_CHILD or WS_VISIBLE or TBS_AUTOTICKS or TBS_ENABLESELRANGE,0,600,120, 30,hWnd,NULL,hInstance,NULL


I don't understand how to retrieve the value in WM_HSCROLL and set the value to a variable...

   .ELSEIF uMsg==WM_HSCROLL
   
invoke SendMessage,addr TrackbarClass,TBM_GETPOS,0,0


    mov myval, eax


is this even close?




jj2007

Pretty close. But you need a mailbox to send messages. It is called a handle in Windows, and it is good practice to use a global variable of the type hMyWindow:

invoke CreateWindowEx,0,...
mov hTrackBar, eax
...
invoke SendMessage, hTrackBar, ....

j00n


j00n

Ok i've got the trackbar working, i've setup the ticks

but when I grab the slider its too smooth... how would I force it to only drag every 5 ticks?

Tedd

The simplest method is to give it the TBS_AUTOTICKS style,and then use the TBM_SETRANGE message -- http://msdn.microsoft.com/en-us/library/bb760221%28VS.85%29.aspx
Then you don't need to set ticks separately.

TBM_GETPOS will return a value in range of min--max, so then you can multiply by any scaling value you decide that each tick represents.
No snowflake in an avalanche feels responsible.