Tuesday, April 5, 2011

How to print a word (two bytes) in assembly

assume the data that need to be printed are in DX register. CX(CL) is the counter to be used to shift the bit of DX. At the end of the code, ascii 13 + ascii 10 are equivalent to "\r\n"


test_word:
movb $16, %cl
test_word_loop:
subb $4, %cl
movw %dx, %ax
shr %cl, %ax
andw $0x000f, %ax
cmpb $10, %al
jl test_word_less
addb $7, %al #prepare for A,B,C...because 17+48=65(A)

test_word_less:
addb $48, %al
movb $0xe, %ah
movw $7, %bx
int $0x10
cmpb $0, %cl
jne test_word_loop
movb $13, %al
int $0x10
movb $10, %al
int $0x10
ret

1 comment:

  1. Can you bet on football in 10 minutes? - Sporting 100
    What is the betting line at odds of 1.50? A sports betting line is a bet made by a bookmaker, and is a set of 스포츠 토토 사이트 events in which bets are placed

    ReplyDelete