### Author Topic: Vm instruction times table  (Read 644 times)

#### cvirus

• Jr. Member
• Posts: 72
##### Vm instruction times table
« on: June 09, 2016 »
Code: [Select]
`set window 0,0,640,480wln "Lets try to use the VM instructions"    cnt = 10    s = 0    i = 1    tab = 1@start:    MOV s 1    MUL s i    wln str\$(tab)+" X "+str\$(i) +" = "+str\$(s)    ADD i 1    ADD s 0    CMP i cnt    ADD i 0    JLE start    JG exit@exit:wln "Count is over old chap"wait keydownend`
Hey Marcus, how can i do it untill 10 not just 1?

#### Marcus

• Hero Member
• Posts: 549
##### Re: Vm instruction times table
« Reply #1 on: June 09, 2016 »
You mean print all x*y, whith x and y in [1..10]?

Code: [Select]
`resultj = 1@jStart: set caret (j - 1)*64, 0 i = 1 @iStart: MOV @0 j MUL @0 i MOV result  @0 wln j, "x", i, "=", result ADD i 1 CMP i 10 JG iEnd JMP iStart @iEnd: ADD j 1 CMP j 10 JG jEnd JMP jStart@jEnd:wait keydown`
.\\\opz

#### cvirus

• Jr. Member
• Posts: 72
##### Re: Vm instruction times table
« Reply #2 on: June 09, 2016 »
Well i'm not @ home so i can not test, but it looks ok, and way better than mine :-(, do you have a screen of the result?

Thanks

#### Marcus

• Hero Member
• Posts: 549
##### Re: Vm instruction times table
« Reply #3 on: June 09, 2016 »
I've attached a screenshot
.\\\opz

#### cvirus

• Jr. Member
• Posts: 72
##### Re: Vm instruction times table
« Reply #4 on: June 09, 2016 »
Dam, that is what i was looking to achieve, i was trying to do everything in the same loop :-).

Thanks

#### Marcus

• Hero Member
• Posts: 549
##### Re: Vm instruction times table
« Reply #5 on: June 09, 2016 »
Using global variables are just as fast as using the registers [@0 .. @7]. If you're doing VM code inside a subroutine the register are faster than the local variables and parameters though.

Haha, I only added the VM commands to be able to make the Raycaster fast enough
.\\\opz

#### cvirus

• Jr. Member
• Posts: 72
##### Re: Vm instruction times table
« Reply #6 on: June 09, 2016 »
but in the docs says that we can only use from @0 to @4, this means that we can use to @7? 8 all registers? Damn, what about memory allocation is it possible too?

Thanks :-)