Ich habe diesen Code in emu8086 geschrieben.
Wenn ich emulieren, dauert es sehr lange, den Code zu kompilieren und wenn es kompiliert wird, funktioniert es merkwürdig falsch. (statt zum Haupt springen springt es auf die Funktion Max etc.)emu8086 - Kompilieren dauert eine sehr lange Zeit und das Programm funktioniert nicht
Und bevor Sie sagen, es könnte ein Problem mit "magshimim.inc", gibt es nicht, es funktioniert in anderen Dateien.
include magshimim.inc
org 100h
jmp main
;--------------------------------------------;
; Functions
;--------------------------------------------;
; This function gets 2 numbers and an address.
; It stores the biggest number in the address.
; Input:
; push result_address
; push num1
; push num2
PROC max
; store offset of parameters relative to bp
result_p equ 6
num1 equ 4
num2 equ 2
push bp ; store the previous stack frame
mov bp, sp ; create new stack frame
push ax ; store ax
mov ax, [bp+num1]
cmp ax, [bp+num2]
jng num1_bigger_num2
num1_bigger_num2:
mov ax, [bp+num1]
mov [[bp+result_p]], ax
jmp skip1
num1_not_bigger_num2:
mov ax, [bp+num2]
mov [[bp+result_p]], ax
skip1:
pop ax ; re-store ax
mov sp, bp ; close stack frame
pop bp ; re-store the previous stack frame
ret
ENDP
;--------------------------------------------;
; Global variables
;--------------------------------------------;
result dw 0
num0 dw 2
num1 dw 10
;--------------------------------------------;
; Main
;--------------------------------------------;
main:
push offset result
push num0
push num1
call max
add sp, 6
mov ax, result
call print_num
mov ah, 0
int 16h
ret
Ich habe gerade Ihren Code in meiner EMU und es sprang zum Haupt, sobald es begann. –
Ich denke, es ist ein Problem in meinem PC. – tomgrin10
Tun Sie dies: Schneiden Sie den Vorgang "max" und fügen Sie es unter dem endgültigen "ret". –