Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ITT the ABC Programming Language

Name: Anonymous 2008-07-29 19:29

#include <stdio.h>

int main(int argc,char argv*[]){
  int i = 0;
  int BUFFA;

  while(argv[i]!='\0'){
    if(argv[i]='a')
      BUFFA++;
    else if(argv[i]='b')
      BUFFA--;
    else if(argv[i]='c')
      printf("%i\n",BUFFA);
    else printf("%s","Error.\n");
  }
}

Name: Anonymous 2010-08-17 3:13

This is the HMA gate. It requires the presence of both an anus and a haxor. Note that it is distinct from the AND gate.


 anus haxor | out
------------+----------
    0     0 | 0
    0     1 | 0
    1     0 | 0
    1     1 | HAX MY ANUS

Name: Anonymous 2010-08-18 19:12

>>307
this is how realEXPERTS make use of the cpp:

#define IF(condition, statement)                \
        do {                                    \
                if ( (condition) ) {            \
                        (statement);            \
                }                               \
        } while (0)

Name: Anonymous 2010-08-18 19:41

>>322
FV-style for decreased code size; uses GNU extensions.
#define F(a,...) ((a)?:(__VA_ARGS__))

Name: Anonymous 2010-08-18 19:51

>>322
EXPERT RECURSION

Name: Anonymous 2010-08-18 19:52

>>323
uses GNU extensions.
enjoy your non standard compliant code, ``faggot''.

Name: Anonymous 2010-08-18 20:15

EXPERT GOLF SOLUTION:
{57- 1^}%'+'/'.p'*0\~;

Map x-57 xor 1: a -> ')' (golfscript increment), b -> '(' (golfscript decrement), c -> '+'. Split over '+', join array with '.p' (golfscript print), push 0, swap, execute, pop.

Name: Anonymous 2010-08-18 20:18

>>325
So what's the point of programming when you don't make use of useful features to help with your problem?

Name: Anonymous 2010-08-18 20:28

>>327
So what's the point of programming when you don't make use of useful features to help with your problem?
standard compliance == portability.
protip: not everyone uses Java

Name: Anonymous 2010-08-18 20:37

>>328
So write a couple of functions when you need them. It's not that hard.

Name: Anonymous 2010-08-18 20:49

>>329
gnu extensions != a couple of functions.
back to the imageboards, ``faggot''.

Name: Anonymous 2010-08-19 2:34

>>330
If you only use a couple of them (which realistically you will), it's only a couple of functions.

Name: Anonymous 2010-08-19 3:59

>>329,331
They're not functions. They're language extensions.

Name: >>331 2010-08-19 4:43

>>332
I don't mean ``functions'' in the sense of ``procedures'' or ``subroutines'', I meant it in the sense of ``functionality''.

Name: Anonymous 2010-08-19 11:01

>>333
WHBT

Name: Anonymous 2010-08-19 14:32

Can anyone link me to the design documents for this language?

Name: Anonymous 2010-08-19 14:52

>>335

I just realized it was a bad idea to sage considering it was off the front page.

What I'm really wondering is if the language is supposed to work like >>53 writes it? Is the ``l'' command supposed to create an infinite loop? Also shouldn't i get set to -1 so the first part of args[0] doesn't get ignored?

Name: Anonymous 2010-08-19 15:27

Google is hard.

Name: Anonymous 2010-08-19 15:33

>>337

Of course I tried to Google it, however searching for ``the ABC programming language'' yields results about a quite different language.

Name: Anonymous 2010-08-19 16:32

>>338
...a language that forces the indentation of code, thread over.

Name: Anonymous 2010-08-20 3:13

>>338
Read the fucking thread. >>185

Name: ​​​​​​​​​​ 2010-09-08 21:49

Name: Anonymous 2010-12-06 9:16

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2011-01-02 2:45

This thread has been indirectly mentioned in

http://dis.4chan.org/read/prog/1293952421

Name: Anonymous 2011-01-02 19:50

bampu

Name: Anonymous 2011-01-02 21:32

How do you interpret r - Set accumulator to a random number between 0 and accumulator?

Is the accumulator now strictly between 0 and its previous value, or is 0 included in the set of possible values?

Name: Anonymous 2011-01-02 21:43

>>347
Simulate a dice throw:
aaaaarac
In the example above (from esolang) the interval would be [0, 5).

In english: Set the accumulator to a random value between 0 inclusive and the accumulator exclusive.

Name: Anonymous 2011-01-02 22:16

>>348

OK, thank you, may I also ask you how you interpret d - Invert accumulator?

Name: Anonymous 2011-01-02 22:40

