×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Help!!! How to write binary to the screen?

 Forum Search FAQs Links MVPs

## Help!!! How to write binary to the screen?

(OP)
I am a beginner in Assembly and just receievd an assignment on this area with one procedure look like this, could someone be able to tell me how to implement it? I have absloutly no idea. Thank you!

AppendBinary PROC
; append the binary representation of the accumulator contents to a string
; with the write starting at address DS:SI
; pre:  BX specifies whether AL or AX is to be output (if BX=0 output AL otherwise AX)
; post: the binary representation of the value in the specified accumulator
;       has been appended (with MSB leftmost) starting at the address DS:SI
;       AND DS:SI points to the char immediately following the appended chars
;       AND all registers (excluding SI) are preserved

;     ========================================================================
;      About 20 instructions in this procedure
;     ========================================================================

ret
AppendBinary ENDP
Replies continue below

### RE: Help!!! How to write binary to the screen?

Algo:

PUSHALL  except SI
x=1;  // let "x" be a character

loop:

temp = input;
and (input) , x
if zero flag set,
move ds:[si], 30h // Ascii for "0"
else
move ds:[si],31h // Ascii for "1"
inc si
x = x << 1;
input = temp;
if (x != 0)

POPall except SI
return; Thatz it

Do not rejoice that ur code works.
it might be a special case of an error

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!