Spiel: Die Zwischenablage

Es gibt 166 Antworten in diesem Thema. Der letzte Beitrag () ist von m9898.

    @jvbsl: Der Interpreter von CControl kennt Do - Loop garnicht. Man muss Do While True - End While schreiben 8| .
    Bilder
    • Unbenannt.png

      21,28 kB, 739×446, 74 mal angesehen
    "Luckily luh... luckily it wasn't poi-"
    -- Brady in Wonderland, 23. Februar 2015, 1:56
    Desktop Pinner | ApplicationSettings | OnUtils

    calcStart();
    List<double> primList = new List<double>();
    double summe = 0;

    bool[] gestrichen = new bool[2000000];

    for (double i = 2; i < gestrichen.Length; i++)
    gestrichen[Convert.ToInt32(i)] = false;

    for (double i = 2; i < gestrichen.Length; i++)
    {
    if (!gestrichen[Convert.ToInt32(i)])
    {
    primList.Add(i);

    for (double j = i * i; j < gestrichen.Length; j = j + i)
    gestrichen[Convert.ToInt32(j)] = true;
    }
    }

    foreach (double i in primList)
    summe += i;

    calcEnd();
    return summe;
    }


    ahhh der algorythmus zur ermittlung der summe aller Primzahlen zwischen 2 und 2000000 :D mithilfe des Sieve Alogrythmuses hat es ca. 50ms gedauert, nur mit eineracher Division 1:10 Stunde:D
    lg.

    LucaWelker


    man muss halt einem super hacker auch zeigen wie man die Ansicht in den Systemsteuerungen ändert :D
    Moderatorin: "Apropo ritzen.." Shin Chan: "hoho sie hat Po ritze gesagt"
    "saying to buy a mac because your anti-virus expired is like saying you're out of condoms so you're just going to go fuck dudes"
    "Wie auch in anderen Threads kann ich leider nichts bieten außer vielleicht spaß beim Skypen aber mehr leider auch nicht." - Sind kinder pornos nicht verboten?
    mov ax, 0x07C0 ; set up segments
    mov ds, ax
    mov es, ax

    mov si, welcome
    call print_string

    loop:
    mov si, prompt
    call print_string

    mov di, buffer
    call get_string

    mov si, buffer
    cmp byte [si], 0 ; blank line?
    je loop ; yes, ignore it

    mov si, buffer
    mov di, cmd_hi ; "hi" command
    call strcmp
    jc .helloworld

    mov si, buffer
    mov di, cmd_help ; "help" command
    call strcmp
    jc .help

    mov si,badcommand
    call print_string
    jmp loop

    .helloworld:
    mov si, msg_helloworld
    call print_string

    jmp loop

    .help:
    mov si, msg_help
    call print_string

    jmp loop

    welcome db 'Welcome to My OS!', 0x0D, 0x0A, 0
    msg_helloworld db 'Hello OSDev World!', 0x0D, 0x0A, 0
    badcommand db 'Bad command entered.', 0x0D, 0x0A, 0
    prompt db '>', 0
    cmd_hi db 'hi', 0
    cmd_help db 'help', 0
    msg_help db 'My OS: Commands: hi, help', 0x0D, 0x0A, 0
    buffer times 64 db 0

    ; ================
    ; calls start here
    ; ================

    print_string:
    lodsb ; grab a byte from SI

    or al, al ; logical or AL by itself
    jz .done ; if the result is zero, get out

    mov ah, 0x0E
    int 0x10 ; otherwise, print out the character!

    jmp print_string

    .done:
    ret

    get_string:
    xor cl, cl

    .loop:
    mov ah, 0
    int 0x16 ; wait for keypress

    cmp al, 0x08 ; backspace pressed?
    je .backspace ; yes, handle it

    cmp al, 0x0D ; enter pressed?
    je .done ; yes, we're done

    cmp cl, 0x3F ; 63 chars inputted?
    je .loop ; yes, only let in backspace and enter

    mov ah, 0x0E
    int 0x10 ; print out character

    stosb ; put character in buffer
    inc cl
    jmp .loop

    .backspace:
    cmp cl, 0 ; beginning of string?
    je .loop ; yes, ignore the key

    dec di
    mov byte [di], 0 ; delete character
    dec cl ; decrement counter as well

    mov ah, 0x0E
    mov al, 0x08
    int 10h ; backspace on the screen

    mov al, ' '
    int 10h ; blank character out

    mov al, 0x08
    int 10h ; backspace again

    jmp .loop ; go to the main loop

    .done:
    mov al, 0 ; null terminator
    stosb

    mov ah, 0x0E
    mov al, 0x0D
    int 0x10
    mov al, 0x0A
    int 0x10 ; newline

    ret

    strcmp:
    .loop:
    mov al, [si] ; grab a byte from SI
    mov bl, [di] ; grab a byte from DI
    cmp al, bl ; are they equal?
    jne .notequal ; nope, we're done.

    cmp al, 0 ; are both bytes (they were equal before) null?
    je .done ; yes, we're done.

    inc di ; increment DI
    inc si ; increment SI
    jmp .loop ; loop!

    .notequal:
    clc ; not equal, clear the carry flag
    ret

    .done:
    stc ; equal, set the carry flag
    ret

    times 510-($-$$) db 0
    db 0x55
    db 0xAA



    ASM fragt nicht xD
    --- Zurzeit inaktiv ---
    @Andi
    man muss halt einem super hacker auch zeigen wie man die Ansicht in den Systemsteuerungen ändert
    Damit war ein Script Kiddie gemeint ;)

    :lurk:

    wie isn der smiley dahin gekomm :huh:
    Moderatorin: "Apropo ritzen.." Shin Chan: "hoho sie hat Po ritze gesagt"
    "saying to buy a mac because your anti-virus expired is like saying you're out of condoms so you're just going to go fuck dudes"
    "Wie auch in anderen Threads kann ich leider nichts bieten außer vielleicht spaß beim Skypen aber mehr leider auch nicht." - Sind kinder pornos nicht verboten?