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-15 17:30

;; BUFFA.asm
;; @Author  --    Gerald Jay Sussman
;; Assemble with nasm -f elf BUFFA.asm
;; Link with ld --dynamic-linker /lib/ld-linux.so.2 -lc BUFFA.o -o BUFFA

%macro     exit 1
    mov    eax, 1
    mov    ebx, %1
    int    0x80
%endmacro

%macro     write 1
    mov    dword [ecx], %1
    mov    eax, 4
    mov    ebx, 1
    mov    edx, 1
    int    0x80
%endmacro

section .data
err:    dw    "Usage: %s [food_for_BUFFA]", 0xa
rwe:    dw    "BUFFA doesn't eat %c's", 0xa

section .text
    extern    printf
    global    _start

_start:
    pop    ebx
    cmp    ebx, 0x1
    je    .usage
    pop    eax
    pop    ecx
    xor    ebx, ebx
    xor    edx, edx
.doloop:
    mov    eax, [ecx+edx]
    cmp    al, 0x0
    je    .die
    call    read_and_write
    inc    edx
    jmp    .doloop
.die:
    write    0xa
    exit    0
.usage:
    pop    ebx
    mov    ebp, esp

    push    ebx
    push    err
    call    printf

    exit    1

read_and_write:
    cmp    al, 0x61
    je    .a
    cmp    al, 0x62
    je    .b
    cmp    al, 0x63
    je    .c
    jmp    .err
.a:
    inc    ebx
    jmp    .ret
.b:
    dec    ebx
    jmp    .ret
.c:
    call    print_buffa
    jmp    .ret
.ret:
    ret
.err:
    mov    ebp, esp

    push    eax
    push    rwe
    call    printf

    exit    2

print_buffa:
    pusha
    write    ebx
    popa
    ret

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