Se ha denunciado esta presentación.
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
Anuncio
Próximo SlideShare
Programming basic computer
Programming basic computer
Cargando en…3
×

Eche un vistazo a continuación

1 de 2 Anuncio

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

Descargar para leer sin conexión


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

Más Contenido Relacionado

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

Más de lez31palka (20)

Anuncio

Más reciente (20)

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 .......

×