Backstage - OOC Forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

The last time someone attacked the Jovians, it was the Amarr, at Vak'atioth, and the Amarr fleet was crushed?

Author Topic: Real-looking code  (Read 2962 times)

Chevalleis

  • Clonejack
  • Offline Offline
  • Posts: 16
Real-looking code
« on: 16 Jun 2011, 02:28 »

So I was thinking of writing something that involves rogue drones, and I would like to add a few lines of programming 'code' here and there. I'm no expert in things like that so in hope that some of you might be, I decided to post this question here (am not even sure if it belongs here). So, how do I write wannabe-code that doesn't look like wannabe-code? It would mainly come for discussion between the drones and the hive mind, for exampl. Hive mind orders the drone to do something and I want to express how the hive mind does it. Ok this post is a bit messy but I hope that you'll get the idea.
Logged

Saede Riordan

  • Immoral Compass
  • Demigod
  • Offline Offline
  • Posts: 2656
  • Through the distorted lens I found a cure
    • All the cool hippies have tumblr
Re: Real-looking code
« Reply #1 on: 16 Jun 2011, 03:58 »

I have a 'character' that's an UIII, that operates out of Nikita's fluid router, and I wanted to distinguish her posts from Nikita's and make them vaguely codish. What I did was make it so that anything she said was technically edited out programming code. She edited the things she wanted to display as dialogue.
So it looked a bit like this:

Quote
//I have a 'character' that's an UIII, that operates out of Nikita's fluid router, and I wanted to distinguish her posts from Nikita's and make them vaguely codish.
//What I did was make it so that anything she said was technically edited out programming code. She edited the things she wanted to display as dialogue.
//So it looked a bit like this:
Logged
Personal Blog//Character Blog
A ship in harbour is safe, but that's not what ships are built for.

Horatius Caul

  • Words words words
  • Omelette
  • Offline Offline
  • Posts: 344
Re: Real-looking code
« Reply #2 on: 16 Jun 2011, 04:26 »

This has some fauxde (?).

EDIT: as does this.

Mithfindel

  • (a.k.a. Axel Kurki)
  • Pod Captain
  • Offline Offline
  • Posts: 695
Re: Real-looking code
« Reply #3 on: 16 Jun 2011, 06:16 »

If it doesn't need to be completely intelligible, I'd possibly use hex code, with plain-text strings. Or pieces of a program in some assembler language, as it's relatively little known these days. The idea with assembler is to use the "worst practices": Rename tokens into something that suggest the code does something different than it does and remove all comments. The messages you want to get thru can be placed on strings. That way, most might still identify that it is code, but most will be unable to figure out what it does.

Examples that print "Hello, World!" in various assembler languages (from http://www.roesler-ac.de/wolfram/hello.htm):
[spoiler]
Code: [Select]
                        .TITL HELLO
02                      ; "HELLO, WORLD" FOR NOVA RUNNING RDOS
03                      ; USES PCHAR SYSTEM CALL
04                      .NREL
05                      .ENT START
06
07              START:
08 00000'022424 DOCHAR: LDA 0,@PMSG     ; LOAD AC0 WITH NEXT CHARACTER,
09 00001'101015         MOV# 0,0,SNR    ; TEST AC0;
10 00002'000412          JMP DONE ; SKIPPED IF NONZERO
11 00003'006017         .SYSTM
12 00004'010000         .PCHAR          ; PRINT FIRST
13 00005'000413          JMP ER ; SKIPPED IF OK
14 00006'101300         MOVS 0,0        ; SWAP BYTES
15 00007'006017         .SYSTM
16 00010'010000         .PCHAR          ; PRINT SECOND
17 00011'000407          JMP ER ; SKIPPED IF OK
18 00012'010412         ISZ PMSG        ; POINT TO NEXT WORD
19 00013'000765         JMP DOCHAR      ; GO AROUND AGAIN
20
21 00014'006017 DONE:   .SYSTM          ; NORMAL EXIT
22 00015'004400         .RTN
23 00016'000402          JMP ER
24 00017'063077         HALT
25 00020'006017 ER:     .SYSTM          ; ERROR EXIT
26 00021'006400         .ERTN
27 00022'063077          HALT
28 00023'063077         HALT
29
30 00024'000025'PMSG:   .+1     ; ADDRESS OF FIRST WORD OF TEXT
31                      ; NOTE BYTES ARE PACKED RIGHT-TO-LEFT BY DEFAULT
32 00025'042510         .TXT /HELLO, WORLD!<15><12>/ ; THAT'S CR LF
33       046114
34       026117
35       053440
36       051117
37       042114
38       006441
39       000012
40 00035'000000         0 ; FLAG WORD TO END STRING
41
42                      .END START
[/spoiler]
[spoiler]
Code: [Select]
/* Hello world for IA64 (Itanium) Assembly */

.HW:
        stringz "Hello World"
        .text
        .align 16
        .global main#
        .proc main#
main:
        .prologue 14, 32
        .save ar.pfs, r33
        alloc r33 = ar.pfs, 0, 4, 1, 0
        .vframe r34
        mov r34 = r12
        adds r12 = -16, r12
        mov r35 = r1
        .save rp, r32
        mov r32 = b0
        .body
        addl r14 = @ltoffx(.HW), r1
        ;;
        ld8.mov r14 = [r14], .HW
        ;;
        st8 [r34] = r14
        ld8 r36 = [r34]
        br.call.sptk.many b0 = puts#
        mov r1 = r35
        ;;
        mov ar.pfs = r33
        mov b0 = r32
        .restore sp
        mov r12 = r34
        br.ret.sptk.many b0
[/spoiler]
[spoiler]
Code: [Select]
;; Hello World for the nasm Assembler (Linux)

SECTION .data

msg db "Hello, world!",0xa ;
len equ     $ - msg

SECTION .text
global main

main:
        mov     eax,4 ; write system call
        mov     ebx,1           ; file (stdou)
        mov     ecx,msg         ; string
        mov     edx,len         ; strlen
int     0x80 ; call kernel

mov eax,1 ; exit system call
        mov     ebx,0     
        int     0x80 ; call kernel
[/spoiler]
[spoiler]
Code: [Select]
## Hello Word in Assemlber for the MIPS Architecture

.globl main

main:   jal hwbody              #call Hello Word Procedure
       trap 10                 #exit

hwbody: addi $30, $30,-4        #we need to preserve
       sw $4, 0($30)           #existing values in register 4

       addi $4,$0,72           # H
       trap 101
       addi $4,$0,101          # e
       trap 101
       addi $4,$0,108          # l
       trap 101
       trap 101                # l
       addi $4,$0,111          # o
       trap 101
       addi $4,$0,32           # <space>
       trap 101
       addi $4,$0,87           # W
       trap 101
       addi $4,$0,111          # o
       trap 101
       addi $4,$0,114          # r
       trap 101
       addi $4,$0,108          # l
       trap 101
       addi $4,$0,100          # d
       trap 101
       addi $4,$0,33           # !
       trap 101
       addi $4,$0,10           # \n
       trap 101

done:   lw $4, 0($30)           #restore values
       addi $30, $30, 4        #in register 4
       jr $31                  #return to the main
[/spoiler]
[spoiler]
Code: [Select]
// Hello World written in PA-RISC 2.0 assembly code

    .LEVEL  2.0N

    .SPACE  $TEXT$,SORT=8
    .SUBSPA $CODE$,QUAD=0,ALIGN=4,ACCESS=0x2c,CODE_ONLY,SORT=24
main
    .PROC
    .CALLINFO CALLER,FRAME=16,SAVE_RP,ORDERING_AWARE
        .ENTRY
        STW     %r2,-20(%r30)   ;offset 0x0
        LDO     64(%r30),%r30   ;offset 0x4
        ADDIL   LR'M$3-$global$,%r27,%r1        ;offset 0x8
        LDO     RR'M$3-$global$(%r1),%r1        ;offset 0xc
        STW     %r1,-56(%r30)   ;offset 0x10
        ADDIL   LR'M$3-$global$+16,%r27,%r1     ;offset 0x14
        LDO     RR'M$3-$global$+16(%r1),%r26    ;offset 0x18
        LDW     -56(%r30),%r25  ;offset 0x1c
        LDIL    L'printf,%r31   ;offset 0x20
        .CALL   ARGW0=GR,ARGW1=GR,RTNVAL=GR     ;in=25,26;out=28;
        BE,L    R'printf(%sr4,%r31),%r31        ;offset 0x24
        COPY    %r31,%r2        ;offset 0x28
        LDW     -84(%r30),%r2   ;offset 0x2c
        BVE     (%r2)   ;offset 0x30
        .EXIT
        LDO     -64(%r30),%r30  ;offset 0x34
    .PROCEND    ;


    .SPACE  $TEXT$
    .SUBSPA $CODE$
    .SPACE  $PRIVATE$,SORT=16
    .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=16
M$3
    .ALIGN  8
    .STRINGZ    "Hello World"
    .BLOCK  4
    .STRINGZ    "%s\n"
    .IMPORT $global$,DATA
    .SPACE  $TEXT$
    .SUBSPA $CODE$
    .EXPORT main,ENTRY,PRIV_LEV=3,LONG_RETURN
    .IMPORT printf,CODE
    .END
[/spoiler]
(The code tag shows only two lines at a time in scrollable frames for me above - likely easier to have a look at the source page.)
« Last Edit: 16 Jun 2011, 06:22 by Mithfindel »
Logged

Kybernetes Moros

  • Guest
Re: Real-looking code
« Reply #4 on: 16 Jun 2011, 06:31 »

As regards fauxde (love that term, by the by), I'd stick to something closer to the stuff in The Precious Tableau: the rough purpose of it is clear without being too similar to anything currently existing in reality -- it doesn't go on about, to use an example, .exe files, which aren't universal now, let alone millenia in the future. The nice thing about The Precious Tableau, I suppose, is that while it's definitely reminiscent of debugging that really shouldn't be displayed during a program's normal operation, the ideas there are easily adaptable, but I imagine you'll be fine as long as you're not, say, throwing lines of C or Perl or whatever wholesale. Big cluster, lots of programming languages, and so on.

It depends what you're after, I guess; Mithfindel's assembly is a lot lower-level and closer to the machine's operation than the stuff in The Precious Tableau, for instance.
« Last Edit: 16 Jun 2011, 06:33 by Kybernetes Moros »
Logged

Mizhara

  • Prophet of New Eden
  • Demigod
  • Offline Offline
  • Posts: 2545
  • The Truth will make ye Fret.
Re: Real-looking code
« Reply #5 on: 16 Jun 2011, 06:39 »

if, then

Done.
Logged


Saede Riordan

  • Immoral Compass
  • Demigod
  • Offline Offline
  • Posts: 2656
  • Through the distorted lens I found a cure
    • All the cool hippies have tumblr
Re: Real-looking code
« Reply #6 on: 16 Jun 2011, 08:52 »

using faux python means you can basically take any sentence and convert it into code.

I need more barrage M" becomes "Self:Req[(Barrage_M)quant=>Self:current]"
Logged
Personal Blog//Character Blog
A ship in harbour is safe, but that's not what ships are built for.

Casiella

  • Demigod
  • Offline Offline
  • Posts: 3723
  • Creation is so precious, and greed so destructive.
Re: Real-looking code
« Reply #7 on: 16 Jun 2011, 09:06 »

Hm. You could probably use nullsec system/constellation names and W-space loci as memory addresses and operands in assembly language "fauxde".
Logged

Lyn Farel

  • Guest
Re: Real-looking code
« Reply #8 on: 16 Jun 2011, 10:04 »

What is "fauxde" ?
Logged

Chevalleis

  • Clonejack
  • Offline Offline
  • Posts: 16
Re: Real-looking code
« Reply #9 on: 16 Jun 2011, 10:13 »

From what google tells me I think it means the same as faux, which is french for false.
Logged

Lyn Farel

  • Guest
Re: Real-looking code
« Reply #10 on: 16 Jun 2011, 10:19 »

Yes, but im probably disturbed precisely because im french. I know faux, I don't understand why a "de" is added after and what is the final meaning and use for the word, its not obvious :/

So it just means false ? Fake ?
Logged

Casiella

  • Demigod
  • Offline Offline
  • Posts: 3723
  • Creation is so precious, and greed so destructive.
Re: Real-looking code
« Reply #11 on: 16 Jun 2011, 10:23 »

It's a punny portmanteau of "faux" and "code". Fake code.
Logged

Horatius Caul

  • Words words words
  • Omelette
  • Offline Offline
  • Posts: 344
Re: Real-looking code
« Reply #12 on: 16 Jun 2011, 11:58 »

What Cas said.

Shintoko Akahoshi

  • Red Mom of War(?)
  • Pod Captain
  • Offline Offline
  • Posts: 540
  • Red Mom of War!
Re: Real-looking code
« Reply #13 on: 16 Jun 2011, 12:09 »

I'd avoid faux code, if I were you, but that's just me. You're not going to be able to produce anything that is anything other than window dressing, which won't really add to the story.

In Gateway, Fred Pohl does use the "I'll include computer code in a sidebar to illustrate what's going on between Robin and Sigfried" trick, but I'd argue that he did it mainly because the idea of software that can communicate as well as a human was new enough that he needed it to push the reader into the proper frame of mind. We all know what rogue drones are, so you don't need to do this to get the point across.

If you think about rogue drones, they're sentient. They have social organization. I'd wager that their social organization is based on swarm behavior governed by mutual message passing. If you really want to add something that illustrates rogue drone behavior, I'd do it from a message passing point of view.