Docsity

Algoritmo de ordenación de pacientes en una cola de prioridad - Prof. Santamaría, Ejercicios de Ingeniería Infórmatica

Toggle sidebar
bg1
void Exchange(int* List, int i, int j)
{
int temp;
temp=List[j];
List[j]=List[i];
List[i]=temp;
}
SortPatients:
push{fp}
mov fp, sp
sub sp, #
cmp r2,#CRIT_PRIO
BEQ no_error
CMP r2, #CRIT_ALFA
BEQ no_error
mov r0, #-1
B fin
no_error:
mov r4,#0 //r4=pid
mov r5,#0 // r5=num
for: cpm r4,#MAX_PATIENTS
BEQ fin_for
ldr r5,[r1,r4,lsl #4]
cmp r5,#0
beq no_if
str r4,[r0,r5,lsl #2]
add r5,r5,#1
no_if: add r4,r4,#1
b for
cmp r2,#CRIT_PRIO
bne no_prio
mov r4,#0
for2: cmp r4,r5
beq fin_for2
push{r0-r3]
mov r2,r4
mov r3,r5
bl LowestPrioPos
mov r6,r0
pop{r0-r3}
push[r0-r3]
mov r1,r4
mov r2,r6
pf2

Vista previa parcial del texto

¡Descarga Algoritmo de ordenación de pacientes en una cola de prioridad - Prof. Santamaría y más Ejercicios en PDF de Ingeniería Infórmatica solo en Docsity!

void Exchange(int* List, int i, int j) { int temp; temp=List[j]; List[j]=List[i]; List[i]=temp; } SortPatients: push{fp} mov fp, sp sub sp, # cmp r2,#CRIT_PRIO BEQ no_error CMP r2, #CRIT_ALFA BEQ no_error mov r0, #- B fin no_error: mov r4,#0 //r4=pid mov r5,#0 // r5=num for: cpm r4,#MAX_PATIENTS BEQ fin_for ldr r5,[r1,r4,lsl #4] cmp r5,# beq no_if str r4,[r0,r5,lsl #2] add r5,r5,# no_if: add r4,r4,# b for cmp r2,#CRIT_PRIO bne no_prio mov r4,# for2: cmp r4,r beq fin_for push{r0-r3] mov r2,r mov r3,r bl LowestPrioPos mov r6,r pop{r0-r3} push[r0-r3] mov r1,r mov r2,r

bl Exchange pop{r0-r3} add r4,r4,# b for fin_for2: no_prio: cmp r2,#CRIT_ALFA bne no_alfa for3: cmp r4,r beq fin_for push{r0-r3] mov r2,r mov r3,r bl LowestAlphPos mov r6,r pop{r0-r3} push[r0-r3] mov r1,r mov r2,r bl Exchange pop{r0-r3} add r4,r4,# fin_for 3: fin: