나는이 코드를 emu8086에 작성했습니다.
에뮬레이션을 누르면 코드를 컴파일하는 데 오랜 시간이 걸리고 컴파일 될 때 이상하게 작동합니다. (main으로 점프하는 대신 max 등의 함수로 점프)emu8086 - 컴파일하는 데 오랜 시간이 걸리며 프로그램이 작동하지 않습니다.
"magshimim.inc"에 문제가 있다고하기 전에 다른 파일에서 작동합니다.
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
EMU에서 코드를 실행하고 시작하자 마자 메인 코드로 바로 넘어갔습니다. –
내 PC에 문제가 있다고 생각합니다. – tomgrin10
이렇게하십시오 : "최대"절차를 잘라 최종 "ret"아래에 붙여 넣으십시오. –