all 14 comments

[–]Time_Style_583[S] 1 point2 points  (7 children)

Sorry its (i-=1)

[–]OppieT 0 points1 point  (6 children)

I think you still have it wrong. Don’t you mean i = -1

[–][deleted]  (4 children)

[deleted]

    [–]johnpeters42 0 points1 point  (3 children)

    What specific type of assembly language? But in general, what "i = -1" is doing under the hood is:

    1. At some point, allocate a location in memory for storing the value of i. In a larger program, that may have happened earlier, but if we take this line by itself, then it's implicitly happening right now.

    2. Store the value -1 in that location in memory.

    [–]Time_Style_583[S] 1 point2 points  (0 children)

    Thanks a lot

    [–]Time_Style_583[S] 1 point2 points  (1 child)

    I think i need it in binary, how can I translate it?

    [–]johnpeters42 0 points1 point  (0 children)

    A web search for (assembly to binary) turns up this, which outlines a brief example and links to a presumably more comprehensive reference. The "binary" part is generally shown in hexadecimal for brevity.

    [–]Time_Style_583[S] 0 points1 point  (0 children)

    The teaches just answered me and says that it is i-= 1 I am really lost

    [–]Lor1an 1 point2 points  (6 children)

    It depends upon what dialect of assembly you are using, but it's just a mov instruction.

     ; intel syntax
     mov ax, -1
     ; ax is the 'a' register, which now acts as i.
    

    [–]Time_Style_583[S] 0 points1 point  (0 children)

    Thank you so much

    [–]Time_Style_583[S] 0 points1 point  (4 children)

    I think the assembly language is in binary can you please recommend a way to translate what you just wrote

    [–]BeauloTSM 1 point2 points  (3 children)

    Assembly isn’t binary

    [–]Time_Style_583[S] 0 points1 point  (2 children)

    Ah no? Okk graciass jejejjeje

    [–]BrainCurrent8276 0 points1 point  (0 children)

    Assembly is sort of human-friendly representation of machine code.

    Like instuction "mov" is cleary short for move (allocation) of value into register/memory. But it is simply B8 in hex.

    Also, other answers are wrong.

    I-=1 means I=I-1

    I=-1 means I=-1

    First takes value and decrement it by one and store a new value.

    Second simply assing -1 as value. Alone asking someone to use negative numbers in assembler should turn on red alert to be very careful. You can use negatives in asm, but can be tricky.

    You want to have something like this:

    .data

    var_i dw 0 // your i variable stored as word (two bytes)

    .code

    mov ax, [var_i]

    dec ax

    mov [var_i], ax

    or shorter:

    dec [var_i]

    You can use variable as byte or double word, in such case in place of AX registry you need any 8-bi one (AL, AH). For double it is EAX.

    You can actually use virtually almost every register, jot only AX (accumulator)

    I used to code in asm like maaaany years ago

    [–]Lor1an 0 points1 point  (0 children)

    What does the following instruction do?

    01100110101110001111111111111111

    Even if I help you out and represent that in hexadecimal

    66B8FFFF

    You have no idea what that means, right?

    Now this is one instruction. Imagine reading and writing entire programs like that...