Anda di halaman 1dari 8

9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.

com

  
NEW!
Textbook Solutions Expert Q&A Practice Search  

home / study / engineering / electrical engineering / electrical engineering questions and answers / show me to write 55 binary to the screen then…

Question: Show me to write 55 binary to the screen then write 32 in hex… Post a question
Answers from our experts for your tou
homework questions

Enter question

Continue to post
20 questions remaining

My Textbook Solutions

Engineering Eng
Mechanics Me

Semiconduct Engineering Engi


or Device... Mechanics Mec
1st Edition 8th Edition 7th Ed

View all solutions

Electrical Engineering C
tutors who can help rig
now

Andre A.
University of OXFORD

Garima G.
University of Delhi

Shivakumar K.
Srinidhi Institute of …
Show me to write
55 binary to the screen then write 32 in hex to the screen and 20 in octal to the screen which on of these as you move things
into the eax have at the end write 50 out as done above store what 55 is in binary using a radix and store it into eax then take
32 store it as a hex number right into the screen finally take 20 store it in as an octal number into eax and write it to the screen
Find me a tutor
Show transcribed image text

Expert Answer

Anonymous answered this


Was this answer helpful? 0 0
72 answers

Code for Program to convert decimal number to binary in Assembly Language


DIS MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM
DATA SEGMENT
MSG2 DB "BINARY NUMBER IS : $"
STR1 DB 20 DUP('$')
STR2 DB 20 DUP('$')
NO DW 100
LINE DB 10,13,'$'
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STR1
MOV AX,NO
MOV BH,00
MOV BL,2
L1:DIV BL
https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 1/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com
L1:DIV BL
ADD AH,'0'
  
NEW!
MOV BYTE PTR[SI],AH Textbook Solutions Expert Q&A Practice Search  

MOV AH,00
INC SI
INC BH
CMP AL,00
JNE L1

MOV CL,BH
LEA SI,STR1
LEA DI,STR2
MOV CH,00
ADD SI,CX
DEC SI

L2:MOV AH,BYTE PTR[SI]


MOV BYTE PTR[DI],AH
DEC SI
INC DI
LOOP L2

DIS LINE
DIS MSG2
DIS STR2
MOV AH,4CH
INT 21H
CODE ENDS
END START

;------
;OUTPUT
;------

BINARY NUMBER IS : 1100100

Code for Program to Convert Decimal number to Hexadecimal number in Assembly Language

prnstr macro msg

mov ah, 09h

lea dx, msg

int 21h

endm

data segment

buf1 db "Enter a decimal number : $"

buf2 db 0ah, "Invalid Decimal Number...$"

buf3 db 0ah, "Equivalent hexadecimal number is : $"

buf4 db 6

db 0

db 6 dup(0)

multiplier db 0ah

data ends

code segment

assume cs:code, ds:data

start :

mov ax, data

mov ds, ax

mov es, ax

prnstr buf1

mov ah, 0ah

lea dx, buf4

int 21h

mov si, offset buf4 + 2

mov cl, byte ptr [si-1]

mov ch, 00h

subtract :

mov al, byte ptr [si]

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 2/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

cmp al, 30h


  
NEW!
Textbook Solutions Expert Q&A Practice Search  
jnb cont1

prnstr buf2

jmp stop

cont1 :

cmp al, 3ah

jb cont2

prnstr buf2

jmp stop

cont2 :

sub al, 30h

mov byte ptr [si], al

inc si

loop subtract

mov si, offset buf4 + 2

mov cl, byte ptr [si-1]

mov ch, 00h

mov ax, 0000h

calc :

mul multiplier

mov bl, byte ptr [si]

mov bh, 00h

add ax, bx

inc si

loop calc

mov si, offset buf4 + 2

mov bx, ax

mov dx, 0000h

mov ax, 1000h

convert :

mov cx, 0000h

conv :

cmp bx, ax

jb cont3

sub bx, ax

inc cx

jmp conv

cont3 :

cmp cx, 0ah

jb cont4

add cl, 37h

jmp cont5

cont4 :

add cl, 30h

cont5 :

mov byte ptr [si], cl

inc si

mov cx, 0010h

div cx

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 3/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

cmp ax, 0000h


  
NEW!
Textbook Solutions Expert Q&A Practice Search  
jnz convert

mov byte ptr [si], '$'

prnstr buf3

prnstr buf4+2

stop :

mov ax, 4c00h

int 21h

code ends

end start

Code for Program to Convert Decimal number to Octal number in Assembly Language

prnstr macro msg

