Announcement

Collapse
No announcement yet.

Rückgabe aus UP per Stack

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rückgabe aus UP per Stack

    Hallo @all,

    hab mich nach tausend Jahren an eine alte ASM-Prüfung gemacht um wieder reinzukommen da ich demnächst eine Nachprüfung schreiben muss.
    Aufgabe ist kurzgefasst folgende: 1. Passwortüberprüfung
    2. Eingabe 2er Zahlen
    3. diese beiden Addieren und Multiplizieren

    musste leider fast alles in die main klatschen, da es in der Aufgabe so gefordert ist, nur die Berechnung soll in Upen erfolgen und ich hätte dazu ein paar Fragen:

    1. Die Übergabe der Params und die Rückgabe der Ergebnisse soll über den Stack laufen, dazu reserviere ich soweit ich das gelesen hab Bytes im Stack und pop diese nach Aufruf des Ups. Leider erhalte ich mein Ergebnis nur ohne dem pop(siehe Addition), könnt Euch dass ja mal anschauen denn ich glaube ich mache da was vollkommen falsch, da ich nur mit Tricks die Ergebnisse angezeigt bekomme

    2. ich soll am Anfang eine Passwortabfrage einbauen Zitat: "Überlegen Sie, wie Sie das Passwort im Datensegment ablegen, damit die einzelnen Zeichen des Passworts nicht einfach hintereinander folgen", heißt dass ich speichere das eingegebene Pw erstmal gesamt im Puffer und shifte sie dann zum Beispiel oder was wäre der richtige Weg? (Das Original-PW darf unverschlüsselt vorliegen.)

    3. nochmal die Passwortabfrage, bevor ich sie einbaute hat mein Programm noch vollkommen funktioniert danach lässt sich die Multiplikation nicht mehr ausführen(Text wird nicht angezeigt und dass Ergebnis spuckt wilde Zeichen aus) es scheint mir fast so nach dem debuggen als wird das Cursor setzen, Ausgabe von "Multiplikation:" und der call vom Up einfach nach der Addition übersprungen, es ist auch komisch, wenn ich das setcursor vor der Multipli auskommentiere sogar die Addition nicht mehr funktioniert. Ich glaube dass hängt mit 1. und eben dieser Passwortabfrage zusammen

    und nun zum Prog(in TASM):
    Code:
    .model small
    .stack 100h
    .data
    
    ;+++++++++++++++++
    ;    Textzeug
    ;+++++++++++++++++
    
    txErg db 'Ergebnis$'
    txMul db 'Multiplikation: $'
    txAdd db 'Addition: $'
    txName db 'MeinName$'
    txPass db 'Passwort: $'
    txMatr db 'DasPwd$'
    txPw1 db 'Passwort richtig!$'
    txPw0 db 'Passwort nicht richtig!$'
    txWeit db 'Weiter mit ENTER$'
    txZahl1 db 'Zahl 1 eingeben: $'
    txZahl2 db 'Zahl 2 eingeben: $'
    txZeile db 00h, 0ah, "$"
    puffer db 20 dup(020)
    
    .code
    
    ;++++++++++++++++++
    ;     Makros
    ;++++++++++++++++++
    
    bsloesch macro anz, attr, ylo, xlo, yru, xru 
    push ax bx cx dx
    mov ah, 6
    mov al, anz
    mov bh, attr
    mov ch, ylo
    mov cl, xlo
    mov dh, yru
    mov dl, xru
    int 10h
    pop dx cx bx ax
    endm
    
    setcursor macro zeile, spalte
    push ax dx bx
    mov ah, 2
    mov dh, zeile
    mov dl, spalte
    mov bh, 0
    int 10h
    pop bx dx ax
    endm
    
    ;++++++++++++++++
    ;   Unterprogs
    ;++++++++++++++++
    
    addition proc near
    push bp
    mov bp, sp
    mov ax, WORD PTR [bp+6]
    add ax, WORD PTR [bp+4]
    mov sp, bp
    pop bp
    ret
    addition endp
    
    multiplikation proc near
    push bp
    mov bp, sp
    mov ax, WORD PTR [bp+6]
    mul WORD PTR [bp+4] 
    
    mov sp, bp
    pop bp
    ret
    multiplikation endp
    
    ;++++++++++++++++
    ;   Hauptprog
    ;++++++++++++++++
    
    start:
    
    ;++++++++++++
    ;++init Zeugs
    mov ax, @data
    mov ds, ax
    sub sp, 2
    
    ;+++++++++++++
    ;++Erste Seite
    
    anf:
    mov ax, 0002h
    int 10h
    setcursor 3, 10
    
    ;++++++
    ;++Name
    mov ah, 9
    lea dx,  txName
    int 21h
    
    ;++++++++++
    ;++Passwort
    setcursor 8, 10
    mov ah, 9
    lea dx,  txPass
    int 21h
    lea di, puffer
    pwein:
    mov ah, 7
    int 21h
    cmp al, 0dh
    je endpw
    stosb
    mov ah, 14
    mov al, 42
    int 10h
    jmp pwein
    endpw:
    lea si, txMatr
    lea di, puffer
    vergleiche:
    cmpsb
    je vergleiche
    dec si
    lodsb
    cmp al, '$'
    jne falsch
    setcursor 10, 10
    lea dx, txPw1
    mov ah, 9
    int 21h
    jmp pwok
    falsch:
    setcursor 10, 10
    lea dx, txPw0
    mov ah, 9
    int 21h
    jmp anf
    pwok:
    
    
    ;+++++++++++++
    ;++warte Enter
    setcursor 20, 54
    mov ah, 9
    lea dx,  txWeit
    int 21h
    warte:
    mov ah, 01h
    int 21h
    cmp al, 0dh
    jne warte
    
    ;++++++++++++
    ;++BS löschen
    mov ax, 0002h
    int 10h
    
    ;++++++++++++++++++
    ;++Eingabe 1te Zahl
    setcursor 3, 10
    lea dx,  txZahl1
    mov ah, 9
    int 21h
    mov di, 5  
    mov cx,10
    mov bx, 0
    mov dx, 0
    eingabe:
    mov ah, 01h
    int 21h     
    cmp al, 0dh
    je endein
    sub al, 30h
    mov dl, al  
    mov ax, bx
    mov bx, 0
    mov bl, dl
    mul cx
    add ax, bx
    mov bx, ax
    dec di
    cmp di, 0
    ja eingabe
    endein:
    mov ax, bx
    push ax
    
    ;++++++++++++++++++
    ;++Eingabe 2te Zahl
    setcursor 4, 10
    lea dx,  txZahl2
    mov ah, 9
    int 21h
    mov di, 5 
    mov cx, 10
    mov bx, 0
    mov dx, 0
    eingabe2:
    mov ah, 01h
    int 21h      
    cmp al, 0dh
    je endein2
    sub al, 30h
    mov dl, al  
    mov ax, bx
    mov bx, 0
    mov bl, dl
    mul cx
    add ax, bx
    mov bx, ax
    dec di
    cmp di, 0
    ja eingabe2
    endein2:
    mov ax, bx
    push ax
    
    setcursor 7, 10
    lea dx,  txErg
    mov ah, 9
    int 21h
    setcursor 8,10
    lea dx,  txAdd
    mov ah, 9
    int 21h
    
    ;++++++++++++++++++++++
    ;++Addition und Ausgabe
    call addition
    mov bx, 10
    mov cx, 0
    teile1:
    cmp ax, bx
    jb kleiner1
    mov dx, 0
    div bx
    inc cx
    jmp teste1
    kleiner1:
    mov dx, ax
    inc cx
    mov ax, 0
    teste1:
    push dx
    cmp ax, 0
    jne teile1
    ausgabe1:
    pop dx
    mov ax, dx
    add al, 30h
    mov ah, 14
    int 10h
    dec cx
    cmp cx, 0
    jne ausgabe1
    
    ;++++++++++++++++++++++++++++
    ;++Multiplikation und Ausgabe
    setcursor 9, 10
    lea dx,  txMul
    mov ah, 9
    int 21h
    
    call multiplikation
    mov bx, 10
    mov cx, 0
    teile2:
    cmp ax, bx
    jb kleiner2
    mov dx, 0
    div bx
    inc cx
    jmp teste2
    kleiner2:
    mov dx, ax
    inc cx
    mov ax, 0
    teste2:
    push dx
    cmp ax, 0
    jne teile2
    ausgabe2:
    pop dx
    mov ax, dx
    add al, 30h
    mov ah, 14
    int 10h
    dec cx
    cmp cx, 0
    jne ausgabe2
    
    ;+++++++++++++ 
    ;++warte Enter
    setcursor 24, 54
    mov ah, 9
    lea dx,  txWeit
    int 21h
    warte2:
    mov ah, 01h
    int 21h
    cmp al, 0dh
    jne warte2
    
    ;++++++
    ;++Ende
    ende:
    mov ax, 4c00h
    int 21h
    
    
    
    end start

  • #2
    Problem gelöst

    das Unterprogramm war zu weit weg, ich habe es dann einfach an das Ende der Hauptfkt verschoben

    kann geschlossen werden

    Comment

    Working...
    X