Question

Write the following x86 assembly program to run in masm: 3. X is a signed array...

Write the following x86 assembly program to run in masm:

3. X is a signed array of bytes. Convert all negative values in the array to positive.

(a) Use conditional jumps only.
(b) Repeat but using conditional directives only
0 0
Add a comment Improve this question Transcribed image text
Answer #1

section .data
ncnt db 0
pcnt db 0
array: dw 80H,4CH,3FH
len equ 3
msg1: db 'positive numbers are:',0xa
len1: equ $-msg1
msg2: db 'negative numbers are:',0xa
len2: equ $-msg2


section .bss
buff resb 02

section .text

global _start
_start:

mov rsi,array
mov rcx,03

A1:
bt word[rsi],15
jnc A
inc byte[ncnt]
jmp skip

A:
inc byte[pcnt]


skip:
inc rsi
inc rsi
loop A1

mov rax,1
mov rdi,1
mov rsi,msg1
mov rdx,len1
syscall

mov bl,[pcnt]
mov rdi,buff
mov rcx,02



call display


mov rax,1
mov rdi,1
mov rsi,msg2
mov rdx,len2
syscall

mov bl,[ncnt]
mov rdi,buff
mov rcx,02


call display

mov rax,60
mov rdi,0
syscall

display:
rol bl,4
mov al,bl
and al,0FH
cmp al,09
jbe B
add al,07h

B:
add al,30H
mov[rdi],al
inc rdi
loop display


mov rax,1
mov rdi,1
mov rsi,buff
mov rdx,02
syscall

ret

Add a comment
Know the answer?
Add Answer to:
Write the following x86 assembly program to run in masm: 3. X is a signed array...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT