Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Problem:
- Write a subprogram which will take input from the main program as-
- A-8 bit number(save in AL)
- B-32 bit number(save in BX:CX)
- C-16 bit number(save in DX)
- D-8 bit number(save in AH)
- Solution:
- .stack 100h
- .data
- A db 151
- B dd 1048576
- C dw 3298
- D db 78
- .code
- main proc
- mov al, A
- mov ah, D
- mov dx, C
- lea si, B ;B is a double word, so to store B we have to treat it like an array
- mov bx, [si]
- mov cx, [si + 2] ;+2 because double word, advance 2 bytes
- call custom_function
- ret
- main endp
- custom_function proc
- ;Inputs A, B, C, D in Al, (BX(High) + CX, (Low)), DX and AH respectively
- ;Storing the input in the stack so that data is not lost
- push ax
- push bx
- push cx
- push dx
- ;Do, something here
- ;Restore the data in the registers
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- custom_function endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement