Trilhas
/
MIPS Assembly
MIPS Assembly
/
Exercícios
/
Canção das garrafas
Canção das garrafas

Canção das garrafas

Médio

Instruções

Recite a letra daquela música infantil repetitiva e popular: Ten Green Bottles.

Repare que nem todas as estrofes são idênticas.

Ten green bottles hanging on the wall,
Ten green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be nine green bottles hanging on the wall.

Nine green bottles hanging on the wall,
Nine green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be eight green bottles hanging on the wall.

Eight green bottles hanging on the wall,
Eight green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be seven green bottles hanging on the wall.

Seven green bottles hanging on the wall,
Seven green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be six green bottles hanging on the wall.

Six green bottles hanging on the wall,
Six green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be five green bottles hanging on the wall.

Five green bottles hanging on the wall,
Five green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be four green bottles hanging on the wall.

Four green bottles hanging on the wall,
Four green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be three green bottles hanging on the wall.

Three green bottles hanging on the wall,
Three green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be two green bottles hanging on the wall.

Two green bottles hanging on the wall,
Two green bottles hanging on the wall,
And if one green bottle should accidentally fall,
There'll be one green bottle hanging on the wall.

One green bottle hanging on the wall,
One green bottle hanging on the wall,
And if one green bottle should accidentally fall,
There'll be no green bottles hanging on the wall.

Formato da saída

Retorne a letra como uma string terminada em nulo.

Registradores

Registrador Uso Tipo Descrição
$a0 entrada inteiro garrafas iniciais
$a1 entrada inteiro quantidade a derrubar
$a2 entrada/saída endereço string de saída terminada em nulo
$t0-9 temporário qualquer para armazenamento temporário

Fonte

WikipediaO link abre em uma nova janela ou aba
Editar via GitHub O link abre em uma nova janela ou aba
MIPS Assembly Exercism

Tudo pronto para começar Canção das garrafas?

Crie sua conta no Exercism para aprender e dominar MIPS Assembly com 70 exercícios e mentoria humana de verdade, tudo de graça.