Difference between revisions of "Jasmin/Example"
< Jasmin
Jump to navigation
Jump to search
(Created page with "Example of a simple robot written in Jasmin Assembly code. <syntaxhighlight lang="asm"> ; --- Copyright Robert Maupin 2012. All rights reserved. ----------------- ; File: cs...") |
m |
||
Line 34: | Line 34: | ||
dconst_0 | dconst_0 | ||
ddiv | ddiv | ||
− | + | invokevirtual robocode/AdvancedRobot/turnRadarRightRadians(D)V | |
return | return |
Revision as of 07:02, 14 December 2012
Example of a simple robot written in Jasmin Assembly code.
; --- Copyright Robert Maupin 2012. All rights reserved. -----------------
; File: cs/Nano.j
; Author: Robert Maupin, 3 December 2012
; -------------------------------------------------------------------------
; WARNING: you will never ever be able to decompile this class
.class public cs/Nano
.super robocode/AdvancedRobot
; initializer
.method public <init>()V
aload_0
invokenonvirtual robocode/AdvancedRobot/<init>()V
return
.end method
;run method
.method public run()V
;these don't have to be precise, just big enough to hold everything :)
.limit stack 8
.limit locals 8
aload_0 ; the 'this' statement...
;setAdjustGunForRobotTurn(true);
iconst_1
invokevirtual robocode/AdvancedRobot/setAdjustGunForRobotTurn(Z)V
aload_0
;turnRadarRightRadians(1.0/0.0);
dconst_1
dconst_0
ddiv
invokevirtual robocode/AdvancedRobot/turnRadarRightRadians(D)V
return
.end method
;turn onScannedRobot...
.method public onScannedRobot(Lrobocode.ScannedRobotEvent;)V
;these don't have to be precise, just big enough to hold everything
.limit stack 16
.limit locals 8
;if (1 < getOthers())
aload_0
invokevirtual robocode/AdvancedRobot/getOthers()I
iconst_1
;this is 3 bytes.... all jumps are (cept jsr_w, which is 5)
if_icmplt skipInfinityLock
;Infinity Lock Radar
;setTurnRadarLeftRadians(getRadarTurnRemainingRadians());
aload_0
dup
invokevirtual robocode/AdvancedRobot/getRadarTurnRemainingRadians()D
invokevirtual robocode/AdvancedRobot/setTurnRadarLeftRadians(D)V
skipInfinityLock:
return
.end method