BBC BASIC for Windows
Programming >> Assembly Language Programming >> Transfering a value using assembly language MOV
http://bb4w.conforums.com/index.cgi?board=assembler&action=display&num=1462853339

Transfering a value using assembly language MOV
Post by michael on May 10th, 2016, 04:08am

I finally found some extremely well made 32 bit general tutorials for assembly
language.
https://www.youtube.com/watch?v=IiEYxc3ZFog&list=PL4C2714CB525C3CD7&index=26

I guess ill share what I learned. It took a while to find a base program to work with and this has some code from the assembly language tutorials.

I got lucky and found 1 source snippet that I could test and modify as I am learning just 32 bit 8086 assembly language programming .. (thankfully)

From my lessons assembly registers must first be given a value and then the register can share a result to a variable.

So in this program, eax is a 32 bit register (that's all I am learning)
* bin% and bcd% are the original variables declared
at the start of the program in a DIM command..

mov eax,[bin%]

so first the value of bin% is moved into the 32 bit register eax

now this part I experimented with assuming if I could assign eax, with bin% then I could assign bcd% (my other variable from eax register value..
AND IT WORKED!!! HE HE HE

mov [bcd%],eax

So this program does just the simple job of transferring variable values within assembly.

Code:
 DIM bin% 3, bcd% 9
      PROCassemble
      REPEAT
        INPUT "Enter a number for eax register to recieve: " !bin%
        CALL bin2bcd
        PRINT ":eax gave bcd% your number ";!bcd%
      UNTIL FALSE
      END

      DEF PROCassemble
      LOCAL P%, L%
      DIM P% 12, L% -1
      [OPT 10
      .bin2bcd
      mov eax,[bin%]
      mov [bcd%],eax
      ret
      ]
      ENDPROC