Se está descargando tu SlideShare. ×

# Write a function in Assembly language that takes a value passed to it (1).docx

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio  Cargando en…3
×

1 de 2 Anuncio

# Write a function in Assembly language that takes a value passed to it (1).docx

Write a function in Assembly language that takes a value passed to it in A register. (write only the function code.) The function: (1) first prints the value as a hex number (2) then prints the value as a decimal number (two digits) (3) then determines if the value is a printable ACSII character, and if so prints the character, but if it is not a printable character, the # character is printed instead. Example: if the value passed in A register is 41 hex, the function prints 41 65 A. Your function may call the standard terminal I/O functions such a and out2hex to do its work. You must provide any code or function needed for converting to decimal. it is important to write this function in such a way that the stack is used to save and restore registers, so that none of the registers have been modified when the function returns.
Solution
Solution :
To convert the input value of register in hex number and decimal number, get the offset address and set the number of ascii with start from highest byte like -
Function -
mov gi, offset ascii
mov dl, 5
rol fd,8 // starting with highest byte // use increase and decrease counter
At end 1 + output string
// output is in hex decimal and decimal number of input number
// In last the output prints the ascii and character too ..............................
mov s,8 ;
print s;
or s,60h; // convert to ascii from value
mov d,s;
mov sh,2;
mov fd,d; // print of character
..... Termination .......
.

Write a function in Assembly language that takes a value passed to it in A register. (write only the function code.) The function: (1) first prints the value as a hex number (2) then prints the value as a decimal number (two digits) (3) then determines if the value is a printable ACSII character, and if so prints the character, but if it is not a printable character, the # character is printed instead. Example: if the value passed in A register is 41 hex, the function prints 41 65 A. Your function may call the standard terminal I/O functions such a and out2hex to do its work. You must provide any code or function needed for converting to decimal. it is important to write this function in such a way that the stack is used to save and restore registers, so that none of the registers have been modified when the function returns.
Solution
Solution :
To convert the input value of register in hex number and decimal number, get the offset address and set the number of ascii with start from highest byte like -
Function -
mov gi, offset ascii
mov dl, 5
rol fd,8 // starting with highest byte // use increase and decrease counter
At end 1 + output string
// output is in hex decimal and decimal number of input number
// In last the output prints the ascii and character too ..............................
mov s,8 ;
print s;
or s,60h; // convert to ascii from value
mov d,s;
mov sh,2;
mov fd,d; // print of character
..... Termination .......
.

Anuncio
Anuncio

### Write a function in Assembly language that takes a value passed to it (1).docx

1. 1. Write a function in Assembly language that takes a value passed to it in A register. (write only the function code.) The function: (1) first prints the value as a hex number (2) then prints the value as a decimal number (two digits) (3) then determines if the value is a printable ACSII character, and if so prints the character, but if it is not a printable character, the # character is printed instead. Example: if the value passed in A register is 41 hex, the function prints 41 65 A. Your function may call the standard terminal I/O functions such a and out2hex to do its work. You must provide any code or function needed for converting to decimal. it is important to write this function in such a way that the stack is used to save and restore registers, so that none of the registers have been modified when the function returns. Solution Solution : To convert the input value of register in hex number and decimal number, get the offset address and set the number of ascii with start from highest byte like - Function - mov gi, offset ascii mov dl, 5 rol fd,8 // starting with highest byte // use increase and decrease counter At end 1 + output string // output is in hex decimal and decimal number of input number // In last the output prints the ascii and character too .............................. mov s,8 ; print s;
2. 2. or s,60h; // convert to ascii from value mov d,s; mov sh,2; mov fd,d; // print of character ..... Termination .......