mov ah, 09h

lea dx, msg

int 21h

endm

data segment

buf1 db "Enter a decimal number : $"

buf2 db 0ah, "Invalid Decimal Number...$"

buf3 db 0ah, "Equivalent octal number is : $"

buf4 db 6

db 0

db 6 dup(0)

multiplier db 0ah

data ends

code segment

assume cs:code, ds:data

start :

mov ax, data

mov ds, ax

mov es, ax

prnstr buf1

mov ah, 0ah

lea dx, buf4

int 21h

mov si, offset buf4 + 2

mov cl, byte ptr [si-1]

mov ch, 00h

subtract :

mov al, byte ptr [si]

cmp al, 30h

jnb cont1

prnstr buf2

jmp stop

cont1 :

cmp al, 3ah

jb cont2

prnstr buf2

jmp stop

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 4/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

cont2 :
  
NEW!
Textbook Solutions Expert Q&A Practice Search  
sub al, 30h

mov byte ptr [si], al

inc si

loop subtract

mov si, offset buf4 + 2

mov cl, byte ptr [si-1]

mov ch, 00h

mov ax, 0000h

calc :

mul multiplier

mov bl, byte ptr [si]

mov bh, 00h

add ax, bx

inc si

loop calc

mov si, offset buf4 + 2

mov bx, ax

mov dx, 0000h

mov ax, 8000h

convert :

mov cx, 0000h

conv :

cmp bx, ax

jb cont3

sub bx, ax

inc cx

jmp conv

cont3 :

add cl, 30h

mov byte ptr [si], cl

inc si

mov cx, 0008h

div cx

cmp ax, 0000h

jnz convert

mov byte ptr [si], '$'

prnstr buf3

prnstr buf4+2

stop :

mov ax, 4c00h

int 21h

code ends

end start

assembly program to convert decimal to radixx

.model small

.386

.stack 100h

.data

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 5/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

.code
  
NEW!
Textbook Solutions Expert Q&A Practice Search  
decimal proc near

;print out number given in AX in decimal

xor eax,eax

xor ebx,ebx

mov cx,2 ;this is to accept the base and the decimal value

  

newchar:   

cmp cx,0

jle startConvert

dec cx

mov ah,1 ;This sets up to accept another input from keyboard

int 21h ;this asks for an input and stores it in al

  

;mov al,0h ;This sets up to accept another input from keyboard

;int 21h ;this asks for an input and stores it in al

;push ax ;stores the second input from keyboard

  

  

  

sub al,30h

jl stloop ;jumps if negative

cmp al,9h

jg stloop ;jumps if greater than

  

xor ah,ah ;to get only the digit they type

push ax ;this stores the rst input from the keyboard

  

cbw ;convert byte to word

;jmp newchar ;to accept multiple digits

stloop:   

mov ah,2

mov dl,0ah

int 21h ;This section inserts a carrige return

mov dl,0dh

int 21h

  

  

startConvert: pop bx

push ax ;given to routine to print out

;push bx

push cx

push dx

  

mov cx,0 ;starts a counter for the number of digits

;mov bx,10 ;base 10 conversion THIS IS THE LINE TO CHANGE FOR DIFFERENT BASES!!!!

  

nonzero:   

xor dx,dx ;same as mov dx,0

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 6/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

div bx
  
NEW!
Textbook Solutions Expert Q&A Practice Search  
push dx ;this is the remainder of the divider

inc cx ;this will help determine the number of digits produced

or ax,ax ;sets ags to check is ax = 0

jne nonzero ;jump not equal to

write:   

pop dx ;gets deciaml digit from stack

add dl,'0' ;ascii value of 30h THIS ALSO NEEDS TO CHANGES FOR DIFFERENT BASES!!!

mov ah,2

int 21h

loop write ;loops number of times in cx, which is the number of digits

pop dx

pop cx

pop bx

pop ax

ret

decimal endp

end decimal

Comment


ABOUT CHEGG

LEGAL & POLICIES

CHEGG PRODUCTS AND SERVICES

CHEGG NETWORK

CUSTOMER SERVICE

© 2003-2019 Chegg Inc. All rights reserved.

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 7/8
9/2/2019 Show Me To Write 55 Binary To The Screen Then Writ... | Chegg.com

  
NEW!
Textbook Solutions Expert Q&A Practice Search  

https://www.chegg.com/homework-help/questions-and-answers/show-write-55-binary-screen-write-32-hex-screen-20-octal-screen-move-things-e… 8/8

Anda mungkin juga menyukai