All right I have a pseudo-working implementation, my former implementation was completely crippled, this implementation is only severely crippled by lacking error handling and the handling of the `;' character, it also assumes that the accumulator is unsigned, which it judging by the phone number example isn't.

;; abc.asm
;; @Author Gerald Jay Sussman
;; Assemble with $ nasm -f elf abc.asm
;; Link with     $ ld -s -o abc abc.o

%define PFBLEN    0xff

%macro    write    2
    pusha
    mov    ecx, %1
    mov    edx, %2
    mov    eax, 4
    mov    ebx, 1
    int    0x80
    popa
%endmacro

section    .bss
printf_buffer:    resw    PFBLEN
char_buffer:    resw    2
argc:        resw    2
randfd:        resw    2
randint:    resw    2

section    .data
error:    dw    "An error occured.", 0xa, 0
randf:    dw    "/dev/urandom", 0
newl:    dw    0xa
ascii:    db    0

section    .text
    global    _start

_start:
    pop    eax
    cmp    eax, 1
    jle    .error

    mov    [argc], eax

    mov    eax, 5
    mov    ebx, randf
    xor    ecx, ecx
    int    0x80

    mov    [randfd], eax

    pop    eax
    pop    ecx
    xor    edx, edx
    xor    ebx, ebx
.loop:
    mov    eax, [ecx + edx]

    cmp    al, 0x0
    je    .next

    cmp    al, 'a'
    je    .a
    cmp    al, 'b'
    je    .b
    cmp    al, 'c'
    je    .c
    cmp    al, 'd'
    je    .d
    cmp    al, 'r'
    je    .r
    cmp    al, 'n'
    je    .n
    cmp    al, '$'
    je    .cash
    cmp    al, 'l'
    je    .l
    cmp    al, 0x3b
    je    .dbg
.bottl:
    inc    edx
    jmp    .loop
.fin:
    mov    eax, 1
    mov    ebx, 0
    int    0x80
.next:
    write    newl, 1
    dec    dword [argc]
    cmp    dword [argc], 1
    jle    .fin
    pop    ecx
    xor    edx, edx
    jmp    .loop
.error:
    write    error, randf - error

    mov    eax, 1
    mov    ebx, 1
    int    0x80
.a:
    inc    ebx
    jmp    .bottl
.b:
    dec    ebx
    jmp    .bottl
.c:
    cmp    byte [ascii], 0
    je    .asint
.aschar:
    mov    dword [char_buffer], ebx
    write    char_buffer, 1
    jmp    .bottl
.asint:
    mov    eax, ebx
    call    print_eax_int
    jmp    .bottl
.d:
    neg    ebx
    jmp    .bottl
.r:
    pusha
    push    ebx
    mov    eax, 3
    mov    ebx, [randfd]
    mov    ecx, randint
    mov    edx, 8
    int    0x80

    pop    ebx
    inc    ebx
    xor    edx, edx
    mov    eax, [randint]
    idiv    ebx
    mov    [randint], edx
    popa
    mov    ebx, [randint]
    jmp    .bottl
.n:
    xor    ebx, ebx
    jmp    .bottl
.cash:
    xor    byte [ascii], 1
    jmp    .bottl
.l:
    xor    edx, edx
    jmp    .loop
.dbg:
    jmp    .error

print_eax_int:
    pusha
    lea    ecx, [printf_buffer + PFBLEN]
.loop:
    sub    ecx, 4

    xor    edx, edx
    mov    ebx, 10
    idiv    ebx
    add    edx, 0x30
   
    mov    [ecx], edx

    cmp    eax, 0
    jle    .ret

    jmp    .loop
.ret:
    mov    eax, 4
    mov    ebx, 1
    lea    edx, [printf_buffer + PFBLEN]
    sub    edx, ecx
    int    0x80
    popa
    ret

Name: Anonymous 2011-01-03 11:02

>>350
Finally, another /prog/lodyte who enjoys the art of intel asm

Heil!

Name: Anonymous 2011-01-03 12:30

>>351

You may note that my knowledge of the instruction set is extremely limited, but I'm learning.

Name: Anonymous 2011-01-04 19:36

How often on average will the abc line ``arcl'' output a natural integer n?

Name: Anonymous 2011-01-04 19:39

>>353

If you count 0 a "natural integer", all the time.

I presume you meant to say a given natural number?

Name: Anonymous 2011-01-05 11:41

I have two improved versions of the string and integer printers for the abc program.

section    .bss
intbuf:    resb    32

section    .text
    global    print_signed
    global    print_str

print_signed:
    pushad
    lea    ecx, [intbuf + 32]

    bsr    ebx, eax
    cmp    ebx, 31
    pushf
    jne    .loop
    neg    eax
.loop:
    dec    ecx

    xor    edx, edx
    mov    bl, 10
    div    ebx

    add    dl, 0x30
    mov    [ecx], dl

    cmp    eax, 0
    je    .end

    jmp    .loop
.end:
    popf
    jne    .ret
    dec    ecx
    mov    byte [ecx], '-'
.ret:
    mov    eax, 4
    mov    ebx, 1
    lea    edx, [intbuf + 32]
    sub    edx, ecx
    int    0x80
    popad
    ret

print_str:
    pushad
    push    eax
    mov    edi, eax

    xor    ecx, ecx
    xor    al, al
    not    ecx
    cld
    repne    scasb
    not    ecx
    lea    edx, [ecx - 1]
    pop    ecx

    mov    eax, 4
    mov    ebx, 1
    int    0x80
    popad
    ret


Definitely maintainable, don't you think?

Name: Anonymous 2011-01-05 12:43

/prog/ CHALLENGE:
Make a compiler for The ABC Programming Language

Only ABC->ASM are allowed!
ABC->C compilers are banned as one has already been implemented by >>142.


Requirements:
• Must fully adhere to the “The ABC Programming Language  Specification” described in The ABC Programming Language page on Esolangs.org[1]
• One can implement non-standard extensions to the language as long they don't break compatibility with the standard[1].

Bonus points if:
• It's an optimising compiler.
• Has flags to switch optimisations on/off.
• It's written in fully POSIX-compliant C code. (if using another language, it must be executable on every POSIX-compliant system)
• It writes directly an ELF executable or equivalent.
• The generated code is efficient.
• The compiler is written in well-written, efficient and idiomatic code.

--
References:
[1] http://esolangs.org/wiki/ABC

Name: Anonymous 2011-01-05 13:16

>>356

May I make it write assembly and then pipe that to some assembler, or must it directly write opcodes to file?

Name: Anonymous 2011-01-05 13:24

>>357
Making yourself the opcodes to file gives you bonus points.

Name: Anonymous 2011-01-05 19:45

>>358

May I link with my favorite copy of a C library?

Name: Anonymous 2012-08-04 14:37

WARNING: NECROBUMP; DO NOT REPLY

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List