;programa para determinar numa turma com 20 alunos de 17 e 18 anos,
; quantos sao:
;os que tem 17 anos, deixando o resultado em 1500h
;os que tem 18 anos, deixando o resultado em 1501h
org 1300h
turma db 18,17,17,18,18,17,18,17,18,18,17,18,17,17,18,18,18,17,18,18
org 1000h
MVI A,17
LXI H,1300h
MVI C,20 ; fica sendo o contador do array
MVI B,0 ; conta os alunos com 17 anos
loop: CMP M
JNZ incHL
INR B ; se comparacao deu zero incrementa um aluno de 17 anos
incHL: INX H
DCR C
JNZ loop
LXI H,1500h ;aponta HL para guardar resultado dos alunos de 17 anos
MOV M,B ;guarda nessa posicao o conta alunos de 17 anos
MVI A,20 ; Os alunos com 18 anos sao os 20 alunos menos
SUB B ; os alunos que tem 17 anos
INX H ;aponta HL para guardar resultado dos alunos de 18 anos
MOV M,A
RST 1
end
EN: Blog with various topics utilities (and curiosities) in various fields: mathematics, electricity, electronics, physics, programming, crafts... PT: Blog com temas diversos com utilidades (e também curiosidades ) em vários domínios: matematica, electricidade, electrónica, fisica, programação, trabalhos manuais... FR: Blog avec de "choses" utiles (et curiosités) dans divers domaines: mathématiques, l'électricité, l'électronique, la physique, de la programmation, de l'artisanat...
Mostrar mensagens com a etiqueta 8085. Mostrar todas as mensagens
Mostrar mensagens com a etiqueta 8085. Mostrar todas as mensagens
quinta-feira, 11 de agosto de 2016
terça-feira, 3 de novembro de 2015
Programa média ponderada de notas
Ler as 2 notas do aluno: N1, N2
Calcular a média ponderada do aluno
media = ( N1 + 4*N2) / 5
Weighted average program from 0 ~ 20 notes
Read 2 student grades: N1, N2
Calculate the weighted average student
final score = (N1 + N2 * 4) / 5
Programme moyen pondéré de 0 ~ 20 notes
Lire 2 notes des étudiants: N1, N2
Calculer l'étudiant moyen pondéré
score final = (N1 + N2 * 4) / 5
org 1000h
N1: ds 1
N2: ds 1
org 3000h
start: lda N1
mov b,a ; the N1 we save at the b register
lda N2
add a ; here accumulator=2*N2
add a ; here we have accumulator 4*N2
add b ; in the accumulator we have N1+4*N2
add a ; lets two multiply all by 2 and then we must divide by 10
; accumulator have now 2(N1+4*N2).
; lets go to divide the accumulator by 10
mvi c,0 ; we use the register c to count the times that we
; subtract the accumulator by 10
mvi d,10 ; we use d register to made the subtraction as sub d
loop: cpi 10 ; to see if accumulator is less then 10, if carry then a<10
jc theend
sub d ; its equal to do sui 10, note d is 10 but less expensive time
inr c
jmp loop
theend: rst 1 ; the media is at: the integer part at c regist
; and decimal part at the acumulator
end ;
Ler as 2 notas do aluno: N1, N2
Calcular a média ponderada do aluno
media = ( N1 + 4*N2) / 5
Weighted average program from 0 ~ 20 notes
Read 2 student grades: N1, N2
Calculate the weighted average student
final score = (N1 + N2 * 4) / 5
Programme moyen pondéré de 0 ~ 20 notes
Lire 2 notes des étudiants: N1, N2
Calculer l'étudiant moyen pondéré
score final = (N1 + N2 * 4) / 5
org 1000h
N1: ds 1
N2: ds 1
org 3000h
start: lda N1
mov b,a ; the N1 we save at the b register
lda N2
add a ; here accumulator=2*N2
add a ; here we have accumulator 4*N2
add b ; in the accumulator we have N1+4*N2
add a ; lets two multiply all by 2 and then we must divide by 10
; accumulator have now 2(N1+4*N2).
; lets go to divide the accumulator by 10
mvi c,0 ; we use the register c to count the times that we
; subtract the accumulator by 10
mvi d,10 ; we use d register to made the subtraction as sub d
loop: cpi 10 ; to see if accumulator is less then 10, if carry then a<10
jc theend
sub d ; its equal to do sui 10, note d is 10 but less expensive time
inr c
jmp loop
theend: rst 1 ; the media is at: the integer part at c regist
; and decimal part at the acumulator
end ;
terça-feira, 18 de agosto de 2015
ASSEMBLER ADITION BCD
EN: Program to add the contents of the BC and DE records pairs in BCD and place the result in result
PT: Programa para somar os conteudos dos pares de registos BC e DE em BCD e colocar o resultado em result
FR: Programme pour adictioner les paires de registres BC et DE en BCD et placer le résultat dans result
inic: mov a,e
add c
daa
sta result
mov a,d
adc b
daa
sta result+1
mvi a,0
adc a
sta result+2
rst 1
_____________EXAMPLES_______________________
when the program run, if BC=2749 and DE=6448, at the end of program
execution result has 97, result+1 has 91 and result+2 has 0
_____________
when the program run, if BC=9052 and DE=2914, at the end of program
execution result has 66, result+1 has 19 and result+2 has 1
:)
sábado, 25 de julho de 2015
Assembler 8085 String Copy
Assembler 8085 String Copy
; PROGRAM STRING COPY STRCPY DO C++
DADOS EQU 2000h
CODIGO EQU 3000h
ORG DADOS
SDEST DS 10 ; HL String target
SFONTE DS 6 ; BC String source
ORG CODIGO
BEGIN: LXI H,SDEST;
LXI B,SFONTE
STRCPY: LDAX B
ANA A
MOV M,A
JZ FIM
INX B
INX H
JMP STRCPY
FIM: RST 1
_______________________________
SYMBOL TABLE
BEGIN 3000
FIM 3011
SDEST 2000
SFONTE 200A
STACK S 0000
STRCPY 3006
The string ends at the value 0.
at the following example x means d'ont care.
If the string SFONTE='John'
means SFONTE memory 200A= 'J' , 'o' , 'h' , 'n' , 0 , x
SDEST memory 2000= x , x , x , x , x , x , x , x , x , x
after we run the program the memory is:
string SFONTE='John'
string SDEST='John'
means SFONTE memory 200A= 'J' , 'o' , 'h' , 'n' , 0 , x
SDEST memory 2000 = 'J' , 'o' , 'h' , 'n' , 0 , x , x , x , x , x
cool!
; PROGRAM STRING COPY STRCPY DO C++
DADOS EQU 2000h
CODIGO EQU 3000h
ORG DADOS
SDEST DS 10 ; HL String target
SFONTE DS 6 ; BC String source
ORG CODIGO
BEGIN: LXI H,SDEST;
LXI B,SFONTE
STRCPY: LDAX B
ANA A
MOV M,A
JZ FIM
INX B
INX H
JMP STRCPY
FIM: RST 1
_______________________________
SYMBOL TABLE
BEGIN 3000
FIM 3011
SDEST 2000
SFONTE 200A
STACK S 0000
STRCPY 3006
The string ends at the value 0.
at the following example x means d'ont care.
If the string SFONTE='John'
means SFONTE memory 200A= 'J' , 'o' , 'h' , 'n' , 0 , x
SDEST memory 2000= x , x , x , x , x , x , x , x , x , x
after we run the program the memory is:
string SFONTE='John'
string SDEST='John'
means SFONTE memory 200A= 'J' , 'o' , 'h' , 'n' , 0 , x
SDEST memory 2000 = 'J' , 'o' , 'h' , 'n' , 0 , x , x , x , x , x
cool!
quarta-feira, 22 de julho de 2015
ASSEMBLER 8085
;FR La multiplication par additions successives
;PT MULTIPLICACAO POR SOMAS SUCESSIVAS
;EN Multiplication by successive additions
;FR Le résultat est valable uniquement si moins d'un octet
;PT O RESULTADO NAO PODE EXCEDER 1 BYTE
;EN The result is only valid if less than one byte
DADOS EQU 2000h
CODIGO EQU 3000h
ORG DADOS
NUM1: DB 1
NUM2: DB 1
ORG CODIGO
BEGIN: LXI H,NUM1 ; HL APONTA NUM1
LDA NUM2;
CMP M ; instrucctions to put
JC CONDICAO ; the counter
MOV A,M ; with the less number that we have
LXI H,NUM2 ; to multiply
CONDICAO: MOV C,A
INR C
MVI A,0
LOOP: DCR C
JZ FIM
ADD M
JMP LOOP
FIM: RST 1
EN: The result of multiplying NUM1 by NUM2 is in the accumulator now at the end
FR: Le acumulateur va rester avec le resultat de la multiplication de le NUM1 e NUM2
PT: O resultado da multiplicação de NUM1 pelo NUM2 fica no acumulador
means: ça veux dire: quer dizer:
A=NUM1xNUM2
very nice!
;FR La multiplication par additions successives
;PT MULTIPLICACAO POR SOMAS SUCESSIVAS
;EN Multiplication by successive additions
;FR Le résultat est valable uniquement si moins d'un octet
;PT O RESULTADO NAO PODE EXCEDER 1 BYTE
;EN The result is only valid if less than one byte
DADOS EQU 2000h
CODIGO EQU 3000h
ORG DADOS
NUM1: DB 1
NUM2: DB 1
ORG CODIGO
BEGIN: LXI H,NUM1 ; HL APONTA NUM1
LDA NUM2;
CMP M ; instrucctions to put
JC CONDICAO ; the counter
MOV A,M ; with the less number that we have
LXI H,NUM2 ; to multiply
CONDICAO: MOV C,A
INR C
MVI A,0
LOOP: DCR C
JZ FIM
ADD M
JMP LOOP
FIM: RST 1
EN: The result of multiplying NUM1 by NUM2 is in the accumulator now at the end
FR: Le acumulateur va rester avec le resultat de la multiplication de le NUM1 e NUM2
PT: O resultado da multiplicação de NUM1 pelo NUM2 fica no acumulador
means: ça veux dire: quer dizer:
A=NUM1xNUM2
very nice!
terça-feira, 14 de julho de 2015
FR: Petit programme assembler pour le 8085: Chercher le numero plus grand...
EN: Program assembler for the 8085 processor: Find the upper number...
PT: Programa assembler para o processador 8085: Procurar o maior numero...
; EN: program to find the upper number in a list TABELA of length LEN
; FR: programme pour trouver le numero plus grand dans une list TABELA de dimension LEN
; PT: programa para encontrar o maior dum array TABELA de dimensao LEN
ORG 2000h
LEN: DW 4
TABELA: DS 20
MAIOR: DS 1
ORG 3000H
LXI H,LEN
MOV C,M
INX H
MOV B,M
LXI H,TABELA
MOV A,M
LOOP2: INX H
DCX B
STA MAIOR
MOV A,B
ORA C
LDA MAIOR
JZ EXIT
CMP M
IF: JNC LOOP2
MOV A,M
MOV D,H
MOV E,L
FIM_DE_IF: JMP LOOP2
EXIT RST 1
EN: Program assembler for the 8085 processor: Find the upper number...
PT: Programa assembler para o processador 8085: Procurar o maior numero...
; EN: program to find the upper number in a list TABELA of length LEN
; FR: programme pour trouver le numero plus grand dans une list TABELA de dimension LEN
; PT: programa para encontrar o maior dum array TABELA de dimensao LEN
ORG 2000h
LEN: DW 4
TABELA: DS 20
MAIOR: DS 1
ORG 3000H
LXI H,LEN
MOV C,M
INX H
MOV B,M
LXI H,TABELA
MOV A,M
LOOP2: INX H
DCX B
STA MAIOR
MOV A,B
ORA C
LDA MAIOR
JZ EXIT
CMP M
IF: JNC LOOP2
MOV A,M
MOV D,H
MOV E,L
FIM_DE_IF: JMP LOOP2
EXIT RST 1
quinta-feira, 4 de junho de 2015
Assembler 8085
EN: This program is intended to put the contents of memory "memx" in memory "memy" and the contents of "memy" in "memx"
FR: Ce programme est destiné à mettre le contenu de la mémoire "memx" en mémoire "memy" et le contenu de "memy" dans "memx"
PT: Neste programa pretende-se colocar o conteudo de memoria "memx" na memória "memy" e o conteudo de "memy" em "memx"
dados equ 5000h
codigo equ 2000h
org dados
memx db 77h
memy db 88h
org codigo
inicio: lxi h,memx
mov b,m
inx h
mov a,m
mov m,b
sta memx
rst 1
EN: This program is intended to put the contents of memory "memx" in memory "memy" and the contents of "memy" in "memx"
FR: Ce programme est destiné à mettre le contenu de la mémoire "memx" en mémoire "memy" et le contenu de "memy" dans "memx"
PT: Neste programa pretende-se colocar o conteudo de memoria "memx" na memória "memy" e o conteudo de "memy" em "memx"
dados equ 5000h
codigo equ 2000h
org dados
memx db 77h
memy db 88h
org codigo
inicio: lxi h,memx
mov b,m
inx h
mov a,m
mov m,b
sta memx
rst 1
Subscrever:
Mensagens (Atom)