Created
July 28, 2019 21:16
-
-
Save coderarjob/fb5cd3419e8c7a453740a4b82bd41b5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bits 16 | |
| section .bss | |
| global _ch | |
| _ch: | |
| resb 1 | |
| section .text | |
| global _main | |
| _main: | |
| push bp | |
| mov bp, sp | |
| sub sp, 10 | |
| mov ax, 0 | |
| mov [bp-2], ax | |
| section .data | |
| L3: | |
| db 48 | |
| db 49 | |
| db 50 | |
| db 51 | |
| db 52 | |
| db 53 | |
| db 54 | |
| section .text | |
| lea ax, [bp-10] | |
| push ax | |
| push L3 | |
| push 7 | |
| call L4 | |
| sub sp, -6 | |
| lea ax, [bp-10] | |
| add ax, [bp-2] | |
| mov bx, ax | |
| mov al, [bx] | |
| cbw | |
| mov [_ch], al | |
| cbw | |
| mov ax, 0 | |
| L1: | |
| leave | |
| ret | |
| section .text | |
| L4: | |
| push bp | |
| mov bp, sp | |
| ;sub sp, 0 | |
| ; *************************** Coded added manually, Starts | |
| push es | |
| mov ax, ss | |
| mov es, ax | |
| ; *************************** Coded added manually, Ends | |
| mov di, [bp+8] | |
| mov si, [bp+6] | |
| mov cx, [bp+4] | |
| cld | |
| rep movsb | |
| mov ax, [bp+8] | |
| ; *************************** Coded added manually, Starts | |
| pop es | |
| ; *************************** Coded added manually, Ends | |
| leave | |
| ret | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char ch; | |
| void main() | |
| { | |
| int i = 0; | |
| char array[] = {'0','1','2','3','4','5','6'}; | |
| ch = array[i]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bits 16 | |
| section .bss | |
| global _ch | |
| _ch: | |
| resb 1 | |
| section .text | |
| global _main | |
| _main: | |
| push bp | |
| mov bp, sp | |
| sub sp, 10 | |
| mov ax, 0 | |
| mov [bp-2], ax | |
| section .data | |
| L3: | |
| db 48 | |
| db 49 | |
| db 50 | |
| db 51 | |
| db 52 | |
| db 53 | |
| db 54 | |
| section .text | |
| lea ax, [bp-10] | |
| push ax | |
| push L3 | |
| push 7 | |
| call L4 | |
| sub sp, -6 | |
| lea ax, [bp-10] | |
| add ax, [bp-2] | |
| mov bx, ax | |
| mov al, [bx] | |
| cbw | |
| mov [_ch], al | |
| cbw | |
| mov ax, 0 | |
| L1: | |
| leave | |
| ret | |
| section .text | |
| L4: | |
| push bp | |
| mov bp, sp | |
| ;sub sp, 0 | |
| mov di, [bp+8] <------------- DI contains the location in stack. Yet no SS | |
| mov si, [bp+6] | |
| mov cx, [bp+4] | |
| cld | |
| rep movsb <---------------- Copies CX bytes to DS:SI to ES:DI, here DS = ES <> SS | |
| mov ax, [bp+8] | |
| leave | |
| ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment