1

I am very new to assembly programming, and I am having some issues with an assignment. I am trying to store a hex value (94h) in AL and store the most significant nibble (MSN) in DH and least significant nibble (LSN) in DL. I know I can use shift left and shift right (by 4) to isolate the MSN and LSN, but I dont know how to store the result in DL and DH.

As an example: If AL contains the number 94h 1)I want to store 39h (ASCII code of the character ‘9’) in DH 2)I want to store 34h (ASCII code of the character ‘4’) in DL 3)I need to display the characters ‘9’, ‘4’, ‘h’, ‘linefeed’, and ‘carriage return’.

MOV AL, 94h ; AL <-- 94h / 1001 0100
MOV CL, 4
SHR AL, 4 ; AL = 0000 1001 = 9 
; How do i store this into DH

At this point, I'm stumped..

3
  • 1
    Umm ... mov dh, al
    – Jester
    Commented Sep 16, 2018 at 18:40
  • 1
    Also you want to move it before you shift it so you don’t lose the other half.
    – prl
    Commented Sep 16, 2018 at 18:56
  • How do I get 4 into DL?
    – MichaelL
    Commented Sep 16, 2018 at 18:59

1 Answer 1

2

One solution among many:

mov al, 94h
mov dh, al
shr dx, 4
shr dl, 4
2
  • So how to I get DH(09h) and DL(04h) to print on the console using WriteChar?
    – MichaelL
    Commented Sep 16, 2018 at 19:26
  • @MichaelL: Thanks for the points. I can guess what the whole task looks like and what other problems you will face. It takes too long to work through all the problems you don't even know until I've done your homework for you. First try to create your own program and then ask if you really don't know what to do. Please take a look at stackoverflow.com/help/mcve
    – rkhb
    Commented Sep 16, 2018 at 19:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.