Hi,
I am new to assembly language and I am taking a course on it right now. I have a question on how you suppress leading zeros when it displays to the screen.
33w
I am new to assembly language and I am taking a course on it right now. I have a question on how you suppress leading zeros when it displays to the screen.
33w
Depends on what method you are using to "display to the screen."
There are plenty of methods, including BIOS Interrupts, DOS Interrupts, Win32 API Library calls, Linux Kernel API via INT 0x80 and writing directly to video memory to name a good few x86-based ones.
Let us know what method you are using, and then we can possibly advise you on solutions to your problem.
There are plenty of methods, including BIOS Interrupts, DOS Interrupts, Win32 API Library calls, Linux Kernel API via INT 0x80 and writing directly to video memory to name a good few x86-based ones.
Let us know what method you are using, and then we can possibly advise you on solutions to your problem.
Thanks for the response,
I don't want to try to get my homework done here, I really am trying to learn this. Can you tell me if I am thinking along the right path.This is where the code is at. I am thinking that I would compare what is in HUN and if it is a zero then I would jump to display a blank.
The code goes on to get the tens digit and ones digit. I also have a question on when it displays. In the .data section I am identifying my data. When it runs through the code it prints .
The number is 026.
What exactly is telling it to print HUNTENONES after "The number is". Is it the DB 0DH,0AH,'$' statement that is saying to add these right after the statement
Thanks for the help.
33w
I don't want to try to get my homework done here, I really am trying to learn this. Can you tell me if I am thinking along the right path.This is where the code is at. I am thinking that I would compare what is in HUN and if it is a zero then I would jump to display a blank.
.model small
.data
BINVAL DB 26
MSG DB 'The number is '
HUN DB ?
TEN DB ?
ONE DB ?
BLANK DB ' ' ; I added this so I could make it print a blank in place of a zero
DB 0DH,0AH,'$'
.CODE
.STARTUP
CALL BTOD
LEA DX,MSG
MOV AH,9
INT 21H
.EXIT
BTOD PROC FAR
MOV AL,BINVAL ;load binary input value
SUB AH,AH ;prepare for division by 100
MOV BL,100
DIV BL ;get hundreds digit
ADD AL,30H ;convert into ASCII digit
MOV HUN,AL ;and save
CMP HUN,0 ;see if it is zero This is where I think I should compare it to zero then jump
JZ BLANK ; jump to blank
The code goes on to get the tens digit and ones digit. I also have a question on when it displays. In the .data section I am identifying my data. When it runs through the code it prints .
The number is 026.
What exactly is telling it to print HUNTENONES after "The number is". Is it the DB 0DH,0AH,'$' statement that is saying to add these right after the statement
Thanks for the help.
33w
or maybe I should look at putting it here.
.CODE
.STARTUP
CALL BTOD
CALL SUPP ;need to compare my digits to zero and suppress
LEA DX,MSG
MOV AH,9
INT 21H
.EXIT
SUPP PROC FAR
CMP HUN,0
JZ NOTH ;now I need to figure how to suppress
Would this be a more efficient place to do it?
33w
.CODE
.STARTUP
CALL BTOD
CALL SUPP ;need to compare my digits to zero and suppress
LEA DX,MSG
MOV AH,9
INT 21H
.EXIT
SUPP PROC FAR
CMP HUN,0
JZ NOTH ;now I need to figure how to suppress
Would this be a more efficient place to do it?
33w
Strings with predefined terminators, such as '$' for the DOS Interrupt you specified, are easier to deal with since they rely on sequential string access up to the point of the string terminator.
To put simply, you need to detect leading zeros in your string prior to calling the Interrupt. You can simply check the BYTE value at DS:DX and increment DX for each instance of '0' (30h in ASCII) you find. You must also check for the string terminator, '$', yourself, as you cannot assume that the string doesn't contain only zeros (safe programming practices).
Steps to Achieve this (SUPP)
-Load DX with the address of the String
-Check DS:DX for 30h (ASCII zero)
-Increment DX for each 30h (ASCII zero) you find, stop when you don't find anymore
-Determine if the last DS:DX value you found is the String Terminator ('$'), handle such an error appropriately
-Return from function accordingly
To put simply, you need to detect leading zeros in your string prior to calling the Interrupt. You can simply check the BYTE value at DS:DX and increment DX for each instance of '0' (30h in ASCII) you find. You must also check for the string terminator, '$', yourself, as you cannot assume that the string doesn't contain only zeros (safe programming practices).
Steps to Achieve this (SUPP)
-Load DX with the address of the String
-Check DS:DX for 30h (ASCII zero)
-Increment DX for each 30h (ASCII zero) you find, stop when you don't find anymore
-Determine if the last DS:DX value you found is the String Terminator ('$'), handle such an error appropriately
-Return from function accordingly
THANK YOU!!
I finally got my code to work
33w
I finally got my code to work
33w