[assembly] ascending sort 코드를 작성했는데 정상적으로 작동하지 않고 있습니다. 이유가 뭘까요?
글쓴이: 익명 사용자 / 작성시간: 토, 2023/05/20 - 12:52오전
; 5개의 정수(음수 포함)를 입력받고 이를 오름차순으로 정렬하여 출력한다.
AREA text, CODE
; This section is called "text", and contains code
ENTRY
IMPORT scan
IMPORT print_char
IMPORT divide
IMPORT print_number
IMPORT print
mov r10, #0×80000004
add r9, r9, #10
mov r6, #5
five_input
cmp r6, #0
bl scan
bl print_char
cmp r0, #10
moveq r0, #13
bleq print_char
streq r4, [r10], #4
moveq r4, #0
beq sort
cmp r0, #32
subeq r6, r6, #1
streq r4, [r10], #4
moveq r4, #0
beq five_input
sub r0, r0, #‘0’
mul r4, r9, r4
add r4, r4, r0
b five_input
sort
mov r7, #0
mov r8, #1
loop
cmp r7, #4
bhs end_loop
cmp r8, #4
bhs next_iteration
sub r0, r4, r5
blt swap
next_iteration
b loop
swap
mov r5, r4
mov r4, r0
b next_iteration
end_loop
mov r0, r4
bl print_number
b exit
exit
; Stnadard exit code : SWI 0×123456, calling routine 0×18
; with argument 0×20026
mov r0, #0×18
mov r1, #0×20000 ; build the "difficult" number
add r1, r1, #0×26 ; in two stems
SWI 0×123456 ; "software interrupt" = sys
END그런데 해당 코드가 정상적으로 작동하지 않는데 이유를 모르겠습니다
Forums:

댓글 달기