Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- jmp main
- toSwap1 db 'a'
- toSwap2 db 'b'
- result dw ?
- numToNeg dw -9
- string db 'm', 'a', 'g', 's', 'h', 'i', 'm', 'i', 'm', 'v', 'e', 'n', 'e', 'h', 'e', 'n', 'i', 'm' ,0Dh,0Ah,'$'
- array db "0000", 0Dh,0Ah, 24h ; line feed return and stop symbol 24h=$ (ASCII).
- num1 dw 0xAC45
- main: ;using stdcall convention
- jmp next
- push numToNeg
- call _negate@2
- PRINTN " ~ Negate ~ "
- call print_num
- PRINTN
- jmp endn
- next:
- mov al,toSwap1
- call print_al_chr
- mov al,toSwap2
- call print_al_chr
- push offset toSwap2 ;b
- push offset toSwap1 ;a
- call _swap@4
- mov al,toSwap1
- call print_al_chr
- mov al,toSwap2
- call print_al_chr
- endn:
- mov ah,0
- int 16h
- ret
- ; ~ Negate ~
- ; Input - parameter
- ; Output - through ax register. (2 byte signed integer)
- ; Function negates the number by 2 completion method.
- _negate@2 proc
- push bp
- mov bp,sp
- mov ax,[bp+4]
- not ax
- inc ax
- mov sp,bp
- pop bp
- retn 2
- _negate@2 endp
- ; ~ Swap ~
- ; Input : (char *a, char *b)
- ; Output : None
- ; Functions swaps between the values of the two pointers.
- _swap@4 proc
- ;num equ 'b'
- push ax
- push bx
- push bp
- mov bp,sp
- mov bx,[bp+8] ;char *a
- mov al, byte ptr [bx]; 'a'
- mov bx, [bp+10] ;char *b
- mov ah, byte ptr [bx]; 'b'
- mov [bx],al
- mov bx, [bp+8]
- mov [bx],ah
- mov sp,bp
- pop bp
- pop bx
- pop ax
- retn 4
- _swap@4 endp
- include magshimim.inc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement