
AA A.
asked 01/30/21write code and flowchart in assembly language 8085:
Assembly 8085(write Code and Flowchart):
Find the number of positive elements (most significant bit 0) in a block of data. The length of the block is in memory location 1001H and the block itself begins in memory location 1002H. Store the number of positive elements in memory location 2000H
Before excution:
1001H = 03H
1002H = 13H
1003H = 9AH
1004H = C4H
2000H = XX
After execution:
1001H = 03H
1002H = 13H
1003H = 9AH
1004H = C4H
2000H = 01H
1 Expert Answer

Patrick B. answered 02/01/21
Math and computer tutor/teacher
#include <stdio.h>
#include <stdlib.h>
int main()
{
char * data = (char*)malloc(4); //point this at address 0x1001
data[0] = 3;
data[1] = 0x13; //19
data[2] = 0x9A; //1001 1010
data[3] = 0xC4; //1100 0100
char chPosCount;
char * outbuff = &chPosCount; // point this at address 0x2000
char n = data[0];
char i=1;
while (i<=n)
{
printf("%d \n",data[i]);
if (data[i]>0)
{
(*outbuff)++;
}
i++;
}
printf("%d \n", *outbuff);
free(data);
}
/*******************************************/
/.LC0:
.string "%d \n"
main:
push rbp
mov rbp, rsp
sub rsp, 32
mov edi, 4
call malloc
mov QWORD PTR [rbp-16], rax
mov rax, QWORD PTR [rbp-16]
mov BYTE PTR [rax], 3
mov rax, QWORD PTR [rbp-16]
add rax, 1
mov BYTE PTR [rax], 19
mov rax, QWORD PTR [rbp-16]
add rax, 2
mov BYTE PTR [rax], -102
mov rax, QWORD PTR [rbp-16]
add rax, 3
mov BYTE PTR [rax], -60
lea rax, [rbp-26]
mov QWORD PTR [rbp-24], rax
mov rax, QWORD PTR [rbp-16]
movzx eax, BYTE PTR [rax]
mov BYTE PTR [rbp-25], al
mov BYTE PTR [rbp-1], 1
.L4:
movzx eax, BYTE PTR [rbp-1]
cmp al, BYTE PTR [rbp-25]
jg .L2
movsx rdx, BYTE PTR [rbp-1]
mov rax, QWORD PTR [rbp-16]
add rax, rdx
movzx eax, BYTE PTR [rax]
test al, al
jle .L3
mov rax, QWORD PTR [rbp-24]
movzx eax, BYTE PTR [rax]
add eax, 1
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov BYTE PTR [rax], dl
.L3:
movzx eax, BYTE PTR [rbp-1]
add eax, 1
mov BYTE PTR [rbp-1], al
jmp .L4
.L2:
mov rax, QWORD PTR [rbp-24]
movzx eax, BYTE PTR [rax]
movsx eax, al
mov esi, eax
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
mov eax, 0
leave
ret
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
You can CONVERT to assembler using -S switch.... gcc -S progname.c -o progname.s02/01/21