'Assembly Language Programming' Problem

Status
Not open for further replies.

a_to_z123

asia://india/ka/bangalore
Well guys here is something which I couldn't find anywhere.

I wrote a simple program to add two numbers in Assembly Language.

So is there any way to show the output on the screen. Any way.............is there???
I mean I know how to output a string on the screen (i.e. by using 'MOV ah, 9h'), but I dunno how to print a number on screen.

If there is, then do tell me...

Thx in advance!!!
 

swatkat

Technomancer
You have to first unpack the Hex number's upper and lower nibble and then convert both the upper and lower nibbles to their equivalent ASCII (by adding 30H). After this you will get two 1 byte ASCII codes representing the original number's upper nibble and lower nibble. You can later use Int 21 to print these two ASCII charactrers one after another which show up as numbers on screen.
 
OP
a_to_z123

a_to_z123

asia://india/ka/bangalore
Thx SwatKat,

I'll surely try out your method and let you know. Actually I'm new to assembly language so let me understand what do you mean exactly.
Then I'll implement it.

Thx again.
 

swatkat

Technomancer
Hi,
Here's the code to do it:-

MOV AX,0000 ;clear AX

MOV AL, 12 ; Here 12 is the number that is to be displayed.

PUSH AX ; Back up the number

SHR AX, 4 ; Shift AX to right 4 times to get the upper nibble (of AL) to lower position. (Now, AL <= 01)

ADD AL, 30 ; Add 30H to convert it to ASCII (Now, AL <= 31)

MOV CH, AL ; Store this ASCII of upper nibble in CH (CH <= 31)

POP AX ; Restore AX

AND AL, 0F ; Mask the upper 4 bits. (Now, AL <= 02)

ADD AL, 30 ; Convert to ASCII (AL <= 32)

MOV AH, CH ; Copy CH to AH. Now, AH contains ASCII of 1 and AL contains ASCII of 2.
(AH <= 31 and AL <= 32, so AX=3132).


Now, you can store the contents of AX at some memory location and then use the INT 21 with the 09H. (Make sure to store 24 (ASCII of $) at the end of the ASCII of numbers storeed in memory.)
 
OP
a_to_z123

a_to_z123

asia://india/ka/bangalore
Thanx a lot swatkat!!!

Actually I got in a fix with two digit nos.
I could only print single-digit nos by adding 30h.

I got the gist behind it. Actually it adds 48 to the no and makes it equivalent to its ASCII code. Hai naa.

Well thx again!!

Waiting to try it!!
 
D

Deleted member 5901

Guest
hey swat ur brilliant MAN !!!

Man watz ur qualif ???

Ur an engineer or Mca student or just interest ??

coz if its interest ur EXTREMELY Brilliant !!! Hey even if it the other 2 options ur Brilliant as well !!

neway!!

Cheers !!
 
Status
Not open for further replies.
Top Bottom