2015-01-30 3 views
0

다음 코드에서 여기서는 숫자를 오름차순으로 정렬하는 코드를 작성했습니다.8085를 사용하여 오름차순으로 정렬.

start: nop 

MVI B, 09 ; Initialize counter  
LXI H, 2200H ;Initialize memory pointer 
MVI C, 09H; Initialize counter 2 
BACK: MOV A, M ;Get the number 
INX H ;Increment memory pointer 
CMP M; Compare number with next number 
JC SKIP;If less, don't interchange 
JZ SKIP; If equal, don't interchang 
MOV D, M 
MOV M, A 
DCX H 
MOV M, D 
INX H ;Interchange two numbers 
DCR C ; Decrement counter 2 
JNZ BACK ;If not zero, repeat 
DCR B ; Decrement counter 1 
JNZ START 
HLT ; Terminate program execution 

이것은 수업에서 가르쳐 주신 내용입니다.

1. Line 9: Undefined symbol. 
2. Line 9: Invalid operand or symbol.Check whether operands start with a 0. Like a0H should be 0a0H. 

누군가가 도와 드릴까요 : 나는 GNUSim에서 코드를 실행하려고하면 , 내가 좋아하는 오류를 얻을?

+0

당신은'SKIP' 라벨이 없습니다. 아마도 'DCR C'이전이어야합니다. – msandiford

답변

1

8085 (js8085) 나는 (버블 정렬을 사용하여) 그것을 다음의 방법을 할 줄에서 : 당신은 당신이 가지고있는 요소의 수와 요소 자체가에서 시작되었다 포트 00에서

@begin 0100 
@next 0100 
MVI A 00 
MVI B 00 
MVI C 00 
MVI D 00 
MVI E 00 
MVI H 00 
MVI L 00 
IN 00 
out 00 
DCR A 
out 06 
bubble: in 06 
cmp c 
jz finished 
inr e 
ldax b 
mov h,a 
ldax d 
cmp h 
jc change; 
comprobation: in 00 
cmp e 
jz semi-fin 
call bubble 
semi-fin: inr c 
mov a,c 
mov e,c 
call bubble 
change: stax b 
mov a,h 
stax d 
call comprobation 
finished: hlt 

위치 0000 ~ 요소 - 1.

관련 문제