Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

i need help..

im having a prOblem with my code..

its dOne actually but there's missing..

its a conversion of an uppercase letter into a lowercase..

it is required to display an 'INVALID' whenever i entered a lowercase..

and that is my problem..

here's my code..

please help me..

------------------------------------

.MODEL SMALL
.STACK 100h
.DATA

UpperPrompt DB "Enter an Uppercase letter: $"
DisplayLower DB 13,10, "Lowercase: $"

.CODE

start:
mov ax, @data
mov ds, ax
mov dx, OFFSET UpperPrompt
mov ah, 9h
int 21h

mov ah, 1h
int 21h

mov bl, al

add bl, 32d


mov dx, OFFSET DisplayLower
mov ah, 9h
int 21h

mov dl, bl
mov ah, 2h
int 21h

mov ax, 4c00h
int 21h

end start

------------------------------------

thanks in advance..

Comments

  • m34tb34tm34tb34t Member Posts: 25
    [code]
    mov bl,al
    [b]cmp bl,'Z'
    jna notLowerCase
    mov dx,offset InvalidMessage
    mov ah,9
    int 21h
    mov ah,4ch
    int 21h
    notLowerCase:
    [/b]add bl,32b
    [/code]
  • sius87sius87 Member Posts: 2
    001 TITLE (wCount.asm)
    002
    003 .model large
    004 .stack 4096
    005 .386
    006
    007 .data
    008
    009 msg byte 0dh, 0ah, 0dh, 0ah, "Demonisch Basic Word Count", 0dh, 0ah, "Type some text (maximum 100 chars) then press enter", 0dh, 0ah, "to see how many words the text contains", 0dh, 0ah, 0dh, 0ah, ":$"
    010 msgN byte 0dh, 0ah, 0dh, 0ah, "Number of Words: $"
    011 msgEnd byte 0dh, 0ah, 0dh, 0ah, "Press any key to continue", 0dh, 0ah, 0dh, 0ah, "$"
    012
    013 input byte 100 DUP ('$')
    014
    015 num word 0000h ;Used so data ends on a word boundary
    016
    017 .code
    018
    019 main PROC
    020
    021 mov ax, SEG msg
    022 mov ds, ax
    023
    024 mov ah, 9
    025 mov dx, OFFSET msg
    026 int 21h
    027
    028 mov cx, 0000h ;CL counts how many char, CH counts reading the chars back
    029 cld
    030
    031 lea di, input
    032 mov ah, 1
    033
    034 getText:
    035
    036 int 21h
    037
    038 cmp al, 0dh ;Return
    039 je wordC
    040
    041 mov [di], al
    042
    043 inc di
    044 inc cl
    045
    046 cmp cl, 64h ;Keep looping as long as it is under 100 chars
    047 jl getText
    048
    049 wordC:
    050
    051 cmp cl, 00h ;If no chars were entered
    052 je proEnd
    053
    054 mov ax, 0000h ;Used to remember if first char was space
    055 mov bx, 0000h ;Used to count how many words
    056 mov dx, 0000h ;Used to remember the last index of a space char
    057
    058 lea di, input
    059
    060 count:
    061
    062 mov al, [di]
    063 cmp al, 20h ;If a space is found
    064 je hanS
    065
    066 count2:
    067
    068 inc di
    069 inc ch
    070
    071 cmp ch, cl ;Keep looping while not all entered chars have been read
    072 jl count
    073
    074 cmp ch, 01h ;Handle differently if only one char was entered
    075 je hanCF
    076
    077 hanCT:
    078
    079 inc dl
    080
    081 cmp dl, ch ;If the last char was a space then don't count it
    082 je results
    083
    084 addWord:
    085
    086 inc bl
    087
    088 jmp results
    089
    090 hanCF: ;Only one char was entered
    091
    092 cmp ah, 01h ;Was it a space
    093 je results
    094
    095 jmp addWord
    096 ;HANDLE SPACES
    097 hanS:
    098
    099 cmp ch, 00h ;At the start dl will be 0, so must check first char myself
    100 je hanSF
    101
    102 cmp ch, 01h ;DL at the start is 0, but if a word such as "A" has been entered it would think it was a double space
    103 je hanSS
    104
    105 mov dh, ch
    106 dec dh
    107
    108 cmp dh, dl ;If last char was a space (prevent double space)
    109 je hanSE
    110
    111 jmp hanSYes
    112
    113 hanSF: ;First char is a space
    114
    115 mov ah, 01h
    116 jmp hanSE
    117
    118 hanSS: ;Second char is a space
    119
    120 cmp ah, 01h ;Was the first char a space
    121 je hanSE
    122
    123 hanSYes:
    124
    125 inc bl
    126
    127 hanSE:
    128
    129 mov dl, ch ;DL stores the last index of a space char
    130 jmp count2
    131 ;END HANDLE SPACES
    132 results:
    133
    134 mov ah, 9
    135 mov dx, OFFSET msgN
    136 int 21h
    137
    138 call disNum
    139
    140 proEnd:
    141
    142 mov ah,9
    143 mov dx,OFFSET msgEnd
    144 int 21h
    145
    146 mov ah, 1 ;Wait for any key, allows the user to read any output
    147 int 21h ;before the programme ends and the window closes
    148
    149 mov ah, 4ch
    150 int 21h
    151
    152 main ENDP
    153 ;--------------------------------------------------------------------------------;
    154 disNum PROC
    155
    156 .data
    157
    158 numOut word 0000h
    159
    160 .code
    161
    162 mov numOut, bx ;Store a copy before pushing, so the original after this method stays the same
    163
    164 push ax
    165 push bx
    166 push cx
    167 push dx
    168 push si
    169 push di
    170
    171 mov bx, numOut ;Use this copy
    172
    173 cmp bx, 0000h ;If number is greater then or equal to 0
    174 jge disNumF
    175
    176 mov ah, 6
    177 mov dl, 2Dh ;Display the - sign
    178 int 21h
    179
    180 neg bx ;The filter requires positive numbers, so turn bx into positive
    181
    182 disNumF:
    183
    184 mov cl, 00h
    185
    186 cmp bx, 2710h ; 10000
    187 jge getTTho
    188
    189 cmp bx, 03E8h ; 1000
    190 jge getThou
    191
    192 cmp bx, 0064h ; 100
    193 jge getHun
    194
    195 cmp bx, 000Ah ; 10
    196 jge getTen
    197
    198 jmp disUnit
    199
    200 getTTho:
    201
    202 inc cl
    203 sub bx, 2710h
    204
    205 cmp bx, 2710h
    206 jge getTTho ;While answer is greater then or equal to 10,000 keep looping
    207
    208 disTTho:
    209
    210 add cl, 30h
    211
    212 mov ah, 6
    213 mov dl, cl
    214 int 21h
    215
    216 mov cl, 00h
    217
    218 cmp bx, 3E8h
    219 jl disThou
    220
    221 getThou:
    222
    223 inc cl
    224 sub bx, 3E8h
    225
    226 cmp bx, 3E8h
    227 jge getThou
    228
    229 disThou:
    230
    231 add cl, 30h
    232
    233 mov ah, 6
    234 mov dl, cl
    235 int 21h
    236
    237 mov dl, 2Ch ;Display thousand comma
    238 int 21h
    239
    240 mov cl, 00h
    241
    242 cmp bx, 64h
    243 jl disHun
    244
    245 getHun:
    246
    247 inc cl
    248 sub bx, 64h
    249
    250 cmp bx, 64h
    251 jge getHun
    252
    253 disHun:
    254
    255 add cl, 30h
    256
    257 mov ah, 6
    258 mov dl, cl
    259 int 21h
    260
    261 mov cl, 00h
    262
    263 cmp bx, 0Ah
    264 jl disTen
    265
    266 getTen:
    267
    268 inc cl
    269 sub bx, 0Ah
    270
    271 cmp bx, 0Ah
    272 jge getTen
    273
    274 disTen:
    275
    276 add cl, 30h
    277
    278 mov ah, 6
    279 mov dl, cl
    280 int 21h
    281
    282 mov cl, 00h
    283
    284 cmp bx, 01h
    285 jl disUnit
    286
    287 disUnit:
    288
    289 add bl, 30h
    290
    291 mov ah, 6
    292 mov dl, bl
    293 int 21h
    294
    295 pop di ;Restore previous values, most importantly bx in case the user wants to use that number again
    296 pop si
    297 pop dx
    298 pop cx
    299 pop bx
    300 pop ax
    301
    302 ret
    303
    304 disNum ENDP
    305
    306 END main
  • quikcarlquikcarl Member Posts: 59
    To sius87: if the 3 digit numbers on the left of each
    line is there, then that's your problem; take them off.
    If not, then you need to include error messages from
    your system and assembler so that someone can help.
  • sius87sius87 Member Posts: 2
    <9> illegal instruction
    <10> illegal instruction
    <11> illegal instruction
    <13> illegal instruction
    <15> illegal instruction
    <21> undefined symbol:MSG
    <31> undefined symbol:MSG
    <58> undefined symbol: INPUT
    <135> undefined symbol: MSGN
    <138> forward reference needs override
    <143> undefined symbol: MSGEND
    <158> illegal instruction
    <162> undefined symbol: NUMOUT
    <171> undefined symbol: NUMOUT
Sign In or Register to comment.