"The means of defense against foreign danger historically have become instruments of tyranny at home." "I mezzi di difesa contro il pericolo storicamente stranieri sono diventati strumenti di tirannia a casa".-- James Madison - James Madison
Published by: apples , on 2008-06-20 01:22:40 Pubblicato da: mele, il 2008-06-20 01:22:40
I. Introduction I. Introduzione Recently, I ran across a programming-oriented game by the name of "Core War." Recentemente, ho eseguito attraverso una programmazione orientata al gioco con il nome di "core war". The objective of Core War is to create a program (called a "warrior") that survives the L'obiettivo di Core guerra è quello di creare un programma (chiamato "guerriero") che sopravvive la longest within the Memory Array Redcode Simulator, or MARS for short. più lunga all'interno della memoria Array Redcode Simulator, o per brevi MARS.However, creating Tuttavia, la creazione di a warrior is a daunting task, and has a steep learning curve for beginners. un guerriero è un compito scoraggiante, e ha una ripida curva di apprendimento per i principianti.In this brief In questo breve guide, I shall explain the basics of the Redcode assembly language, and give you some tips guida, vorrei spiegare le basi del linguaggio assembly Redcode, e darvi alcuni consigli on how to create a successful warrior. su come creare un guerriero.
II. The Redcode Intsruction Set Il Redcode Intsruction impostare The following section will describe each instruction that is available within the La sezione seguente descrive ogni istruzione che è disponibile all'interno del Redcode assembly language. Redcode linguaggio assembly.The syntax of any instruction is as follows: La sintassi di ogni istruzione è la seguente: CODE : CODICE:
name source, destdenominazione di origine, destinazione
A. The ADD instruction A. La aggiungere istruzioni Well, if you haven't figured out what this one does yet, I'm not sure if Beh, se non hai figurato che cosa questo si fa ancora, non sono sicuro se you should be reading this guide. si dovrebbe essere la lettura di questa guida.ADD adds together the source and dest, ADD aggiunge insieme la fonte e la destinazione, and stores it in dest. e lo memorizza nella destinazione. B. The CMP instruction B. il CMP di istruzioni CMP compares the instruction at source and the instruction at dest, and CMP confronta le istruzioni alla fonte e l'istruzione a destinazione, e skips the next instruction if they are equal. salta la prossima istruzione se sono uguali. C. The DAT instruction C. Il DAT istruzione This instruction is vital to winning any Core War game. Questa istruzione è fondamentale per vincere qualsiasi guerra Core gioco.Upon executing a Al momento l'esecuzione di un DAT, the warrior will terminate, and will be out of the game. DAT, il guerriero si concluderà, e sarà fuori del gioco.This is one Questo è uno of the only ways to kill a warrior. l'unico modo per uccidere un guerriero.The arguments to this instruction have Gli argomenti di questo insegnamento sono no effect on how it executes. alcun effetto sul modo in cui viene eseguito. D. The DIV instruction D. Il div istruzione As you might have guessed, DIV divides the source by dest, and stores it in Come forse avrete già indovinato, DIV divide la fonte da dest, e lo memorizza nella dest. If the divisor is 0, the warrior will terminate, as if it has received Se il divisore è 0, il guerriero si concluderà, come se essa ha ricevuto a DAT. DAT. E. The DJN instruction E. L'istruzione DJN DJN is a conditional jump, the opposite of an unconditional one. DJN è un salto condizionale, il contrario di uno incondizionato uno.Conditional Condizionale jumps only jump if a certain condition is met. salti saltare solo se una certa condizione è soddisfatta.DJN decrements src by 1, and Src DJN decrementi di 1, e if it is not zero, then it jumps to dest. se non è zero, allora salta a destinazione. F. The JMP instruction F. La JMP istruzione This is an unconditional jump. Questo è un salto incondizionato.That means, no matter what, the next instruction Ciò significa che, non importa cosa, la prossima istruzione executed will be at src. sarà eseguito a src. G. The JMN instruction G. La JMN istruzione JMN is a conditional jump that checks to is if src is 0, and if it isn't, jumps JMN è un salto condizionale che verifica se è src è 0, e se non è, salti to dest. a destinazione. H. The JMZ instruction H. La JMZ istruzione JMZ is a conditional jump that checks to is if src is 0, and if it IS, JMZ è un salto condizionale che verifica se è src è 0, e se lo è, (the opposite of JMN) then it jumps to dest. (il contrario di JMN), poi si salta a destinazione. I. The MOD instruction I. Il mod istruzione MOD is a modulus function that takes the remainder of a division between src MOD è un modulo funzione che prende il resto di una divisione tra src and dest and stores it in dest. e destinazione e le memorizza in dest.If the divisor is 0, the same action will be taken as Se il divisore è 0, la stessa azione sarà presa come if it were a DIV. se si trattasse di un DIV. J. The MOV instruction J. Il mov istruzione MOV, well, moves the instruction at src to dest. MOVIMENTI, bene, si muove l'istruzione a src di destinazione.It's easily the most simple instruction E 'facilmente i più semplici istruzioni in any assembly language. montaggio in qualsiasi lingua. K. The MUL instruction K. Il MUL istruzione MUL multipilies src by dest, and stores the result in dest. MUL multipilies src dalla destinazione, e memorizza il risultato in dest. L. The SEQ instruction L. Il seguenti istruzioni SEQ is exactly the same as the aforementioned CMP instruction. SEQ è esattamente lo stesso come il CMP di istruzioni di cui sopra. M. The SNE instruction M. l'END istruzione SNE compares the instruction at source and the instruction at dest, and END confronta le istruzioni alla fonte e l'istruzione a destinazione, e skips the next instruction if they are not equal. salta l'istruzione successiva se non sono uguali. N. The SPL instruction N. La SPL istruzione SPL is the most complicated instruction within all of Redcode. SPL è il più complicato di istruzioni all'interno di tutti i Redcode.It starts a new Si inizia una nuova process at the location given by src, and the current process continues towards processo presso la posizione data dal src, e l'attuale processo di continua verso the next instruction. la successiva. O. The SUB instruction O. il sub istruzione SUB subtracts src from dest and stores it in dest. SUB sottrae src da dest e le memorizza in dest.
III. Facts about the MARS system Fatti circa il sistema MARS MARS works very differently than a regular PC. MARS funziona molto differente rispetto a un normale PC.Its memory wraps around, which means La sua memoria intorno, il che significa once you reach the limit of the memory, you start back again at 0. Una volta raggiunto il limite di memoria, si avvia di nuovo a 0.Also, MARS uses what is called Inoltre, MARS utilizza quello che viene chiamato "relative addressing." "relativa affrontare".This means that in your instructions, you refer to other instructions relative to Ciò significa che nel tuo istruzioni, si riferiscono ad altre istruzioni relative alla your location. la vostra posizione.An example would be in the first warrior created by AK Dewdney, known as the "Imp." Un esempio potrebbe essere il primo guerriero creato da AK Dewdney, noto come "Imp." The code for the Imp is as follows: Il codice per l'imp è il seguente: CODE : CODICE:
MOV $0, $1MOV $ 0, $ 1
Let's dissect what exactly this instruction is doing. Let's dissezionare esattamente ciò che questa istruzione sta facendo.First, it's a MOV instruction, so we know that it's In primo luogo, si tratta di una istruzione MOV, quindi sappiamo che è moving an instruction from one place to another. uno spostamento di istruzioni da un luogo all'altro.The $ sign before the numbers simply means it's "direct", Il segno $ prima di semplicemente i numeri significa che è "diretto", which we will cover in the next chapter. che serviranno a coprire nel prossimo capitolo.This code moves the instruction at the current location, 0, Questo codice si sposta le istruzioni per l'attuale posizione, 0, (which is MOV $0, $1) to 1, which is 1 instruction above the current location. (che è MOV $ 0, $ 1) a 1, che è di 1 istruzione al di sopra della posizione attuale.So, the Imp simply moves Quindi, la imp semplicemente sposta itself to the next instruction indefinitely. stessa alla prossima istruzione indeterminato.This tactic easily overwrites the opposing warrior, but will not Questa tattica facilmente sovrascrive l'opponente guerriero, ma non kill it, so the game will end in a tie. uccidere, quindi il gioco finirà in un pareggio.
IV. The addressing modes La modalità di indirizzamento Addressing modes are certain modes applied to src and dest (from now on known as the A-field Affrontare le modalità sono determinate le modalità applicate ai src e destinazione (d'ora in poi noto come il campo A - and the B-field, respectively) that change how an instruction executes. e il B-campo, rispettivamente) che come un cambiamento di istruzioni esegue.When the rules for Core War Quando le regole per Core Guerra were first written in 1988, only 4 addressing modes were established. sono state scritte prima, nel 1988, a soli 4 modi di affrontare, sono state stabilite.Later, in 1994, 4 more addressing modes Più tardi, nel 1994, 4 modalità di indirizzamento più were added. sono stati aggiunti.The changes present in the 1994 addition to the Core War rules are known as the '94 standard. Le modifiche presenti nel 1994 oltre al core Guerra regole sono noti come i'94 standard. A. The # (immediate) addressing mode A. Il # (immediato) modalità di indirizzamento # is used to show that the number is actually a number, and not a reference to another # Viene utilizzata per indicare che il numero è in realtà un numero, e non un riferimento a un altro area. zona.ADD #2, @1 would add the number 2 to the B-Field of the instruction at 1. ADD # 2, @ 1 aggiungere il numero 2 al B-Field di istruzione a 1. B. The $ (direct) addressing mode B. Il $ (diretto) modalità di indirizzamento $ is to display that you explicitly specify the whole instruction. $ È di display che hai esplicitamente specificare l'intero insegnamento.MOV $0, $1 moves the MOV $ 0, $ 1 sposta il whole instruction to the location in front of it. istruzioni per intero la posizione di fronte.Usually $ can be omitted in your code. $ Solito possono essere omessi nel codice. C. The * (A-field indirect) addressing mode C. Il * (A-campo indiretta) modalità di indirizzamento * shows that you want to take the value stored in the A-field of that instruction. * Mostra che si desidera prendere il valore memorizzato in un campo di tale insegnamento. MUL *1, #2 will multiply the A-field of the instruction at 1 by the number 2. MUL * 1, # 2 si moltiplicheranno A-campo della istruzione a 1 con il numero 2. D. The @ (B-field indirect) addressing mode D. Il @ (B-campo indiretta) modalità di indirizzamento This is the exact same as the *, except instead of referencing the value in the A-field, Questo è lo stesso come il *, ad eccezione dei riferimenti invece il valore in un campo, you're referencing the one in the B-field. sei il riferimento a uno in B-campo. E. The { (A-field indirect with predecrement) mode E. L'((A-campo indiretta con predecrement) modalità This is similar to the * mode, except that the value stored in the A-field of that instruction Questo è simile alla modalità *, ad eccezione del fatto che il valore memorizzato in un campo di istruzione che is decremented before the current instruction is executed. è decrementato prima che la corrente di istruzioni viene eseguito. F. The < (B-field indirect with predecrement) mode F. La <(B-campo indiretta con predecrement) modalità Again, this is exactly the same as the { addressing mode, but with the B-field instead. Anche in questo caso, è esattamente la stessa della modalità (affrontare, ma con il B-campo, invece. G. The } (A-field indirect with postincrement) mode G. La) (A-campo indiretta con postincrement) modalità This is the same as the * mode, except after the current instruction is executed, the Questa è la stessa della modalità *, tranne che dopo l'attuale insegnamento è stato eseguito correttamente, il value stored at the A-field of that instruction is inremented by 1. valore memorizzato in un campo di istruzione che è inremented entro il 1. H. The > (B-field indirect with postincrement) mode H. Il> (B-campo indiretta con postincrement) modalità I'm sure by now you can guess what this mode does. Sono sicuro che da ora si può indovinare che cosa fa questa modalità. :)
V. A final warrior example V. Un esempio finale guerriero This warrior is the second one created by AK Dewdney, and known as the "Dwarf." Questo guerriero è la seconda quella creata da AK Dewdney, e conosciuta come la "Nano".The dwarf Il nano places DATs at intervals of 4 within the core. DAT posti a intervalli di 4 entro il nucleo.The following is the code for the dwarf. Di seguito è riportato il codice per il nano. CODE : CODICE:
Firstly, 4 is added to the B-field of the DAT instruction. In primo luogo, il 4 è aggiunto il B-campo della istruzione DAT.Then, the DAT is copied to 4 instructions in front Quindi, il DAT è copiato a 4 istruzioni di fronte of itself. di se stesso.Finally, the jump moves back 2 instructions, and 4 is added to the B-field in the DAT again. Infine, si muove il salto indietro istruzioni 2, e 4, è aggiunto il B-campo nel nuovo DAT.So, the Dwarf Quindi, il Nano simply copies DATs at 4, 8, 12, etc until it wraps around and starts copying all over again. semplicemente copie DAT a 4, 8, 12, ecc finché non si avvolge intorno e inizia la copia di tutto di nuovo.This type of warrior Questo tipo di guerriero is known as a "bomber." è noto come un "bombardiere".There are other types of warriors that will be discussed in a later article. Ci sono altri tipi di guerrieri che saranno discussi in un secondo articolo.
VI. Epilogue Epilogo Redcode is a very interesting language, to say the least. Redcode è una lingua molto interessante, per usare un eufemismo.It allows a programmer to hone his skills and Esso consente un programmatore per perfezionare le sue competenze e compete at the same time. competere allo stesso tempo.Hopefully, you've learned a thing or two from this article. Speriamo, che hai imparato una cosa o due da questo articolo.If not, I'm sure it was at least In caso contrario, sono sicuro che si è almeno a good review. una buona recensione.
Cast your vote on this article Cast il vostro voto su questo articolo *Note: the order of the votes has been reversed. * Nota: l'ordine delle votazioni è stato invertito.
Good work, must've taken a little while to write and put together. Buon lavoro, must've preso un po 'di tempo per scrivere e messi insieme.A thing or two was learned indeed. Una cosa o due è stata davvero imparato.
Tiak - 01:51 pm Saturday June 21st, 2008Tiak - 01:51 pm Sabato 21 Giugno 2008
I like the article, but the formatting is ugly now that it's posted. Mi piace l'articolo, ma la formattazione è brutto, ora che è distaccato.
shone - 05:48 pm Saturday June 21st, 2008brillò - 05:48 pm Sabato 21 Giugno 2008
Great article, real refreshment. Grande articolo, vero ristoro.I didn't know about this 'till now, but it sounds pretty interesting indeed. Non sapevo di questa 'fino ad ora, ma sembra piuttosto interessante in effetti.Great work! Gran lavoro!
apples - 02:34 pm Sunday June 22nd, 2008mele - 02:34 pm Domenica giugno 22, 2008
yeah, Tiak. yeah, Tiak.it was all nice and shiny, until HTS went and b0rked it up. è stato tutto bello e lucido, fino a quando è andato HTS e b0rked lo compongono.leave it to HTS to do something like that :P Lascio a HTS di fare qualcosa di simile: P
Seeing as you are a dev why don't you fix it. Vedendo come si sono uno sviluppatore perché non è risolvere il problema. :p : p
shone - 07:23 pm Monday June 23rd, 2008brillò - 07:23 pm Lunedi 23 Giugno 2008
Hey, apples, there is an error in "Dwarf" example: the first line of code should be "ADD #4, 3", not "ADD #4, @3". Ehi, mele, vi è un errore di "Nano" esempio: la prima riga di codice dovrebbe essere "ADD # 4, 3", non "ADD # 4, @ 3".That's how it was in the original "Dwarf" code. Ecco come è stato in originale "Nano" codice.This way the code will not run properly. In questo modo il codice non verrà eseguito correttamente.
apples - 10:35 am Tuesday June 24th, 2008mele - 10:35 am Martedì giugno 24, 2008
fixed! fisso!thanks, i never would've noticed. grazie, non ho mai notato che abbiamo.i'm curious as to why it doesn't work though, seeing as how it ends up adding to the B-field anyways. Sono curioso di vedere il motivo per cui non funziona se, visto che come si finisce per aggiungere al B-campo comunque.
youssef k - 11:50 pm Friday August 01st, 2008Youssef k - 11:50 pm Venerdì 01a agosto, 2008
good work brother, buon lavoro fratello, keep doing!! mantenere facendo! :)
hadik - 12:12 pm Tuesday August 26th, 2008hadik - 12:12 pm Martedì agosto 26, 2008
good work dude buon lavoro dude
webdracula - 04:07 am Friday August 29th, 2008webdracula - 04:07 am Venerdì agosto 29, 2008
Really helpfull, thank you. Veramente utile, la ringrazio.
where can i get the game? Dove posso trovare il gioco?
This site is the collective work of the HackThisSite staff. Questo sito è il contratto collettivo di lavoro del personale HackThisSite.Please don't reproduce in part or whole without permission. Si prega di non riprodurre in parte o in tutto senza permesso. Page Generated: Mon, 01 Dec 2008 20:54:12 -0500 Exec: 10 Pagina Generata: lun, 01 dicembre 2008 20:54:12 -0500 Esec: 10 Page loaded in 0.24797 seconds!Pagina caricata in 0,24797 secondi!
Good work, must've taken a little while to write and put together. Buon lavoro, must've preso un po 'di tempo per scrivere e messi insieme. A thing or two was learned indeed. Una cosa o due è stata davvero imparato.