hello,
i was wondering if someone could give me an idea on building a program in assembly language which asks the user to enter a string and count the no. of times an entered character occurs in that given string.
help pls... assembly language
Started by ishi, Mar 09 2009 06:01 PM
2 replies to this topic
#1
Posted 09 March 2009 - 06:01 PM
|
|
|
#2
Posted 20 March 2009 - 09:33 PM
First write a C routine in TC that doesn't print but does everything else that you say without using standard libraries. Now compile but don't assemble or link. What you get is the assembly language program. Now print the result using INT 10h BIOS or INT 20/21h (Not sure) dos interrupt.
Size does matter for science and its laws changes accordingly.
[SIGPIC][/SIGPIC]
An C
[SIGPIC][/SIGPIC]
An C
#3
Posted 23 March 2009 - 03:43 PM
Something like this...
It asks for a string, then it checks the ocurrence of character 'A' in the string you entered, and the number of ocurrences is returned by AX. Assemble it with NASM and check it, i think that everything is well...
USE16 ORG 0x100 section .data msg: db 'Insert some text: $' buf: max: db 255 cnt: db 0 str: times 255 db 0 section .text _start: push word msg call near _print push word buf call near _read push word 'A' push word str push word [max] call near _findchr call near _wait call near _exit retn _print: push bp mov bp, sp mov ah, 0x09 mov dx, word [bp+4] int 0x21 pop bp retn 2 _read: push bp mov bp, sp mov ah, 0x0A mov dx, word [bp+4] int 0x21 pop bp retn 2 _findchr: push bp mov bp, sp mov si, word [bp+6] xor cx, cx xor ax, ax .loop: cmp cx, word [bp+8] je .out cmp si, word [bp+4] je .found inc si inc cx jmp .loop .found: inc ax jmp .loop .out: pop bp retn 2 _wait: mov ah, 0x00 int 0x16 retn _exit: mov ax, 0x4C00 int 0x21 retn
It asks for a string, then it checks the ocurrence of character 'A' in the string you entered, and the number of ocurrences is returned by AX. Assemble it with NASM and check it, i think that everything is well...


Sign In
Create Account

Back to top









