Virtual Assembler - Learn assembly languages fast!

Community Forums/Showcase/Virtual Assembler - Learn assembly languages fast!

bytecode77(Posted 2008) [#1]
hi!

this is an assembly language, which is not fast. in fact, it's even interpreted. but it's a way to learn asm very fast.
(there is a command reference included!)

download: http://stuff.dev-ch.de/index.php?article=stuff_virtualassembler

here is an example code:
lop1:	invoke	lockbuffer
	invoke	rand, &h000000, &hffffff
	mov	eax, 0
lop2:	cmp	eax, 630
	jz	lop2e
	add	eax, 10
	mov	ebx, 0
lop3:	cmp	ebx, 470
	jz	lop3e
	add	ebx, 10
	invoke	plot, eax, ebx, ecx
	jmp	lop3
lop3e:	jmp	lop2
lop2e:	invoke	unlockbuffer
	invoke	flip
	jmp	lop1

if you like it or if you dont like it, i would like to hear from you. just post your oppinions :)
and if you have written a little program, i'll be happy to see the code ;)!
bye!


Perturbatio(Posted 2008) [#2]
I presume this is x86 asm?


SoggyP(Posted 2008) [#3]
Hello.

Wow! I did something similar - a Z80/6502 Assembler/Disassembler Emulator - for my A Level project a couple of years ago...ok, so it was 20 years ago but who's counting? It sure beat the pants off the library databases that everyone else was writing.

Right then, get back on topic ;o)

Goodbye.


bytecode77(Posted 2008) [#4]
this is emulating x86 asm. try to put some code together and drop it on the exe :)
its just fun, because you can go as deep as you want. in that one example i used three loops within each other and its amazing how fast it gets confused.


Karja(Posted 2008) [#5]
This is so cool! But couldn't you write a print_number function? I wrote this little fibonacci function but I can't be arsed to test it if it works - it's too much work writing a number-to-ascii converter when I don't know if I even can send a memory address to the print function. :)

Or maybe display what the registers contains after the program has ended? That would work!

; In: eax = n
; Out: ecx = fib(n)
	mov	ebx, 0
	mov	ecx, 1
loop:	mov	edx, ebx
	add	edx, ecx
	mov	ebx, ecx
	mov	ecx, edx
	dec	eax, 1
	cmp	eax, 0
	jg	loop


(I take no responsibility for any errors - it's been yeeears since I did any asm!)


bytecode77(Posted 2008) [#6]
registers can be displayed by invoking print
invoke print, eax

in this version of assembler, you can move anything to anything.
add edx, ecx would be
inc edx



Karja(Posted 2008) [#7]
Ah, cool! Then, here's an updated fibonacci function which handles fib(0) as well:

	mov eax, 1

; In: eax = n
; Out: ecx = fib(n)
	mov	ecx, 1
	cmp	eax, 0
	jle	end
	mov	ebx, 0
loop:	mov	edx, ebx
	add	edx, ecx
	mov	ebx, ecx
	mov	ecx, edx
	dec	eax
	cmp	eax, 0
	jg	loop

end:	invoke	print, ecx


Just change the initial eax to something else to see different results. :)

(Oh, and you can't change the add to an inc. ecx is updated with a new value in each loop.)


bytecode77(Posted 2008) [#8]
hm what exactly does that do?

if you want a never ending loop:
loop:	inc	eax
	invoke	print, eax
	jmp	loop


PS: you might as well use 0x000 up to 0xfff for memory acess!!!


Karja(Posted 2008) [#9]
The fibonacci sequence is a mathematical sequence defined like this:

fib(n) = fib(n-1) + fib(n-2)

I.e:

fib(0) = 1
fib(1) = 1
fib(2) = 2
fib(3) = 3
fib(4) = 5
fib(5) = 8
...

It's a common example when you explain recursion; this implementation uses a loop instead, since it's both more efficient and more practical for assembly.


bytecode77(Posted 2008) [#10]
ah i see. nice idea!


Perturbatio(Posted 2008) [#11]
I get a MAV when dragging and dropping a file onto the exe
this happened on my work machine as well.


bytecode77(Posted 2008) [#12]
even my examples?
are you using windows xp? if that isnt the case, we have our error found.
otherwise: open the bb file and put "Sample.asm" insted of commandline(). try this.


N(Posted 2008) [#13]
http://webster.cs.ucr.edu/AsmTools/HLA/index.html This is your better option if you want to start learning assembly.
http://drpaulcarter.com/pcasm/ I'd also recommend reading that.

Good work even so, but I just wanted to toss those out there for people interested in learning assembly.


Perturbatio(Posted 2008) [#14]
even my examples?

yes

are you using windows xp?



yes

if that isnt the case, we have our error found.

Nope

However, the error appears to be that the program doesn't take into account file paths like "C:\Documents and Settings\Perty.Flubblekin\Desktop\Vasm_Release1\test.asm"


bytecode77(Posted 2008) [#15]
Perturbatio: hm dont know why that causes a problem anyway... put into the line where i call the commandline simply the filename such as "sample.asm" and delete the SetEnv line.

Pure Cane Soda: i know little something about asm. i tried to do Tasm but i never found a working IDE. and thats the problem. but since c++ is 98% as fast as ASM i think i stick to c++

bye


Jasu(Posted 2008) [#16]
Does this do floating point arithmetic?


bytecode77(Posted 2008) [#17]
this is string, float and int all in one. you work with strings and if a mathematic opperation is done, you cast to ints/floats