0
LC3 프로그램을 생성하여 양수와 음수를 표시하지만 시뮬레이션 프로그램에서 프로그램을 실행하면 - R5에서 양수는 추가 된 첫 번째 + ve 번호 만 표시합니다. 내 코드는 다음과 같습니다 -이 지점 문 모두가 아주 정확하지LC3 어셈블리를 실행 한 후 레지스터 값이 올바르지 않음
.ORIG x3000
and r1, r1,#0 ; clear r1
and r2, r2, #0 ; neg counter amount of negative numbers
and r3, r3, #0 ; positive counter amount of pos numbers
and r4, r4, #0; negative sum
and r5,r5, #0; positive sum
and r6,r6,#0; clear register
LEA R1, DATA
loop
ldr r6, r1, #0
BRn negativecountm ;if negative go to branch to ncount method
BRp positivecountm ;if positive go to branch to pcount method
BRz Escape ;if 0 encountered program done go to escape method
negativecountm
add r2, r2, #1 ; increment count for neg numbers
add r4, r4, r6 ; sum of neg number
add r1, r1,#1 ; increment pointer to point to next number in data
BRp loop ; go back to original loop
positivecountm
add r3, r3, #1 ; increment count for positive num
add r5, r5, r6; sum of +ve num
add r1, r1, #1 ; increment pointer to point to next num in data
BRn loop;
Escape
ST r2, negativecount ;
ST r3, positivecount;
ST r5, positivesum;
ST r4, negativesum;
TRAP x25 ;
DATA .Fill 1244
.Fill -23
.Fill 17
.Fill 6
.Fill -12
.Fill 0
negativecount .BLKW 1
positivecount .BLKW 1
positivesum .BLKW 1
negativesum .BLKW 1
.END
고맙습니다. – rahulchawla