tasm


How do you code subtraction in TASM


Okay so I based my codes from the turbo assembler manual that we have...i tried to swap registers and it worked only for the inverse subtraction example 1-2= -1...now my problem in this code is that when the first number is greater than the second number, i cannot get the correct answer
;Subtract
.MODEL Small
.STACK 100h
.DATA
Start DB 13,10,'Subtract 2 numbers!$'
FOne DB 13,10,'Enter first set number1: $'
FTwo DB 13,10,'Enter first set number2: $'
Diff1 DB 13,10,'Difference is: $'
.CODE
mov ax,#data
mov ds,ax
mov dx,OFFSET Start
mov ah,09h
int 21h
mov dx, OFFSET FOne
mov ah,09h
int 21h
mov ah,01h
int 21h
MOV BL,AL
AND BL,0Fh
mov dx, OFFSET FTwo
mov ah,09h
int 21h
mov ah,01h
int 21h
AND AL,0Fh
compare:
cmp AL,BL
jge reverse
jnz normal
normal:
mov ah,00h
SUB BL,AL
AAS
OR AX,3030h
MOV BX,AX
mov dx,OFFSET Diff1
mov ah,09h
int 21h
mov dl,Bh
mov ah,02h
int 21h
mov dl,Al
int 21h
mov ah,02h
jmp exit
reverse:
mov ah,00h
SUB AL,BL
AAS
OR AX,3030h
MOV BX,AX
mov dx,OFFSET Diff1
mov ah,09h
int 21h
mov dl,"-"
mov ah,02h
int 21h
mov dl,Bh
mov ah,02h
int 21h
mov dl,Bl
mov ah,02h
int 21h
jmp exit
exit:
mov ah,4ch
int 21h
END
ok so i guess i got it :D
;Subtract
.MODEL Small
.STACK 100h
.DATA
Start DB 13,10,'Subtract 2 numbers!$'
FOne DB 13,10,'Enter first set number1: $'
FTwo DB 13,10,'Enter first set number2: $'
Diff1 DB 13,10,'Difference is: $'
Rtry DB 13,10,'Enter new inputs?[y][n]: $'
.CODE
mov ax,#data
mov ds,ax
mov dx,OFFSET Start
mov ah,09h
int 21h
mov dx, OFFSET FOne
mov ah,09h
int 21h
mov ah,01h
int 21h
MOV BL,AL
AND BL,0Fh
mov dx, OFFSET FTwo
mov ah,09h
int 21h
mov ah,01h
int 21h
MOV BH,AL
AND AL,0Fh
compare:
cmp AL,BL
jg reverse
jnz normal
normal:
mov ah,00h
SUB BL,BH
MOV AL,BL
AAS
OR AX,3030h
MOV BX,AX
mov dx,OFFSET Diff1
mov ah,09h
int 21h
mov dl,Bh
mov ah,02h
int 21h
mov dl,Bl
int 21h
mov ah,02h
jmp exit
reverse:
mov ah,00h
SUB AL,BL
MOV BH,AL
AAS
OR AX,3030h
MOV BX,AX
mov dx,OFFSET Diff1
mov ah,09h
int 21h
mov dl,"-"
mov ah,02h
int 21h
mov dl,Bh
mov ah,02h
int 21h
mov dl,BL
mov ah,02h
int 21h
jmp exit
exit:
mov ah,4ch
int 21h
END

Related Links

How do you code subtraction in TASM
How to do inverse subtraction in TASM?
Display Negative numbers in TASM
getch() in TASM
why do we use 0dh,0ah after msg1 db in this statement :msg1 db 0dh, 0ah, “ENTER A CHOICE $”;
TASM problems with output
TASM Can't locate .asm file Error: **Fatal** Command line: Can't locate file: filename.asm
TASM giving no output after compile
I can't figure out how to delete a row in my tasm assembly homework
How to read and write A FAT in WinXP [duplicate]
Turbo Assembler [closed]
8086 programming using TASM: pc to pc communication

Categories

HOME
embedded
twitter-bootstrap-3
eslint
android-studio-2.2
object
entity-framework-core
ado.net
qpython
arangodb
reactive-programming
heap
text-mining
datastage
comsol
cumulocity
qsqlquery
microsoft-dynamics-nav
template-engine
foreign-keys
digital-signature
replication
symbols
imagemap
inno-download-plugin
visual-studio-extensions
jboss6.x
moses
jackson-modules
underscore.js
user-defined-functions
finagle
google-cast
utorrent
database-comparison
cart
carriage-return
navigator
raft
hivemq
android-augmented-reality
nohup
verifiable-c
levenshtein-distance
skylink
escpos
claims
outputcache
contract
puredata
vaadin-elements
opennms
proget
gitlist
chai-as-promised
mschart
vugen
context-switch
gpg-signature
cmp
pure-css
google-cloud-console
nikeplus-api
hclust
jtwig
tracker-enabled-dbcontext
sklearn-pandas
fuzzywuzzy
thread-sleep
terracotta
page.js
sql-server-data-tools
skspritenode
ansi
google-refine
cakephp-2.7
dot.js
document-repository
delayed-execution
android-vibration
contrast
spy++
mdichild
mobility
vsx
maven-scm
cfcache
synapse
ora-06550
gd-graph
ice-cube
ui-select2
cascadingdropdown
os.system
wcf-configuration
cuda-gdb
jdb
isa-swizzling
cgimage
workflow-services
tournament
eclipse-marketplace
tabpanel
web-application-project
linfu-dynamicproxy
product-management
wspbuilder

Resources

Encrypt Message