Şimdi Ara

Assembly Language Programming Yardim Lutfen!

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
1 Misafir - 1 Masaüstü
5 sn
2
Cevap
0
Favori
350
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
Öne Çıkar
0 oy
Sayfa: 1
Giriş
Mesaj
  • Arkadaslar sinirli bilgide egitim aldik ve bizden bir proje yapmamiz istendi. Hocaninda yardimiyla projenin bir kismini yaptim ama bir noktada takildim. ilk once ilk kisim onceden verilmis bir cumlenin icindeki belli bir harf sayisini bulma!

    OR: (Proje 1)

    "Benim evim!"
    e = 2 (2 tane e var)

    -Bu kismi kolaydi, ama simdi bu programdan yola cikarak onceden belli cumleye onceden belli olmayan kullanicinin girdigi bir harfi bulmak istiyorum

    OR: (Proje 2)

    Bir harf girin:
    i
    "Benim evim!"
    i = 2 (2 tane i var)

    Cok sinirli bilgim oldugu icin, proje 1`de nasil degisiklikler yapabilirim proje 2 ye ulasmak icin, bilgili arkadaslarda tuyo bekliyorum!
    Tesekkurler!

    Proje 1 Code:
     
    ##
    ## ALP: TP5 - count.asm [Indexed Addressing]
    ##
    ## Count the occurrences of a specific
    ## character (char) found in a string array "str".
    ## Indexing used to access each array element, in turn.
    ##
    ## t0 - holds each byte from string in turn
    ## t1 - index into array: k in str(k)
    ## t2 - count of occurences
    ## t3 - holds the character to search for
    ##
    .text
    .globl main
    main: nop # initialise loop variables [no operation 'instruction']
    li $t1,0 # $t1 will be the array index
    li $t2,0 # $t2 will be the counter
    lb $t3,char # $t3 holds the search-for character
    #
    loop:
    lb $t0,str($t1) # fetch next character
    # from location: str + ($t1) i.e. " str(k)"
    # indexed addressing (= base + offset)
    # (psuedo instruction; assembles as two actual instructions)

    beqz $t0,strEnd # if it's a null, then exit loop
    bne $t0,$t3,con # else not null; is it same as target char?
    add $t2,$t2,1 # yes, so increment counter
    con: add $t1,$t1,1 # and either way increment index: "k = k + 1"
    j loop # then continue to work along string
    #
    strEnd: # string search all done so deliver output
    la $a0,str # system call to print the string
    li $v0,4
    syscall

    la $a0,txt1 # then print output message
    syscall
    la $a0,char # with target char in
    syscall
    la $a0,txt2 # then print output link message
    syscall

    move $a0,$t2 # system call to print [ = 'copy']
    li $v0,1 # out the count worked out
    syscall

    la $a0,endl # system call to print
    li $v0,4 # out a newline and identity sign-off
    syscall

    li $v0,10 # (usual quit)
    syscall # au revoir...
    ###
    .data
    str: .asciiz "aybeeceedee*bach.beethoven.chopin/abracadabra$%!+" # {9 e's, 7 a's}
    char: .asciiz "e" # can alter this (to "a", say) and run again

    txt1: .asciiz "\n\n Count of "
    txt2: .asciiz " in the above is "
    endl: .asciiz "\n Cheerio from PJB \n" # (you!)

    ## end of file : TP5 - count.asm



    _____________________________




  • Yokmu su dilden anlayan bir arkadasimiz...
    _____________________________
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.