Embed presentation
Download to read offline
![Data x: word 23 y: word -3 Write assembly code for the following pseudo code and draw flow
chard (for both Q1 and Q2): if (x
Solution
Answer:
Assembly Language Code :
1)
.zero 1
main:
push rbp
mov rbp, rsp
cmp DWORD PTR [rbp-4], 4
jg .L2
add DWORD PTR [rbp-8], 1
2)
.zero 1
main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 1
mov eax, 1
test al, al
je .L2
mov DWORD PTR [rbp-8], 0](https://image.slidesharecdn.com/dataxword23yword-3writeassemblycodeforthefollowingp-230704042845-4217dc8a/75/Data-x-word-23-y-word-3-Write-assembly-code-for-the-following-p-pdf-1-2048.jpg)
The document contains assembly code and pseudo code for two questions. The first question's code compares the value stored in x to 4, and if x is greater than 4 it jumps to the label L2. Otherwise, it adds 1 to the value stored in y. The second question's code initializes x to 1, moves 1 into eax and tests if it is equal to 0, jumping to L2 if so. Otherwise it sets y to 0.
![Data x: word 23 y: word -3 Write assembly code for the following pseudo code and draw flow
chard (for both Q1 and Q2): if (x
Solution
Answer:
Assembly Language Code :
1)
.zero 1
main:
push rbp
mov rbp, rsp
cmp DWORD PTR [rbp-4], 4
jg .L2
add DWORD PTR [rbp-8], 1
2)
.zero 1
main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 1
mov eax, 1
test al, al
je .L2
mov DWORD PTR [rbp-8], 0](https://image.slidesharecdn.com/dataxword23yword-3writeassemblycodeforthefollowingp-230704042845-4217dc8a/75/Data-x-word-23-y-word-3-Write-assembly-code-for-the-following-p-pdf-1-2048.jpg)